History log of /haiku/src/system/kernel/fs/vfs.cpp
Revision Date Author Comments
# a9be0efb 31-Aug-2019 Augustin Cavalier <waddlesplash@gmail.com>

kernel/fs: Add support for setting custom VMCaches in vnodes.

This adds one (private) VFS function, and checks in all usages of
the vnode->cache as a VMVnodeCache that it really is one. (Generic
usages, for the moment just the ReleaseRef() calls in vnode
destruction, are intentionally not touched.)

This will be used by ramfs to set the cache from its own,
so that map_file() calls on a ramfs can work.


# 69a9cd36 30-Jul-2019 Augustin Cavalier <waddlesplash@gmail.com>

kernel/fs: Free file descriptors via put_fd(), not free().

FDs are now object_cached, so this triggered an assert-failure panic
trying to put them through the regular allocator. Just use put_fd
to free these instead, so that there is only one "destruction" path
for FDs.

Fixes #15213.


# a04ff4c7 19-Jul-2019 Augustin Cavalier <waddlesplash@gmail.com>

kernel/fs: Fix copy/paste error.


# 62f06d86 18-Jul-2019 Augustin Cavalier <waddlesplash@gmail.com>

kernel/fs: Use an object_cache for the file_descriptor structs.

file_descriptor structs were (following the original packagefs changes)
the 4th most allocated item during the boot, with 11903 instances.
These are of course all rather ephemeral, as after the boot finished
there were only 70-some-odd remaining (which is surprisingly low,
I though.)

During heavy system use, this will of course get hit much more often.
So making them object_cached for both performance and memory reasons
makes a lot of sense.


# 14cbb958 13-Jul-2019 Augustin Cavalier <waddlesplash@gmail.com>

kernel/vfs: Unlock KPath buffers after copying them.

Otherwise we will call UnlockBuffer() when we potentially never
called LockBuffer().

Fixes #15157.


# 42e3c6f9 10-Jul-2019 Augustin Cavalier <waddlesplash@gmail.com>

KPath: Use an object_cache for the path buffers in the normal case.

This was (following the packagefs changes) the number-one (by call
count) consumer of malloc() during the boot -- 52866 calls, and 100%
of them either 1024 or 1025 bytes!

Virtually all of these are ephemeral (indeed, the object_cache
stats after a boot with this patch shows there is only a single slab
of 64 buffers allocated, and most of them unused), so this is
probably a significant performance boost.

Change-Id: I659f5707510cbfeafa735d35eea7b92732ead666


# 858e5775 10-May-2019 Jérôme Duval <jerome.duval@gmail.com>

vfs: fail only truncate on file descriptors opened read-only.

chmod is allowed.

Change-Id: Idcac38bdd7f0d614538421a41dfd30066a0c316f
Reviewed-on: https://review.haiku-os.org/c/1444
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>


# 03ed26b6 29-Mar-2019 Jérôme Duval <jerome.duval@gmail.com>

kernel/fs/vfs: apply CLOEXEC on the new fd instead of the old one.

fix a failure for test-cloexec.c of gltests.

Change-Id: I340cc88a787a59d55f93cc80883f57e6627f38cf
Reviewed-on: https://review.haiku-os.org/c/1332
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# fb1dd50e 25-Feb-2019 Augustin Cavalier <waddlesplash@gmail.com>

kernel/fs: Make fs_mount::lock a mutex instead of a recursive_lock.

Solves a TODO.


# 38c4c8bf 20-Feb-2019 François Revol <revol@free.fr>

kernel: fix mount arguments checks from userland

Since NULL is not considered a user address anymore, we must check for
it first.

This fixes the "mount: Bad address" error after hrev52905.

Change-Id: If60ea58bb81b6c35c6bf27ecfa9b29bd7a25d8aa


# 8497a2cc 12-Jul-2012 ahenriksson <sausageboy@gmail.com>

vfs: functions to change a vnode busy status and ID

The kernel version is only partially tested.

Change-Id: I9a2f6c78087154ab137eadbced99062a8a2dd688
Reviewed-on: https://review.haiku-os.org/c/918
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# f22ee592 22-Jan-2019 Augustin Cavalier <waddlesplash@gmail.com>

kernel/vfs: Fix shadowed variables.

The -Werror=uninitialized caught this, but I fixed it the wrong way
rather than looking at the code a little closer.

Should fix the strange bugs that cropped up after the first VFS patch.


# 3f77fdd1 21-Jan-2019 Augustin Cavalier <waddlesplash@gmail.com>

kernel/vfs: Fix -Werror=maybe-uninitialized.


# cb0d3bd3 22-Jan-2019 Leorize <leorize+oss@disroot.org>

kernel/fs/vfs: add truncation check for user_strlcpy calls

**Lots** of syscalls here don't check if strlcpy truncated the user
supplied argument. This commit adds them where appropriate.

Closes #2642

Change-Id: Iff89055aeb3a1870c8baf327b60873ce85815cd7
Reviewed-on: https://review.haiku-os.org/c/890
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# e7e7a552 12-Dec-2018 Augustin Cavalier <waddlesplash@gmail.com>

kernel/fs: Account for vnode being NULL in vfs_release_posix_lock.

When the FD is put() but not freed while O_DISCONNECTED, its "ops"
and "vnode" are cleared. Thus it is entirely valid for a non-NULL
file FD to have a NULL vnode, so we should just treat such FDs
as if the locks had already been cleared (which they should have.)

Fixes #14294.


# bee962a2 12-Dec-2018 Augustin Cavalier <waddlesplash@gmail.com>

kernel/fs: Consumers of context->fds[] must check O_DISCONNECTED.

Since these do not go through get_fd, which would check for them,
we need to do these checks manually in the relevant locations.

Some of these changes were broken out from axeld's original commit,
and some were found by my own auditing.


# 15ec0b5c 12-Dec-2018 Augustin Cavalier <waddlesplash@gmail.com>

Revert "VFS: Slight rework of the FD disconnect feature."

This reverts commit eb62d3337b82f4dce6b1a0b3f116e38491c66f14.


# 8c053e95 17-Nov-2018 Jérôme Duval <jerome.duval@gmail.com>

vfs: fail write_stat() on file descriptors opened read-only.

Change-Id: I20d586c606c47df6625cc9272f153250a5a621d6
Reviewed-on: https://review.haiku-os.org/706
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 74e882b3 10-Sep-2018 Augustin Cavalier <waddlesplash@gmail.com>

kernel/fs: Flush the underlying device's write cache as part of sync().

BFS does this as part of journal management, but not as part of block
cache synchronization (which makes sense, as flushing it then would
defeat the purpose of the drive's write cache.) No other file system
seems to touch it at all, so we should do it as part of an explicit sync.

This may help with some of the filesystem corruption issues, as it seems
that on slow disks, the drive might not have enough time to flush the cache
before it is powered off (or on some SATA/AHCI based disks, it is not flushed
before close at all), so triggering it here and, as the ioctl is supposed to be
synchronous, waiting for it also, seems to make sense.

Change-Id: I7d9992c21ca4b59c839711dcc96c973b4b8df052
Reviewed-on: https://review.haiku-os.org/530
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 0217e08a 21-Aug-2018 Augustin Cavalier <waddlesplash@gmail.com>

vfs: panic() if volume->ops is NULL but status == B_OK.

This panic, unlike the NULL dereference that would otherwise occur, is
at least continuable.


# de6ea5f4 10-Jul-2018 Augustin Cavalier <waddlesplash@gmail.com>

vfs: Move volume->ops NULL check to just after call to mount().

As Rene pointed out on the mailing list, if this is NULL after the file system
mount call occurs, then something has gone very wrong and we should treat it
as an error.


# 131c64ad 09-Jul-2018 Augustin Cavalier <waddlesplash@gmail.com>

vfs: Add missing NULL check of volume->ops.

I got a reproducible KDL that upon close inspection seems to have been
a NULL dereference of this, thanks to GCC's mix-source-and-assembly
functionality.

Unfortunately, I deleted my mount_server settings before I fully understood
what was going on, and afterwards it no longer reproduced, so it seems to
have been related to that. I'm confident enough this is the correct fix to
commit it anyway.


# 4f5ed463 30-Jun-2018 Jérôme Duval <jerome.duval@gmail.com>

kernel: vfs: common_fcntl() now uses memcpy() for kernel calls.

instead of user_memcpy().

* fix #14204: the NTFS filesystem kernel addon uses the fcntl system call to
lock the underlying device. The user_memcpy replacement in the x86 compat
branch adds range checks for the user pointer, which exposes such problems.


# 4f7b9506 14-Jun-2018 Augustin Cavalier <waddlesplash@gmail.com>

Revert the rest of the COMPAT_MODE changes (back to hrev52003.)

This reverts commit 458e758f3792ef11ca26d6ff7e24600c88326e83.
This reverts commit ce5eb94a82b1b377ef5909e65411e031f54ceb15.
This reverts commit aac8d4c317ca11a9a6e194e2c668e8183ec23dd6.
This reverts commit c70cba914aa79c01bbc2da38085936f589899c8c.
This reverts commit 2ffbe7aaca8668c5a68ac7488459bace7a0700f2
This reverts commit c6e120e2d2f909d95f95839fa99fccf811fdb3c5.


# 2ffbe7aa 18-May-2018 Jérôme Duval <jerome.duval@gmail.com>

kernel/x86_64: compatibility syscalls for vfs.cpp.

* define compat_flock, compat_timespec, compat_stat, compat_attr_info,
compat_fs_info, compat_fd_info to be used for respective 32-bit types
of syscalls in compatibility mode.
* handle 32-bit types in common_fcntl(), _user_read_stat(), _user_stat_attr(),
_user_read_index_stat, _user_read_fs_info, _user_write_fs_info,
_user_get_next_fd_info, other syscalls are compatible as is.

Change-Id: I5b372169fe142f67b81fd6c27e0627d5119ba687


# 8bca37d6 14-Jan-2018 Adrien Destugues <pulkomandy@pulkomandy.tk>

vfs: Bind flock locks to file descriptors

* File locks created by flock should only apply for the file descriptor
that was used to lock the file. Another fd on the same file should then
be denied access (calling flock should fail).
* fcntl based locks, however, are in a separate namespace and are global
to a team.
* This issue was found when running webkitpy test suite, and should close
ticket #13795.
* Don't use session or team as comparison in release_advisory_lock(), as
that information might not be available anymore (e.g. when called from
Team::~Team()). This fixes #14121.

Change-Id: I9efb96cfcefe7e72b0060220c635a665e7e643cc
Co-authored-by: Axel Dörfler <axeld@pinc-software.de>


# 7750fdcf 18-Apr-2018 Axel Dörfler <axeld@pinc-software.de>

vfs: _user_flock() did not use FS advisory locking calls

* The kernel's advisory locking implemenation must not be used if the
file system has its own (ie. network file systems).
* Added ASSERT to free_vnode() that assures there is no locking left;
I recently had a lot of them around.


# a9388f6d 20-Jan-2018 Xiang Fan <sfanxiang@gmail.com>

kernel: vfs: don't notify output-only select events by default

Output-only events (B_EVENT_ERROR, B_EVENT_DISCONNECTED and
B_EVENT_INVALID, with B_EVENT_INVALID masked out before passing down
events) are used to indicate error, so they should not be notified if
the vnode does not have select().

Bug: 13965


# 9fbffea6 07-Jan-2018 Jérôme Duval <jerome.duval@gmail.com>

kernel: vfs: don't use the attribute name user buffer directly.

instead copy the name on the stack.


# e46e9fee 03-Jan-2018 Jérôme Duval <jerome.duval@gmail.com>

vfs: check userland buffers before reading them.


# 019828ab 17-Dec-2017 Augustin Cavalier <waddlesplash@gmail.com>

VFS: Add proper locking of the team structure in disconnect_mount_or_vnode_fds.

The KDL in #13861 was apparently caused by a NULL io_context. I read over
the Team code and have applied the following fixes here as a result:

1. A NULL io_context is entirely possible, as implied by the NULL check
before deinitializing it in Team's destructor, so account for that.

2. Team objects have a class-wide lock which must be acquired before
directly accessing class members, so use that here.

First part of the fix for #13861.


# 26740b28 24-Aug-2017 Jérôme Duval <jerome.duval@gmail.com>

POSIX: F_DUPFD_CLOEXEC support (POSIX.1-2008).

* fix #12187.


# 2d4d0f0a 12-Jul-2017 Jérôme Duval <jerome.duval@gmail.com>

Revert "vfs.cpp: Fix gcc6 crash."

This reverts commit 5b55f6dba9d905e26729961a146de825277c9d79.


# 5b55f6db 10-Jul-2017 Murai Takashi <tmurai01@gmail.com>

vfs.cpp: Fix gcc6 crash.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>


# 16825fd9 30-Apr-2017 Axel Dörfler <axeld@pinc-software.de>

VFS: Pass on NULL for NULL paths, if allowed.

* Uses the new KPath::LAZY_ALLOC feature.
* This closes ticket #9625.


# eac83fb3 30-Apr-2017 Axel Dörfler <axeld@pinc-software.de>

KPath: Replaced booleans with flags field.

* No functional change intended; I chose the flags in a way that it
should still work even if I missed a reference.


# 742b85c1 02-Apr-2017 Axel Dörfler <axeld@pinc-software.de>

vfs: Let new_vnode() and publish_vnode() wait for busy vnodes.

* Both functions need to wait when encountering a busy vnode, in order
not to create a race condition in combination with get_vnode().
* This should fix both #5262, and #9839.
* I did not implement Ingo's suggestion to burden the file systems with
solving the problem for the following reasons:
- I think the file system interface should be as simple as possible.
- I can't think of a possible locking issue at least for BFS.
- The solution on the file system side would look pretty similar to
what the VFS already does or has to do (minus controlling the locking
directly), so it would cause quite a functional duplication.


# 67988f50 21-Mar-2016 Axel Dörfler <axeld@pinc-software.de>

NodeMonitor: Resolve mount points for B_WATCH_CHILDREN.

* When a watched directory contains a mount point, we need to resolve
the actual parent directory of the mount point in the file system to
serve the monitor.


# ba307a12 08-Nov-2015 Michael Lotz <mmlr@mlotz.ch>

vfs: Cleanup: Move functions around for more logical grouping.

Move static internal functions out of the API functions block and drop
their vfs_ prefix and move an API function into the API functions block.


# c73d1301 08-Nov-2015 Michael Lotz <mmlr@mlotz.ch>

kernel: Use anonymous namespaces to avoid type collisions.

The anonymous namespace makes type definitions local to the translation
unit (like static does for objects). For pretty much any type not shared
across multiple files this is what one wants to happen (and might
erroneously expect to happen automatically).

This commit solves some actual collisions that were present:

* The VFS and the rootfs both used an incompatible VnodeHash struct for
their BOpenHashTable.
* XSI semaphores and message queues both used queued_thread, Ipc and
IpcHashTableDefinition.

For release builds these did not cause problems as the types were fully
inlined. Debug builds would crash at boot however because parts of a
BOpenHashTable<VnodeHash> from the rootfs meant to operate on struct
rootfs_vnode would be applied to one from the VFS expecting struct
vnode.

As such collisions are violations of the one definition rule, the code
is at fault and unfortunatley the compiler isn't required to diagnose
such problems across translation units (which isn't actually trivial).
This can lead to subtle and hard to debug problems and it's therefore
best to avoid leaking types into the global namespace whenever possible.


# c518435b 07-Nov-2015 François Revol <revol@free.fr>

VFS: pass correct vnode to fs calls in default get_vnode_name

The opendir and closedir/free_dircookie hooks were called with
mismatched vnode. It seems only googlefs is actually affected by this,
since all other fs without a get_vnode_name just don't are about the
passed vnode arg to closedir and free_dircookie.

Now I should really get some sleep!


# 8f4a653c 07-Nov-2015 François Revol <revol@free.fr>

VFS: typo


# 1e6dd3fe 24-Apr-2015 Murai Takashi <tmurai01@gmail.com>

Fix GCC 5 maybe-uninitialized warnings.

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

Fixes #12020


# 13882115 11-Oct-2015 Adrien Destugues <pulkomandy@pulkomandy.tk>

Implement stat.st_rdev for block and character devices.

* devfs: set st_rdev to the inode number of the node being queried. This
may not be the best thing to do, as it does not match what is set in
st_dev for other files, so it can't be used to find which device
stores a particular file. I'm not sure if st_rdev is actually used that
way anywhere, however.
* vfs: do not clobber st_rdev with -1 for "special" (device) files.
Refactor the code a little so setting the common attributes is done in
a single place.

Fixes #12390.


# 13882115 11-Oct-2015 Adrien Destugues <pulkomandy@pulkomandy.tk>

Implement stat.st_rdev for block and character devices.

* devfs: set st_rdev to the inode number of the node being queried. This
may not be the best thing to do, as it does not match what is set in
st_dev for other files, so it can't be used to find which device
stores a particular file. I'm not sure if st_rdev is actually used that
way anywhere, however.
* vfs: do not clobber st_rdev with -1 for "special" (device) files.
Refactor the code a little so setting the common attributes is done in
a single place.

Fixes #12390.


# eb62d333 11-Sep-2015 Axel Dörfler <axeld@pinc-software.de>

VFS: Slight rework of the FD disconnect feature.

* This should fix ticket #4157, although I probably have missed
something.
* In any case, it no longer messes with the ref counts of the
file descriptor, and the race condition in put_fd() should be
gone.
* It's still rather messy all in all.


# 6adf7a0c 11-Sep-2015 Axel Dörfler <axeld@pinc-software.de>

VFS: prevent FD inheritance for the kernel completely.

* Each io_context now has a "inherit_fds" member that decides whether
or not this context allows to inherit FDs to its children.
* This replaces the former O_CLOEXEC mechanism.


# e668e80d 11-Sep-2015 Axel Dörfler <axeld@pinc-software.de>

VFS: Always open kernel FDs with O_CLOEXEC.

* Avoids leaking them into userland.


# 5d4501aa 20-Aug-2015 Michael Lotz <mmlr@mlotz.ch>

Assorted whitespace cleanup and typo fixes.


# efb0a3a8 17-Aug-2015 Michael Lotz <mmlr@mlotz.ch>

EntryCache: Add entry_cache_add_missing() for negative caching.

It provides a way for filesystems to cache a lookup failure and
therefore prevents repeated lookups of missing entries. This is a
common scenario for example in command lookup and compiling, where
each directory in PATH or each include directory is searched for the
given entry.


# 3395fdcd 12-Jan-2015 Adrien Destugues <pulkomandy@gmail.com>

gcc4 build fix.

* offsetof is not allowed on non-POD types so we need to use
offset_of_member (gcc2 accepts offsetof, and C++11 relaxed the
constraints on where it is allowed so it should work there too)
* we have offset_of_member as a workaround until we switch to C++11,
move it from khash (which is soon to be removed) to list.h which is the
other place where it is used (for this one single call in our whole
codebase)

Also fix a typo in vfs.cpp.


# f9defd45 12-Jan-2015 Adrien Destugues <pulkomandy@gmail.com>

VFS: migrate to BOpenHashTable.


# 76b8f002 04-Nov-2014 François Revol <revol@free.fr>

Implement lseek(SEEK_END) on devices

While the partitioning system does publish partitions as block
devices and report their size in stat(), the old BeOS-style
drivers have no means of reporting it this way.
So we fall back to ioctl(B_GET_GEOMETRY) to find out the size.


# 22ea3415 01-Nov-2014 Jessica Hamilton <jessica.l.hamilton@gmail.com>

access: fix to be POSIX compliant


# 6bbd25f0 29-Oct-2014 Ingo Weinhold <ingo_weinhold@gmx.de>

Make vfs_resize_fd_table() accessible in the kernel

Also update some types from int to uint32.


# 5a95af70 25-Oct-2014 Axel Dörfler <axeld@pinc-software.de>

vfs/{b|btr|package|b}fs/ext2/exfat: common access check.

* Added VFS helper function check_access_permissions() that combines
several partially correct versions to the one true version (tm).
* All but BFS (since recently) missed the S_IXOTH for root on directories,
and all but packagefs missed proper group handling.


# 8efd5b76 25-Oct-2014 Axel Dörfler <axeld@pinc-software.de>

vfs: check the X permission on set cwd.

* When you change the current working directory, you actually
should have the permission to enter that directory.
* This gives us a 0.04% better score on the perl test suite :-)


# 8ea3e912 18-Oct-2014 Michael Lotz <mmlr@mlotz.ch>

Typo: Fix doubled "not" in comment.


# d64267ff 09-Jun-2014 Jérôme Duval <jerome.duval@gmail.com>

vfs: checks whether the mount's unmounting flag is already set.

* thanks to Ingo for suggesting the idea, quoting him:
"by holding sVnodeLock read-locked, get_mount() ensures that fs_unmount() can't
process the nodes. If it is already past that point, the root node check
(not NULL, not busy, ref count > 0) is supposed to detect that. But it doesn't
look like this can work. fs_unmount() doesn't set the root node to NULL (the
root node field is NULL only during a short period in fs_mount()), but it just
frees the nodes after releasing sVnodeLock. So the not busy and ref count > 0
checks could already access freed memory".
* tested OK, this fixes #10522.
* replaced mount->root_vnode by the local variable with the same value.


# 38b150a9 24-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

VFS FIFO: Add "fifo" KDL command

Prints information about a FIFO node and, optionally, its data buffer
content.


# 104c0688 11-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

dir_vnode_to_path(): Fix uninitialized status variable


# 07f6506e 11-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

VFS: Fix broken zero_pages()

Besides that it failed to actually iterate through the vectors, it
shouldn't try to clear physical memory in the first place. The iovecs
refer to virtual address ranges. Rename it to zero_iovecs() to avoid
confusion.


# 18640f25 10-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

vfs: dir_vnode_to_path(): Fix bug with chroot on mount

Simplify the code, which also fixes the bug that the I/O context's root
was ignored when it was a mount point, thus resulting in globally rooted
paths in this case.


# 726e47bb 10-Sep-2013 Siarzhuk Zharski <zharik@gmx.li>

vfs:Remove extra put_vnode call on error B_LINK_LIMIT exit

Fixing the autoconf test: attempt to create file in place of already
existing symlink. On error exit put_vnode was called explicitly before
returning error. The second, implicit call to put_vnode was issued on
destroying the VNodePutter instance that references the same vnode. At
this time the vnode has references count equal to 0 so corresponding
panic was executed. Great thanks to Ingo for pointing it out!

Fixes #9140.


# a56422b4 01-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

VFS: fs_mount(): fix FS name leak

Fixes #9909.


# 311e1487 29-Apr-2013 Jérôme Duval <jerome.duval@gmail.com>

vfs: fixed two warnings.

* warnings about comparison between signed and unsigned integer expressions.


# 237127fb 22-Apr-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Fix _user_entry_ref_to_path() in chroot

* Add "bool kernel" parameter to vfs_entry_ref_to_path(), so it can be
specified for which I/O context the entry ref shall be translated.
* _user_entry_ref_to_path(): Use the calling team's I/O context instead
of the kernel's. Fixes the bug that in a chroot the syscall would
return a path for outside the chroot.


# 5b6fb78c 05-Apr-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

VFS: _kern_open_dir(): Fix NULL path case

It would create an empty path buffer and pass that on to dir_open(),
which accepts NULL, but not empty paths.


# 8627383b 22-Mar-2013 Alex Smith <alex@alex-smith.me.uk>

Fixed compilation errors with ENABLE_TRACING set.


# 1aef6664 22-Mar-2013 Alex Smith <alex@alex-smith.me.uk>

Fixed compilation of VFS/IORequest trace messages.


# 1a0386d7 12-Mar-2013 Pawel Dziepak <pdziepak@quarnos.org>

Fix #8661: fcntl(fd, F_GETLK, ...) violates POSIX

The standard states that F_GETLK should check whether given lock would be
blocked by another one and return description of the conflicting one (or
set l_type to F_UNLCK if there is no collision).

Current implementation of F_GETLK performs completely different actions, it
"Retrieves the first lock that has been set by the current team". Moreover,
if there are no locks (advisory_locking == NULL) an error is returned
instead of l_type set to F_UNLCK.


# d50875de 02-Dec-2012 Michael Lotz <mmlr@mlotz.ch>

Use format macros in debug output.


# 195a0f35 21-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Changed argument type of fcntl syscall from uint32 to size_t.

Since this argument may be used to pass pointers, uint32 is not
correct for 64-bit. Effectively no change on 32-bit targets, both
size_t and uint32 are unsigned long there.


# c3f0fd28 12-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed formatting of output in some debugger commands.

Currently all debugger commands assume 32-bit pointers when formatting their
output. This means that on x86_64 the output is incorrectly formatted. Fixed
this by adding a B_PRINTF_POINTER_WIDTH definition (16 on 64-bit, 8 on
32-bit), and using this to correctly format the output. Not all commands have
been fixed yet, but all VM, slab, VFS, team, thread and image commands should
be correct.


# d764d148 27-Jun-2012 Pawel Dziepak <pdziepak@quarnos.org>

Allow file systems to manage file locks

Haiku implements file locking at vfs level. That would not work for remote
and shared file systems, since they need to negotiate locks with peers.
This patch introduces three additional hooks in fs_interface that allow
file system module to take over the management of file locks.


# 4be4fc6b 15-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

More 64-bit compilation/safety fixes.


# 4bbb27e3 12-Feb-2012 Jerome Duval <jerome.duval@gmail.com>

More 'GCC4.6 variable set but not used' fixes.


# 7ef47de9 13-Feb-2012 czeidler <haiku@clemens-zeidler.de>

Revert "Finally applying the patch that adds support to add path information to stat and attr monitor messages."

Will recommit it when I have more time to work on the todos.

This reverts commit 610ef6c00781522022455c0cbf34495420b2db1d.


# 610ef6c0 21-Jan-2012 czeidler <haiku@clemens-zeidler.de>

Finally applying the patch that adds support to add path information to stat and attr monitor messages.
* for all open FD the path information is stored in a map
* this info is used to fill the missing fields in the node monitor


# 04999b6c 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Completed vfs_bind_mount_directory() support

We don't need to explicitly track the covered/covering nodes per mount
after all. In fs_unmount() we iterate through all vnodes multiple times
anyway and can deal with the covers/covered_by vnodes there. Also, the
root vnode doesn't need to be handled specially anymore.


# 1b08a68a 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

vfs_bind_mount_directory(): Fail if unmounting


# 8855625e 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

fix_dirent(): Fix ref count leaks

* Only get an additional parent reference, when going to call
vnode_path_to_vnode().
* Put the reference of the vnode vnode_path_to_vnode() returns.


# e4320fd7 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

remove_vnode(): Also consider covering vnode busy


# 54e721af 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add support for bind-mounting directories

* Add support function vfs_get_mount_point(), so a file system can get
its own mount point (i.e. the node it covers). Re-added
fs_mount::covers_vnode for that purpose -- the root node isn't know to
the VFS before the mount() hook returns.
* Add function vfs_bind_mount_directory() which bind-mounts a directory
to another. The Vnode::covers/covered_by mechanism is used, so this
isn't true bind-mounting, but sufficient for what we need ATM and
cheaper as well. The vnodes connected thus aren't tracked yet, which
is needed for undoing the connection when unmounting.
* get_vnode_name(): Don't use dir_read() to read the directory. Since we
have already resolved vnode to the covered vnode, we don't want the
dirents to be "fixed" to refer to the covering nodes. Such a vnode
simply wouldn't be found.


# f4a1387c 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add vfs_ prefix to resolve_vnode_to_covering_vnode()


# 47ea54c5 20-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Generalize use of Vnode::covered_by/covers

* Introduce Vnode flags for covered and covering. Can be used as a quick
check when one doesn't already hold sVnodeLock.
* Rename resolve_mount_point_to_volume_root() to
resolve_vnode_to_covering_vnode().
* Adjust all code that deals with transitions between mount points and
volume root vnodes to generally support covered/covering vnodes.


# 02be66ca 20-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced fs_mount::covers_vnode by Vnode::covers

Introduce a Vnode::covers field. It is currently only used for the root
node of an fs_mount, replacing fs_mount::covers_vnode.


# 7bb72b8d 20-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Comment typo fixes


# a735bdeb 31-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

Align all filesystem relevant places to use B_UNSUPPORTED for unsupported
instead of a mix of B_NOT_SUPPORTED and B_UNSUPPORTED. This allows checking for
a specific error code. Probably one of those should be phased out...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43025 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d5e36fb5 10-Aug-2011 Axel Dörfler <axeld@pinc-software.de>

* Introduced new fs_lopen_attr_dir() function that opens the attribute
directory of a file without traversing leaf links (just like lstat()).
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42620 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 33272012 10-Aug-2011 Axel Dörfler <axeld@pinc-software.de>

* Fixed reversed handling of O_NOTRAVERSE in attr_open(), and attr_create().
* Added support for O_NOFOLLOW for those two as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42619 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fe592884 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Completed vfs_bind_mount_directory() support

We don't need to explicitly track the covered/covering nodes per mount
after all. In fs_unmount() we iterate through all vnodes multiple times
anyway and can deal with the covers/covered_by vnodes there. Also, the
root vnode doesn't need to be handled specially anymore.


# 0be138ab 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

vfs_bind_mount_directory(): Fail if unmounting


# 19c48aa4 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

fix_dirent(): Fix ref count leaks

* Only get an additional parent reference, when going to call
vnode_path_to_vnode().
* Put the reference of the vnode vnode_path_to_vnode() returns.


# 9561ddca 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

remove_vnode(): Also consider covering vnode busy


# d61a8548 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add support for bind-mounting directories

* Add support function vfs_get_mount_point(), so a file system can get
its own mount point (i.e. the node it covers). Re-added
fs_mount::covers_vnode for that purpose -- the root node isn't know to
the VFS before the mount() hook returns.
* Add function vfs_bind_mount_directory() which bind-mounts a directory
to another. The Vnode::covers/covered_by mechanism is used, so this
isn't true bind-mounting, but sufficient for what we need ATM and
cheaper as well. The vnodes connected thus aren't tracked yet, which
is needed for undoing the connection when unmounting.
* get_vnode_name(): Don't use dir_read() to read the directory. Since we
have already resolved vnode to the covered vnode, we don't want the
dirents to be "fixed" to refer to the covering nodes. Such a vnode
simply wouldn't be found.


# 313e1e37 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add vfs_ prefix to resolve_vnode_to_covering_vnode()


# 2e21fc54 20-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Generalize use of Vnode::covered_by/covers

* Introduce Vnode flags for covered and covering. Can be used as a quick
check when one doesn't already hold sVnodeLock.
* Rename resolve_mount_point_to_volume_root() to
resolve_vnode_to_covering_vnode().
* Adjust all code that deals with transitions between mount points and
volume root vnodes to generally support covered/covering vnodes.


# 3cc71079 20-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced fs_mount::covers_vnode by Vnode::covers

Introduce a Vnode::covers field. It is currently only used for the root
node of an fs_mount, replacing fs_mount::covers_vnode.


# 9280379a 20-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Comment typo fixes


# 24df6592 11-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged signals-merge branch into trunk with the following changes:
* Reorganized the kernel locking related to threads and teams.
* We now discriminate correctly between process and thread signals. Signal
handlers have been moved to teams. Fixes #5679.
* Implemented real-time signal support, including signal queuing, SA_SIGINFO
support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition
of the real-time signal range. Closes #1935 and #2695.
* Gave SIGBUS a separate signal number. Fixes #6704.
* Implemented <time.h> clock and timer support, and fixed/completed alarm() and
[set]itimer(). Closes #5682.
* Implemented support for thread cancellation. Closes #5686.
* Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554.
* Lots over smaller more or less related changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8775d8d2 05-Mar-2011 Jérôme Duval <korli@users.berlios.de>

dir_remove() now handles a path which ends with "/./" and fixed #6817.
Another way would be to disallow removing such a path, as Linux does.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40819 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 548836e4 02-Mar-2011 Jérôme Duval <korli@users.berlios.de>

* if ioctl hook wasn't found, now returns B_DEV_INVALID_IOCTL
* in case fd_ioctl() was about to return B_DEV_INVALID_IOCTL, translate to ENOTTY to satisfy #7279.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40787 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 137c5fe2 16-Jan-2011 Oliver Tappe <zooey@hirschkaefer.de>

* add implementation of bindfs, which can be used to bind-mount
a folder to some other place in the filesystem hierarchy
* add helper function to VFS that encapsulates the "conversion" of a
vnode-pointer to a fs_vnode-pointer (used by bindfs)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40238 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4535495d 10-Jan-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged the signals branch into trunk, with these changes:
* The team and thread kernel structures have been renamed to Team and Thread
respectively and moved into the new BKernel namespace.
* Several (kernel add-on) sources have been converted from C to C++ since
private kernel headers are included that are no longer C compatible.

Changes after merging:
* Fixed gcc 2 build (warnings mainly in the scary firewire bus manager).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 66e85572 02-Jan-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

common_rename(): Fixed incorrect check (array address instead of first
element, CID 4077).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40082 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2757dc8c 21-Nov-2010 François Revol <revol@free.fr>

Fix build with VFS_PAGES_IO_TRACING.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39566 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 31d8c43d 28-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed CID 1262: waitForLock was not only -1 when exiting the loop, it didn't
make much sense to wake up any waiters either in this case.
* Fixed doubled semaphore deletion.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38418 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 87de0cb4 17-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed CID 1199-1202: only call the cache listener in case the open succeeded
(this might also have derefenced a potentially freed vnode).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e855d52 02-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Changed some POSIX error codes to native ones.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37842 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c019945c 17-Jul-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added detail to the comment about why we can't call the create() hook without
O_EXCL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37555 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1cdc3cbb 18-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

The vnode cache also considers the address space low resource state, now.
Together with vnode associated structures like file cache, VMCache, and file
system specific structures the impact on heap usage (and thus address space)
is considerable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37169 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 435c43f5 02-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced type generic_io_vec, which is similar to iovec, but uses types
that are wide enough for both virtual and physical addresses.
* DMABuffer, IORequest, IOScheduler,... and code using them: Use
generic_io_vec and generic_{addr,size}_t where necessary.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36997 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9d570af7 24-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed the type of the "op" parameter of the fs_vnode_ops::ioctl() hook and
the _kern_ioctl() syscall from ulong to uint32.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36927 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1888e228 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

bonefish+mmlr:
The O_CLOEXEC open mode wasn't actually set in the close-on-exec bitmap causing
all files opened with O_CLOEXEC (like done in the storage kit classes) to still
be inherited. This caused for example to be unable to unmount volumes when
opening apps while Tracker touched some files (i.e. copying some large files)
since these apps would inherit the file descriptor and therefore keep the
volume busy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36273 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74fc3e9a 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

bonefish+mmlr:
* Add file descriptor and IO context tracing.
* Some minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36272 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7d9bce24 27-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

debug_resolve_vnode_path(): Avoid duplicate slash at the beginning of the
path.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35642 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c35e2c70 26-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added option "-p" to the "vnode" debugger command. Using the entry cache it
tries to resolve the vnode's path.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35626 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 21d9331e 23-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Beautified the output of the "io_context" command.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35582 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d0e43cc7 24-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

"vnode" does now also print the node type.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35280 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb1819be 07-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Eliminated sVnodeCoveredByMutex. The Vnode::covered_by field is now also
protected by the global vnodes lock. The contention mostly moves to other
locks, though. The total -j8 Haiku image build time is only reduced
minimally.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34938 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7fc65e14 03-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

fs_unmount(): We need to hold the vnodes write lock after all. The upside is
that it saves us from locking the individual vnodes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34872 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a210e610 03-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* free_unused_vnodes(): Be a good citizen and use vnode_used() instead of
playing with the unused list manually. This also clears the vnode's unused
flag, which wasn't done before and would thus cause corruption of the
unused list a bit later.
* fs_unmount():
- Fixed an iteration bug I introduced previously. The iterator would be
advanced twice per iteration, leading to NULL pointer dereferencing
when the vnode count was odd and skipping the checks for every other
vnode.
- All vnodes are going to be freed, so vnode_to_be_freed() has to invoked
for every one of them. The code wasn't adjusted correctly when
introducing the hot vnodes handling.
* Adjusted/improved some comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34871 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 54848900 02-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved the unused vnode management to a new file. Well the few variables
used for it that is.
* The main cause for the heavy contention of the unused vnodes mutex was that
relatively few vnodes are actually used for a longer time. Mainly those are
the volume roots, mmap()ed files, and the files opened by programs. A good
deal of nodes -- particularly directories -- are just referenced for a very
short time, e.g. to resolve a path to a contained entry. This caused those
nodes to be added to and removed from the unused vnodes list very
frequently, thus resulting in a high contention of the mutex guarding it.
To address the problem I've introduced an approximation of a set of "hot"
vnodes, i.e. vnodes that have recently been marked unused. They are stored
in an array that by means of an r/w locker and atomic operations can most
of the time be accessed concurrently. Whenever it gets full, it is flushed
to the actual unused vnodes list.
* dec_vnode_ref_count(): No longer check the unused vnode count every time.
The called new vnode_unused() does only from time to time and returns when
the caller is expected to free some of the unused vnodes. As a side effect
this also fixes a bug I previously introduced: The unused vnode to be freed
was marked busy without being locked first.

The -j8 Haiku image test build shows that the changes reduce the contention
of the unused vnode list mutex to virtually zero without introducing any
significant contention of the new r/w lock. The VMCache lock contention also
seems to be decreased somewhat, which is probably not that surprising
considering that the page writer acquires/releases vnode references with the
cache lock held. The "pages" lock takes over even more contention, now
causing more than 100000 waits per second.
The total build time reduction is about 4.5%. Kernel time drops more than
10%.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34866 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ccbb781 02-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved the vnode structure (to by Vnode class at some time in the future) into
its own header/source files.
* Changed vnode's bit fields to a single, atomically changeable int32 using
flags instead. Added respective accessor methods.
* Added a per-vnode mutex-like lock, which uses 2 bits of the structure and
32 global "buckets" which are used for waiter lists for the vnode locks.
* Reorganized the VFS locking a bit:
Renamed sVnodeMutex to sVnodeLock and made it an r/w lock. In most situations
it is now only read-locked to reduce its contention. The per-vnode locks guard
the fields of the vnode structure and the newly introduced sUnusedVnodesLock
has taken over the job to guard the unused vnodes list.

The main intent of the changes was to reduce the contention of the sVnodeMutex,
which was partially successful. In my standard -j8 Haiku image build test the
new sUnusedVnodesLock took over about a fourth of the former sVnodeMutex
contention, but the sVnodeLock and the vnode locks have virtually no contention
to speak of, now. A lot of contention migrated to the unrelated "pages" mutex
(another bottleneck). The overall build time dropped about 10 %.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34865 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb5c39cb 01-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed TODO again. I tried a similar event mechanism as used for busy pages
in VMCache, but, if anything, that makes a -j8 build marginally slower. I
guess busy vnodes are encountered so rarely that the additional overhead for
a more intelligent algorithm isn't really worth it. Reduced the wait time,
though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34845 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f42efbcd 01-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved the entry cache implementation into its own file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34843 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7a9b8baa 01-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Made vnode::type private, renamed it to fType, and added accessor methods. It
stores the value right-shifted by 12 bits, now, since those bits are not
relevant. This saves some bits and also resolves a TODO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34842 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3caec287 01-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Resolved TODO in free_vnode(): There was a race condition between vnode
destruction and VMVnodeCache::AcquireUnreferencedStoreRef(). Solved by
adding a flag to VMVnodeCache and letting AcquireUnreferencedStoreRef()
fail, if set.
* Added TODO regarding replacing the snooze() waiting for busy vnodes.
* get_vnode(): Unlock sVnodeMutex while calling the put_vnode() hook on
error.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34841 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e50cf876 02-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved the VM headers into subdirectory vm/.
* Renamed vm_cache.h/vm_address_space.h to VMCache.h/VMAddressSpace.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34449 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a477e3cf 01-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Finished renaming of vm_cache to VMCache.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34424 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f31ffa6b 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Use O_CLOEXEC when open directories, attribute directories, indexes, and
queries.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34291 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 486fffda 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Forgot to add linkat(), this really closes #4928 now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34289 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb2500da 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Added missing AT_EACCESS.
* Implemented renameat(), faccessat(), fchownat(), fchmodat(), and mkfifoat().
* Added stub for mknodat().
* The kernel backend for faccessat() does not yet differentiate between
effective and real user/group IDs, though.
* Removed B_ENABLE_INCOMPLETE_POSIX_AT_SUPPORT, as we now support everything
(more or less). This also closes ticket #4928.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34288 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7ce581d7 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Eliminated the extra buffer in dir_vnode_to_path(); we write directly to the
specified buffer now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34282 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 00362625 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Added support for O_NOFOLLOW.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34279 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 432bb91f 25-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* dir_vnode_to_path() now uses B_* error codes instead of POSIX ones, and also
returns the correct error code if the buffer was too small (should be ERANGE
instead of ENOBUF).
* Also, it is now independent of B_PATH_NAME_LENGTH, and therefore should
fulfill POSIX getcwd() requirements. This should also close ticket #3352.
* Is there any reason to allocate another buffer instead of using memmove()
at the end instead of memcpy()?


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34276 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1ba04177 25-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* load_image() now has exec() semantics wrt file descriptors; before each team
would always inherit them all, causing quite a number of open files.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34247 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 713cc7fc 17-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added fs_read_attr().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34085 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c3dbe626 10-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

_user_open_dir(): Allow a NULL path to be passed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33973 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f40c5e32 05-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* common_rename() now checks the name for validity before passing it on to the
file systems, so those checks don't have to be duplicated there, anymore.
* Minor cleanup, mostly automatic whitespace.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33895 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 095a7d84 18-Oct-2009 Jérôme Duval <korli@users.berlios.de>

using chroot with a mount point wrongly exposed the mount point name: we now avoid resolving the volume root in case we hit the IO context root.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33645 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a9689e84 30-Sep-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* VFS:
- Fixed vfs_get_vnode_from_fd() return type.
- Added vfs_open_vnode().
- Added a "bool traverseLeafLink" parameter to vfs_get_fs_node_from_path().
It was always resolving symlinks.
* device manager/devfs:
- devfs: get_node_for_path() no longer resolves leaf symlinks. That still
doesn't help with file disk devices, as creating partition wouldn't work
anyway.
- Pulled the module-related implementation part of BaseDevice into new class
AbstractModuleDevice and made all methods of BaseDevice virtual. Small
adjustments to devfs to be happy with the new BaseDevice interface.
- Added BaseDevice subclass FileDevice, which maps the interface to a file's
file descriptor. Still got a few TODOs, but should basically work.
- Use FileDevice for publishing file disk devices in devfs. Now those do
actually work, though there's some BFS trouble with one of the images I
tested.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33385 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a2bb3414 01-Sep-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup, no functional change.

+ alphabranch


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32890 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7435db9f 14-Aug-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* _user_read_dir(): Allocate a temporary heap buffer passed into the kernel
instead of using the user buffer. This frees the VFS and FS implementations
from handling user buffers.
* Adjusted fix_dirent() accordingly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32384 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 368fc35a 13-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Also have the uppper limit check in the assert.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32323 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 48cb56d8 13-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* We also shouldn't try to copy if the dirent is too large, obviously.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32314 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f9ba5c92 12-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Let fix_dirent() handle invalid reclen's gracefully.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32306 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a068dcb1 11-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* cdda_read_dir() could copy too many bytes into the provided buffer (worst
case was an unterminated string, though).
* fix_dirent() did not copy the trailing null-byte.
* Not yet entirely sure why, but this caused #4214.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32254 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7a6506e 06-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Replaced all "status < B_OK" with != B_OK - this should make the VFS layer
more robust against broken (userland) file systems.
* 80 character column cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32184 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 061d2ed1 30-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* Creating a symlink now fails with B_NOT_SUPPORTED instead of
B_READ_ONLY_DEVICE if it has a write hook.
* This fixes bug #4141.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32004 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ae594ff 28-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* Introduced dedicated syscalls for the deprecated BeOS fs_attr API. Before,
each attribute access needed 3 syscalls, now only one as it should.
* Renamed the new Haiku call fs_open_attr() to fs_fopen_attr(), and added a new
function fs_open_attr() that takes a path (same semantics as the
fs_[f]open_attr_dir() functions already present in BeOS).
* Merged former _kern_open_attr(), and _kern_create_attr() into one syscall.
* Cleaned up vfs.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31881 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5147963d 26-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

headers/private/kernel/util/OpenHashTable.h, Hugo's version, is a bit nicer than
Tracker's OpenHashTable.h which it should eventually replace. We've renamed the
class to BOpenHashTable and changed the interface slightly so that HashTableLink
became superfluous.
Adapted all the code that used it. Since the OpenHashTables no longer clash,
this should fix the GCC4 build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31791 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6def1a63 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* In order to resolve mount points, fix_dirents() retrieved all vnodes from
disk; but since mount points are always kept in memory, it makes much more
sense to use lookup_vnode() instead.
* As a side effect, directory listings are no longer aborted when they contain
broken files that could not be retrieved anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31775 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 874f2349 11-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Returning random stat data isn't really nice.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31010 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fa773c0a 01-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

vnode_path_to_vnode(): Don't propagate the traverseLeafLink flag, if we've
decided to recursively resolve a symlink. We only have to do the resolution
when the flag is true anyway or the symlink is not the last component of
our path, in which case we have to resolve it anyway. Fixes #3986.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30937 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ce4db6ae 16-May-2009 Axel Dörfler <axeld@pinc-software.de>

* The covered vnode release was never put when it already was a mount point
during fs_mount(). This fixes bug #3934.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30773 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 78e7cdae 16-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Removed the get_next_removed_vnode() call again - besides the problems Ingo
pointed out, there is also an unsolvable race condition with BFS that other
file systems should share.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30204 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4e98292b 15-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Introduced new call get_next_removed_vnode() to be able to iterate over
removed but not yet deleted vnodes.
* Simplified get_vnode_removed().
* Header cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30176 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3cf43c26 25-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed the fs_vnode_ops::create_dir() parameter for returning the ID of the
newly created dir. The VFS really doesn't need it and for some file systems
it might not be easy to get by. Several file systems (e.g. rootfs and fat)
were ignoring the parameter anyway.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29719 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c9bc3be3 12-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup, no functional change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29480 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aa4ba93e 08-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed src/system/kernel/device_manager/io_requests.{h,cpp} to
IORequest.{h,cpp}.
* Introduced public <io_requests.h> header. Currently it only declares the
single function BFS uses.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29446 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 43b2ca91 02-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed wrong use of MutexLocker as pointed out by Korli - nice catch! This
could have caused a number of problems.
* Fixed coding style violation Ingo introduced.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29378 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5ecc4b37 01-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced ref-counting for the I/O contexts.
* The I/O context related vfs_*() functions have io_context* instead of void*
parameters/return values, now.
* vfs_new_io_context(): Lock the parent I/O context before getting its table
size. Otherwise the table size could change until we do.
* vfs_resize_fd_table(): Fixed use of MutexLocker. We created only a temporary
object, not one with function scope.
* Renamed load_image_etc() to load_image_internal() and added a parameter for
specifying the parent team of the one to create.
* Introduced a kernel private load_image_etc() with a few more arguments than
load_image().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29375 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f6d0017d 28-Feb-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed duplicate parameter name.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29342 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2e47b62e 27-Feb-2009 Axel Dörfler <axeld@pinc-software.de>

* Consolidated '*' style.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29341 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ed3e5ec0 27-Feb-2009 Axel Dörfler <axeld@pinc-software.de>

* zero_pages() did not fill in the _bytes parameter correctly - it returned how
many unclear bytes remained instead of how many were cleared. This caused
sparse files to show garbage instead of empty space. This fixes bug #2889.
* common_file_io_vec_pages() set "size" (size_t) from file_io_vecs::length
which is off_t without taking into account that important information could
be lost.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29339 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 63448c92 23-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Better do the check for "." and ".." after stripping off superflous leafs as
otherwise a "rmdir ./" would still have caused the corruption.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29299 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 24a7f4c2 23-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Disallow removing the "." entry. We do the same for ".." already and it seems
to be in line with what other systems do as well. Also fixes bug #3476.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29296 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 77b26c32 19-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

We need a longer filesystem string here to fit in all the possible layers.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29259 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49004dc7 19-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Remove the additional fs_vnode_ops arugment from get_vnode() again as it's not
needed at all when used as intended. Thanks Ingo for the explanation on how this
is intended to work. Adjusted the overlay fs accordingly and updated/reverted
the changes to the other filesystems.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29250 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b1a58597 18-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Add a new fs_volume op all_layers_mounted() that is called when all layers have
been mounted. This is to allow layered filesystems to setup internal data that
requires all the sub/super volumes to be available.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29248 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a26c2439 14-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Adding volume ops to the overlay filesystem.
* Remove the previous method of applying the overlay by flags. In the future the
overlay can just be mounted as a filesystem layer. This is probably how layers
were intended to work in the first place.
* Move the filesystem module info and filesystem name from the fs_mount to the
fs_volume structure. Filesystem layering is done by having multiple layered
volumes and we want to be able to have a different fs per layer.
* Adapt VFS code to this move.
* Implement mounting layered filesystems. Specifying multiple filesystems
separated by a colon on mount will cause the layers to be set up and the
corresponding filesystems to be mounted at that layer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29199 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e5f1227 13-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Handle the overlay request flag in publish_vnode() as well.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 00405f22 09-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Add an additional argument to get_vnode() that gets the fs_vnode_ops of the
node. That is needed for a layered filesystem to be able to construct a full
fs_vnode out of a volume/inode pair.
* Adapt places where get_vnode is used. Sadly this is a C API and we can't just
use a default NULL for that argument.
* Introduce a flag B_VNODE_WANTS_OVERLAY_SUB_NODE that can be returned in the
flags field of a fs get_vnode call. A filesystem can use this flag to indicate
that it doesn't support the full set of fs features (attributes, write support)
and it'd like to have unsupported calls emulated by an overlay sub node.
* Add a perliminary overlay filesystem that emulates file attributes using files
on a filesystem where attributes aren't supported. It does currently only
support reading attributes/attribute directories though. All other calls are
just passed through to the super filesystem.
* Adjust places where a HAS_FS_CALL() is taken as a guarantee that the operation
is supported. For the overlay filesystem we may later return a B_UNSUPPORTED,
so make sure that in that case proper fallback options are taken.
* Make the iso9660 filesystem request overlay sub nodes. This can be fine tuned
later to only trigger where there are features on a CD that need emulation
at all.

If you happened to know the attribute file format and location you could build
an iso with read-only attribute support now. Note that this won't be enough to
get a bootable iso-only image as the query and index support is yet missing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29177 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c33667d4 01-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Fixing warnings under GCC4 in preparation to enable -Werror there as well:
* Replaced the use of offsetof() for structs that aren't PODs. Add a
offset_of_member() macro to util/khash.h because that's what it's used for
in our cases.
* Change the signature of add_debugger_command()/remove_debugger_command() on
GCC > 2 to avoid the depricated conversion from string constants to char *.
* Adding some "suggested" parenthesis. I know that not everyone likes that, but
it pointed out at least one bug that is fixed here as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29113 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f58d8cf2 11-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* _user_flock() will no longer accept invalid operations, thus fixing bug #3141.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28889 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fbb7d4cd 11-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* fs_write() is optional for read-only file systems. This fixes bug #3062 and
also #3083 (although I could not reproduce the latter).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28881 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6a90578f 06-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* Removed a left-over mutex_unlock() that could cause a panic on removing
a busy vnode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28851 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5500d8a5 06-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* All file descriptors that only refer to a mount now keep the mount, ie. they
won't call put_mount() before they are freed. Internally, this causes them
to grab a reference to the mount's root vnode.
* This fixes bug #3262.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28850 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 55ddbd7b 13-Nov-2008 Axel Dörfler <axeld@pinc-software.de>

* When a file system reports -1 offsets in its fs_get_file_map() function, this
will now accepted and regarded as sparse file data. FileMap::_Add() also
correctly joins multiple vecs with that offset together, FileMap::Translate()
will always report offset -1 even for offsets into that extent.
* read_file_io_vec_pages() (or rather, its backend common_file_io_vec_pages())
now supports sparse files, and will just clear the memory it should read from
offset -1 instead of passing a request to the vnode.
* ext2 now correctly reports sparse files. This should close bug #2889, as well
as #975.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28648 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7e621f16 05-Nov-2008 Axel Dörfler <axeld@pinc-software.de>

* Use parse_expression() for argument parsing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28515 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 67804f25 27-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* fs_unmount() removed the vnodes of the fs_mount twice since r28215,
triggering an assert.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28344 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e967b93a 26-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* vfs_stat_node_ref(): Added missing initialization of
stat::st_{dev,ino}.
* stat::st_rdev is unused, but at least initialize it with some
deterministing value. This makes Perl's lib/File/stat.t test happy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28333 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1894a0a9 20-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Consistently use KDEBUG. It is always defined and therefore must be
checked with "#if".


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28247 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3b839d85 18-Oct-2008 Michael Lotz <mmlr@mlotz.ch>

The fs_mount structure now has a constructor/destructor and is used with new and
delete. Therefore the constructor/destructor of the contained EntryCache is also
called. The manual call of the destructor to the OpenHashTable inside the
EntryCache was therefore superflous and the destructor would be called twice,
leading to bug #2869.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28232 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 703aecaa 17-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Instead of having the mount_link, struct vnode now subclasses from
DoublyLinkedListLinkImpl, and fs_mount now uses a DoublyLinkedList instead
of a typeless struct list.
* Also added a constructor/destructor to fs_mount which simplifies and cleans
some code.
* This should not contain any functional changes :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28215 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 552c8edc 17-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* fs_sync() now holds the sVnodeMutex while iterating over the mount list.
* This has the advantage that we no longer need to call get_vnode(), and
instead can use lookup_vnode().
* This means at least most of the "corrupted BFS inode" messages should be
gone; they were produced when fs_sync() tried to get already deleted vnodes.
This was actually harmless, but doesn't really help in trusting your system :-)
* Also, it no longer tries to write back removed vnodes.
* And finally, it now uses a marker vnode when iterating over the list, so
that it doesn't need to break out of the loop anymore, and can always sync
all willing vnodes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28212 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e8d3eff9 26-Sep-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* vfs_normalize_path() and _user_normalize_path() use a common helper
function (normalize_path()), now. There was some code duplication
before.
* Added "bool traverseLink" parameter to vfs_normalize_path(). When
true and the leaf component is a symlink, it will be resolved.
* KPath:
- Added similar leaf link traversal parameter to SetTo() and
SetPath().
- Added Normalize().
- Added DetachBuffer(), which returns the object's current buffer and
unsets itself.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27751 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ee1a1571 07-Sep-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Implemented a simple directory entry cache to speed up path resolution.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27366 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2aa5367a 24-Aug-2008 Jérôme Duval <korli@users.berlios.de>

extended debug check for FS_CALL() to others FS_CALL() versions


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27189 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8cf7754b 24-Aug-2008 Jérôme Duval <korli@users.berlios.de>

added a check in FS_CALL() for null hooks in KDEBUG mode


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27188 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2fd4fdcf 22-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Changed the way fix_dirent() copies the entry: it will now copy the complete
dirent without the name first, and will then check if the d_reclen member
is valid before copying the name.
* This shows the problem with the FAT file system that was revealed by r26859.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27128 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a3afb5ee 09-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Handy on-demand debug tracing, I've used a few times already. So I leave
it commented out in the code for the time being.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26907 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49a7b619 07-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* fix_dirent() now correctly handles buffers from userland.
* dir_read() now takes into account that we may have read more than one dir
entry, and calls fix_dirent() for each of them.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26859 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 58306fec 02-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added tracing for vfs_{read,write}_pages).
* {read,write}_pages() use vfs_{read,write}_pages() now, instead of
invoking the FS {read,write}_pages() hooks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26750 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 15374c5d 02-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Renamed thread_spinlock and team_spinlock to gThreadSpinlock and
gTeamSpinlock.
* Renamed the static global variables in smp.c to match our style guide.
* Minor other cleanup.
* Removed superfluous white space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26730 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9f6ae76f 01-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Added acquire_vnode() call that you can use to get another reference to an
inode - unlike get_vnode() the busy flag won't prevent you from getting that
reference.
* Changed put_vnode() to return an error in case the vnode couldn't be found.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26713 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7f12cc54 30-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* It is now supported that I/O operations and requests are only handled
partially (e.g. due to hitting the end of file). The respective
classes have grown new methods and attributes to deal with that. The
"finished" callbacks have got additional parameters to indicate
whether the transfer was only partial and how much has been
transferred. Other callbacks and functions have a size_t* in/out
parameter instead of a simple size_t, now.
* vfs_{read,write}_pages() do now use the I/O request framework instead
of the underlying FS's {read,write}_pages() hooks (those should be
unused now). Furthermore they've got an additional "flags" parameter,
which is passed to IORequest::Init(), i.e. it allows to specify that
the given vecs refer to physical addresses.
* The file cache's read_into_cache() reads directly into physical
pages, now.
* Fixed bug in DoIO::IO(): The offset was not adjusted, so that all
pages were incorrectly transferred from/to the same location.
* Fixed broken subrequest scheduling loop head in
do_iterative_fd_io_iterate().
* Adjusted the test driver and implemented its io() hook. Using this
driver I/O requests are passed all the way from the VFS/VM to the
driver and through the I/O scheduler. It even seems to work. :-)
* Added missing const to the iovec* parameter of the IORequest::Init()
methods.
* Disabled some debug output by default. Added new optional debug
output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26692 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7df40c23 28-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added handy function volume_for_vnode() which returns the fs_volume for
a given given fs_vnode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26669 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ec598fe4 27-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added FS interface hooks io() and cancel_io(). The former is supposed
to provide asynchrounous (or only synchronous, if asynchronous is not
supported) I/O request support. It will eventually replace
{read,write}_pages(). None of the FS implementations implement them
yet.
* Implemented some support functions for request-based I/O. File system
implementations can use do_fd_io() which passes an I/O request to the
layer responsible for a given FD, and do_iterative_fd_io(), which
translates a request for a file to subrequests for the underlying
device and passes them on. Both fall back to synchrounous processing
when the io() hook is not supported.
Furthermore added vfs_synchronous_io() which should be handy for the
devfs to perform io_requests synchronously for devices that don't
support the io() hook.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26655 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ef7fb431 23-Jul-2008 Rene Gollent <anevilyak@gmail.com>

Remove extraneous put_vnode(). This would result in decrementing the vnode ref count even if an unmount operation failed, which in turn would cause other fun problems. This fixes tickets 1982 and 2538. However, there seems to be another problem remaining with unmounting: the placeholder dir in the rootfs is not removed when the volume is unmounted, or it's not reused correctly. As a consequence, on subsequent remounts of the same volume via Tracker or mountvolume, a new dir is created each time, leaving empty placeholders. (i.e. remounting the volume HaikuData results in the creation of /HaikuData1, 2, 3, 4, etc.).



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26586 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e6bd90c5 23-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* bfs_fsync() was the only place which could cause the
fs_vnode_ops::write_pages() to be called with fsReenter = true. Since
this is no longer the case, the argument has become superfluous. For
read_pages() it always was. Removed the argument from the functions
and all functions that propagated it.
* Some whitespace at the end of lines was removed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26579 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5c99d639 22-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged branch haiku/branches/developer/bonefish/vm into trunk. This
introduces the following relevant changes:
* VMCache:
- Renamed vm_cache to VMCache, merged it with vm_store and made it a
C++ class with virtual methods (replacing the store operations).
Turned the different store implementations into subclasses.
- Introduced MergeStore() callback, changed semantics of Commit().
- Changed locking and referencing semantics. A reference can only be
acquired/released with the cache locked. An unreferenced cache is
deleted and a mergeable cache merged when it is unlocked. This
removes the "busy" state of a cache and simplifies the page fault
code.
* Added VMAnonymousCache, which will implement swap support (work by
Zhao Shuai). It is not integrated and used yet, though.
* Enabled the mutex/recursive lock holder asserts.
* Fixed DoublyLinkedList::Swap().
* Generalized the low memory handler to a low resource handler. And made
semaphores and reserved memory handled resources. Made
vm_try_resource_memory() optionally wait (with timeout), and used that
feature to reserve memory for areas.
...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26572 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 541959e0 17-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

Add (not really necessary) locking of the sMountMutex in case of KDEBUG to keep the assert in find_mount() happy.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26484 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 60f2ef17 12-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added "partition_id partition" field to fs_volume, so that file
systems can get the partition they reside on easily.
* Updated TODO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26401 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 92c3ae2b 06-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Reverted r26293 again, as that "subtle" change also prevented any device I/O
from happening...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26294 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bed8516a 06-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* file_{read|write}() now only accept regular files, and will return either
B_BAD_VALUE or B_IS_A_DIRECTORY depending on the vnode type.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26293 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 469c26e7 06-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Since we now have a vnode::type field, several calls of read_stat() were no
longer necessary.
* Optimized file_seek() using this field, too; reading the stat is now only done
when necessary.
* file_read() and file_write() will now return B_IS_A_DIRECTORY so that not
every file system has to care about that particular error code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26292 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52ecda6e 06-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Added some optional KDL command and statistics to the file map implementation.
* Turned them on for now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26291 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a8f9741c 04-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

* Removed -Wno-unused from all KernelMergeObjects in kernel Jamfiles.
* Fixed most of the warnings resulting from that by removing actually not used
variables or moving declaration into the #IF. Left unused functions there
though, as I wouldn't know if they are supposed to be used again.
* Fixed two statements with no effect (clamping to MAX_ANCILLARY_DATA_LEN in
socket.cpp and unsetting fCounterSem in MessagingService.cpp).
* Some style cleanups.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26253 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e1b630c5 28-Jun-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced the global cache pages hash table by an IteratableSplayTree
per cache.
* Changed the strategy vm_cache_acquire_page_cache_ref() uses to ensure
that the cache isn't deleted while trying to get a reference. Instead
of the global cache pages hash table lock, it holds the global cache
list lock now. We acquire + release this lock in delete_cache() after
removing all pages and just before deleting the object.
* Some small optimizations using the property that the cache's pages are
ordered, now (vm_cache_resize(), vm_page_write_modified_page_range(),
vm_page_schedule_write_page_range()).
* Replaced some code counting a cache's pages by simply using
vm_cache::page_count.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26160 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 285b754f 24-Jun-2008 Axel Dörfler <axeld@pinc-software.de>

* dec_vnode_ref_count() can now also directly free the vnode if requested
(and if it isn't used anymore).
* vnode_low_memory_handler() now just calls it this way, so it doesn't have
to use two passes anymore, and can always write back vnodes without having
the busy flag set.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26124 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f5b3a6a7 05-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

* Initialize all static mutexes in the kernel through a MUTEX_INITIALIZER()
and remove the then unneeded mutex_init() for them.
* Remove the workaround for allowing uninitialized mutexes on kernel startup.
As they are all initialized statically through the MUTEX_INITIALIZER() now
this is not needed anymore.
* An uninitialized mutex will now cause a panic when used to find possibly
remaining cases.
* Remove now unnecessary driver_settings_init_post_sem() function.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25812 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 032f1e5f 01-Jun-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed an endless loop when using vfs_get_vnode_name() or the "wrong"
get_vnode_name() variant.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25750 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3cec3084 30-May-2008 Michael Lotz <mmlr@mlotz.ch>

Fix build with TRACE_VFS enabled and also fix a warning.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25726 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b0f5179a 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed recursive_lock to use a mutex instead of a semaphore.
* Adjusted code using recursive locks respectively. The initialization
cannot fail anymore, and it is possible to use recursive locks in the
early boot process (even uninitialized, if in BSS), which simplifies
things a little.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25687 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1e18692e 26-May-2008 Axel Dörfler <axeld@pinc-software.de>

* get_vnode() now accepts a NULL parameter for the fsNode argument.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25660 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c44fb2a6 09-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Advisory locking fixes:
* Made the access strategy to vnode::advisory_locking consistent.
get_advisory_locking() was guarding it with sVnodeMutex,
create_advisory_locking() was using atomic_pointer_test_and_set(), and
release_advisory_lock() just set it unguardedly. We do use sVnodeMutex
consequently, now.
* Beautified create_advisory_locking() (got rid of the gotos,
reorganized the control flow).
* Fixed race conditions in acquire_advisory_lock(). It was always
unlocking and relocking the advisory_locking object when it didn't
have to wait, but in the meantime someone else could have changed the
locking situation. Reorganized the control flow, so that it only drops
the lock when it has to fail or wait. Using create_advisory_locking()
upfront simplifies the code quite a bit (and fixes another race
condition).

APR's testprocmutex test seems happy now, at least.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25407 a95241bf-73f2-0310-859d-f6bbb57e9c96


# adf376c9 08-May-2008 Axel Dörfler <axeld@pinc-software.de>

Replaced benaphores with mutexes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25378 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0c615a01 01-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed old mutex implementation and renamed cutex to mutex.
* Trivial adjustments of code using mutexes. Mostly removing the
mutex_init() return value check.
* Added mutex_lock_threads_locked(), which is called with the threads
spinlock being held. The spinlock is released while waiting, of
course. This function is useful in cases where the existence of the
mutex object is ensured by holding the threads spinlock.
* Changed the two instances in the VFS code where an IO context of
another team needs to be locked to use mutex_lock_threads_locked().
Before it required a semaphore-based mutex implementation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25283 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 503912f7 30-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed the case that a file to be created non-exclusively is a symlink
(bug #2183).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25271 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 24280972 29-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed superfluous uint32 ref parameter from select() FS hook.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25268 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b1d749f8 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Added an atomic.h header that provides a C++ file with a templatized
64-bit safe version of atomic_test_and_set() for pointers:
atomic_pointer_test_and_set().
* The VFS is now using this function (it's not used anywhere else in the
kernel this way).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25260 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bbc25eb6 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Renamed temporary KDL variable from _cookie to _volume in the "mount"
command.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25251 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f8a2f7ce 25-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* attribute dirs shouldn't be locked out either; I've inverted the type check,
so that it now only checks for the type that allow locking.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25168 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d81dcabe 25-Apr-2008 Bruno G. Albuquerque <bga@bug-br.org.br>

FS gurus, please review.

- get_new_fd() now checks if we are dealing with attributes before deciding to
bail out on a locked vnode.
- Enabled locking in MailSettings again as it now works.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25162 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0951fcb4 24-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

vfs_create_special_node() always tried to create the node in "/".


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25139 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3118b3a7 11-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added fd_ops::set_flags() hook. It's only implemented by socket FDs
ATM.
* Changed common_fcntl() to also work for non-vnode-based FDs. Only the
operations that require a vnode do fail now. F_SETFL uses the new
fd_ops::set_flags() if available, falling back to the vnode respective
operation.
* Changed some direct accesses to file_descriptor::u::vnode. It was safe
in those cases, but might not be anymore if we ever change fd_vnode().

ftp can at least connect to servers again, now, but apparently we still
have a problem with syscall restarts -- downloads fail after one second,
when the timer goes off.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24917 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ac0e5c1c 11-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

The fs_sync() function (or any other, for that matter) must not hold the
sMountMutex lock when calling sync() on a file system. This fixes a potential
deadlock (I just encountered for the first time).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24915 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9493edbe 11-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

Applied patch by Christian Fasshauer:
* get_dir_path_and_leaf() now removes trailing slashes from the path.
* This fixes bug #2016, thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24913 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0fc6c437 10-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Resolved TODO: We can check for sockets, now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24906 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f8b4d83f 09-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

New service function vfs_create_special_node() to create special nodes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24883 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 037f7094 09-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Cleaned up KernelExport.h completely, removed deprecated and non implemented
API, uses the _PRINTFLIKE macro where appropriate.
* Got rid of the "qent" structure, struct timer now contains everything we
need. This makes the affected code in sem.cpp, signal.cpp, and timer.c much
cleaner, and resolves a few TODOs.
* Minor cleanup in vfs.cpp.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24871 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fc380199 06-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Rename vfs_stat_entry_ref() to vfs_stat_node_ref() as that's what a dev_t and
ino_t combination really is.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24825 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e36a49e 05-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added _kern_create_pipe() syscall, creating a pipe as an entryless
FIFO. Reimplemented pipe() to use it.
* pipefs is no longer mounted. Will remove the superfluous code soon.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24823 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 717705d8 05-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

We get a reference to the node from create_special_node(), so we have to
release it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24817 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7ffafac8 05-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reorganized the FS interface a little:
- Moved most file_system_module_info hooks into separate structures.
Those that operate on mounted volumes to fs_volume_ops, those
operating on a vnode to fs_vnode_ops.
- Got rid of the fs_volume, fs_cookie, fs_vnode typedefs. We use void*
again.
- Instead of a void* volume and node cookie hooks are passed a
fs_volume and fs_vnode structure pointer, which contain the cookie
and an ops pointer (fs_volume a few more things).
- The VFS {new,publish,get,...}_vnode() functions take a fs_volume*
instead of the volume ID. So does vfs_get_fs_node_from_path().
- Added type and flags arguments to publish_vnode() and the
get_vnode() hook and removed the type argument from lookup() hook.
Added vnode::type using formerly unused bits to store the node type.
Simplified a few things in the VFS due to the now always available
node type.
- Added fs_volume_ops::{create,delete}_sub_vnode() and
fs_vnode_ops::get_super_vnode() hooks. They are used to support file
system layers, e.g. allowing to extend an FS not supporting BeOS
attribute with attribute support. Needs some more work in the VFS.
- Added fs_vnode_ops::create_special_node() hook for creating special
nodes (e.g. FIFOs).
* Adjusted the built-in file systems and BFS according to the interface
changes. Removed all other FSs from the image for the time being.
We'll see whether further API changes are necessary before porting
them.
* Adjusted the bfs_shell accordingly.
* Implemented create_special_node() in rootfs to support special nodes.
* Added support for FIFOs:
- Added syscall _kern_create_fifo() (used by mkfifo()), which creates
a special node (type S_IFIFO) in the respective file system.
- When a special node is published the VFS creates a respective sub
node. Currently only FIFOs are supported.
- Added a little support for FIFO subnodes by using functionality from
the pipefs.
- Added mkfifo to the image. It can create FIFOs in the rootfs, but
the FIFOs aren't really usable ATM, since they still work like
pipes, i.e. readers and writers need to have them open at the same
time.
* Some smaller changes in the VFS:
- Made the *_CALL macros nicer to use (vargs).
- Refactored FS entry lookup into new function lookup_dir_entry().
- create_vnode() no longer just calls the FS create() hook. First it
looks up the entry and uses open_vnode(), if it already exists. This
is necessary for two reasons: 1) The FS might not support create()
while still allowing to open() entries. 2) When the FS has other
layers on to of it (or the respective node) it might not be
responsible for opening the node.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24816 a95241bf-73f2-0310-859d-f6bbb57e9c96


# efb965d5 05-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Introduce vfs_stat_entry_ref() that allows to stat a vnode based on a dev_t
and ino_t instead of a path. Supposed to work with node monitoring messages.
Took the name from vfs_entry_ref_to_path() that takes the same arguments, but
suggestions for a better name are welcome.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24813 a95241bf-73f2-0310-859d-f6bbb57e9c96


# de731008 01-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Also check whether the supplied vnode is a directory, if there's only
one path component.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24736 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0cc0b6fc 01-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed resolution of symlinks path components, broken since
r24721/r24722. After resolving a symlink we weren't updating the local
type variable to the type of the link target, so that the directory
check in the next iteration would always fail.
* Added TODO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24735 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b987779d 01-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

Revised my previous patch as outlined in the previous one:
* No longer checks for the path delimiter twice.
* Now also checks if the first part of the path is a directory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24722 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6800e4f8 01-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

Reverted r24720, and at least fixed the problematic return code after the
first loop - the vnode passed in would still need to be checked, though.
Eventually, it would be nice to move the check to the top, though, so that
we don't need to search for the patch delimiter twice.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24721 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b48c7f23 01-Apr-2008 Bruno G. Albuquerque <bga@bug-br.org.br>

- vnode_path_to_vnode() now returns B_NOT_A_DIRECTORY instead of B_NOT_ALLOWED
as expected by POSIX programs. This allowed be to compile Haiku under itself
without any hacks at all, so I guess this means that now we are officially
self-hosting!



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24720 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 360be1fc 29-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Implemented support for chroot:
- Added a "root" vnode to the io_context. It is used for resolving
paths and converting nodes to paths instead of sRoot. Some more
passing around of io_context structures was necessary.
- Introduced a new lock sIOContextRootLock to protect
io_context::root. The current uses of io_context::io_mutex
(put_vnode(), remove_vnode() while holding it) looked too suspicious
to use that mutex in vnode_path_to_vnode().
- Added _kern_change_root() syscall and chroot() libroot function.
- Added chroot coreutils program to the image. Funnily it seems to be
much easier to set up a little jail than under Linux (just copy
bash and libroot.so into respective subdirs; mount another pipefs
if you want pipe support).
With Haiku allowing direct access to directories via inode IDs
jailing is obviously not very secure at the moment.
- Added /var/empty to the image. It will be the chroot target for ssh.
* Changed vfs.cpp:get_cwd() so that the io_context::io_mutex is no
longer held when calling dir_vnode_to_path().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24673 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c117a6d 29-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added function vfs_read_stat() that also allows for stat()ing files in
the user IO context from within the kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24667 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9e79133f 27-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Reverted r22315 as far as free_vnode() is concerned: removing the
vnode from the hash before putting it caused all sorts of problems.
* For example, BFS would trim its preallocations when the vnode is put;
if someone would read that same vnode after it had been removed, but
before BFS could trim it, it would read the old vnode which still
seemed to own the blocks which would subsequently be freed.
* This fixes bug #1914, and should also fix bug #1956.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24607 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e9d948ce 18-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* entry_ref_to_vnode() now gets a "traverse" argument, so that it is
able to resolve symlinks.
* file_open_entry_ref() now evaluates the openMode and passes the
correct "traverse" argument to entry_ref_to_vnode(). This fixes bug
#1932 (symlink refs wouldn't be resolved).
* dir_open_entry_ref() now always resolves symlinks, all other uses of
entry_ref_to_vnode() keep their previous behaviour, though.
* Fixed warnings; since Ingo's header changes, NULL now causes a warning
when it is used as int.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24442 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1b32947d 17-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Aligned the semantics of the read_symlink() FS module hook with the
readlink() function. It is no longer required to null-terminate the
string, shall not fail, if the buffer is too small, and shall return
the length of the string actually written into the buffer.
* Adjusted rootfs, devfs, and bfs accordingly. Also adjusted their
read_stat() hooks to return the correct symlink length in st_size.
* Our readlink() does now comply to the standard (and BeOS).
Additionally if the buffer is big enough it is nice to non-conforming
apps and null-terminates it.
* BSymLink::ReadLink() explicitly null-terminates the string now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24425 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f542307a 09-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

We didn't copy the close-on-exec flags on fork(), thus always leaving
all FDs in a fork()+exec()ed child open. Makes Perl test
t/run/cloexec.t pass.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24336 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3f89bce4 09-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* The module code now uses find_directory() and no hard-coded paths anymore.
* It now also supports the common directory path.
* search_module() checked the module paths in the wrong order, ie. it preferred
modules in the system directory over the user directory.
* Clarified comment in vfs_get_module_path().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24323 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fa28330b 09-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Explained under which circumstances vnode_path_to_vnode() will clobber the
buffer of the provided "path" argument.
* Applied patch by Vasilis to fix some warnings when build on Linux (missing
const on certain functions). We should probably fix the original
{add|remove}_debugger_command() functions in Haiku as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24322 a95241bf-73f2-0310-859d-f6bbb57e9c96


# daa6f66e 04-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24236 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0c415f62 27-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

"leaf" may be NULL, fixed crashing bug I introduced with
vfs_entry_ref_to_path().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24154 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4f26630d 27-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Factored a vfs_entry_ref_to_path() out of _user_entry_ref_to_path()
and made it public (within the kernel).
* _user_entry_ref_to_path() is now using that function.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24151 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 849246ba 19-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

Improved (and tested) the advisory file locking mechanism a bit:
* our flock::l_len was inclusive, while it's exclusive (the last byte locked
is (l_start - 1 + l_len) not just (l_start + l_len).
* F_UNLCK removes all locks of the calling process that are within the specified
region - existing locks might also cut or divided.
* Apparently, a single team can lock the same region as often as it wants.
* advisory_locking is now using a DoublyLinkedList instead of its C counterpart.
* advisory_lock now has start + end fields, instead of offset + len, it's
handier this way.
* This fixes bug #1791.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24020 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4048494c 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
* Implemented automatic syscall restarts:
- A syscall can indicate that it has been interrupted and can be
restarted by setting a respective bit in thread::flags. It can
store parameters it wants to be preserved for the restart in
thread::syscall_restart::parameters. Another thread::flags bit
indicates whether it has been restarted.
- handle_signals() clears the restart flag, if the handled signal
has a handler function installed and SA_RESTART is not set. Another
thread flag (THREAD_FLAGS_DONT_RESTART_SYSCALL) can prevent syscalls
from being restarted, even if they could be (not used yet, but we
might want to use it in resume_thread(), so that we stay
behaviorally compatible with BeOS).
- The architecture specific syscall handler restarts the syscall, if
the restart flag is set. Implemented for x86 only.
- Added some support functions in the private <syscall_restart.h> to
simplify the syscall restart code in the syscalls.
- Adjusted all syscalls that can potentially be restarted accordingly.
- _user_ioctl() sets new thread flag THREAD_FLAGS_IOCTL_SYSCALL while
calling the underlying FS's/driver's hook, so that syscall restarts
can also be supported there.
* thread_at_kernel_exit() invokes handle_signals() in a loop now, as
long as the latter indicates that the thread shall be suspended, so
that after waking up signals received in the meantime will be handled
before the thread returns to userland. Adjusted handle_signals()
accordingly -- when encountering a suspending signal we don't check
for further signals.
* Fixed sigsuspend(): Suspending the thread and rescheduling doesn't
result in the correct behavior. Instead we employ a temporary
condition variable and interruptably wait on it. The POSIX test
suite test passes, now.
* Made the switch_sem[_etc]() behavior on interruption consistent.
Depending on when the signal arrived (before the call or when already
waiting) the first semaphore would or wouldn't be released. Now we
consistently release it.
* Refactored _user_{read,write}[v]() syscalls. Use a common function for
either pair. The iovec version doesn't fail anymore, if anything could
be read/written at all. It also checks whether a complete vector
could be read/written, so that we won't skip data, if the underlying
FS/driver couldn't read/write more ATM.
* Some refactoring in the x86 syscall handler: The int 99 and sysenter
handlers use a common subroutine to avoid code duplication.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23983 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4af88776 17-Feb-2008 Marcus Overhagen <marcusoverhagen@gmail.com>

build fix for r23929


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23982 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9ae93dcd 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

_user_normalize_path() was broken for symlinks in absolute paths.
Fixes #1778.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23969 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2c986936 07-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added new syscall _kern_normalize_path() to normalize a path.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a32a4683 03-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Implemented flock() semantics to the advisory locking backend. Not tested
(must also compare to BSD; I've looked at their sources, but I might have
missed something).
* Added sys/file.h and the flock() system call.
* common_fcntl() could forget to put back the file descriptor on some error
conditions (I guess we should introduce and use a DescriptorGetter class).
* Cleaned up fcntl.h, moved the BSD extensions S_IREAD and S_IWRITE to
sys/stat.h where they belong, and added the missing S_IEXEC to them.
* Added some more comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23836 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 731262c6 21-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Rethought fs_sync(): since we no longer deadlock when calling
vm_cache_write_modified() here anymore since quite some time, it actually
doesn't make any sense to call the file system's "fsync" method here.
This should make syncing all file systems much faster when many vnodes are
in use.
* If a file system doesn't use the file cache, it can still just sync everything
it needs to in its "sync" method.
* Added a TODO item on how to improve sync speed further, if necessary.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23679 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b9074efc 16-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed the "vnodes" KDL command when called without any arguments.
* Fixed the usage text of the "help" KDL command.
* Made the "ambiguous command" warning shorter, so that it will still fit in
the exception buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23565 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dd80f32a 16-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Added support for the "--help" argument for all VFS debugger commands.
* Added some temporary variables to the commands.
* Use parse_expression() where appropriate.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23556 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2eceeaba 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Fix comment.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23466 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0fc976d9 12-Jan-2008 Ithamar R. Adema <ithamar.adema@team-embedded.nl>

Fix problem with CLOEXEC also being handled on fork(). For details on expected (BeOS) behaviour, see http://www.freelists.org/archives/openbeos/12-2001/msg00280.html

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23456 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f3ecf93d 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Added the cookie/private_node fields to the mounts/vnodes list in KDL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23455 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a52c1759 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Fixed two bugs in the vnode disconnecting code found by bonefish+mmlr:
* vfs_disconnect_vnode() did not put away its vnode reference.
* disconnect_mount_or_vnode_fds() did always throw the current working
directory of all apps on the same mount away, even if only a specific
vnode should have been disconnected.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23445 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 34b3b26b 10-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged branch haiku/branches/developer/bonefish/optimization revision
23139 into trunk, with roughly the following changes (for details svn
log the branch):
* The int 99 syscall handler is now fully in assembly.
* Added a sysenter/sysexit handler and use it on Pentiums that support
it (via commpage).
* Got rid of i386_handle_trap(). A bit of functionality was moved into
the assembly handler which now uses a jump table to call C functions
handling the respective interrupt.
* Some optimizations to get user debugger support code out of the
interrupt handling path.
* Introduced a thread::flags fields which allows to skip handling of
rare events (signals, user debug enabling/disabling) on the
common interrupt handling path.
* Got rid of the explicit iframe stack. The iframes can still be
retrieved by iterating through the stack frames.
* Made the commpage an architecture independent feature. It's used for
the real time data stuff (instead of creating a separate area).
* The x86 CPU modules can now provide processor optimized versions for
common functions (currently memcpy() only). They are used in the
kernel and are provided to the userland via commpage entries.
* Introduced build system feature allowing easy use of C structure
member offsets in assembly code.

Changes after merging:
* Fixed merge conflict in src/system/kernel/arch/x86/arch_debug.cpp
(caused by refactoring and introduction of "call" debugger command).



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23370 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4accd841 06-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a big bug in common_file_io_vec_pages(): vecOffset was not correctly
set when the first chunk of the file could be read in directly, causing it
to read data to a wrong place in the buffer.
* Reading in the first chunk directly would have also only worked if vecIndex
and vecOffset was 0 when calling the function.
* Applied the fs_shell changes in file_map to the kernel version as well (the
constructor already worked correctly, though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23265 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb431b44 13-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* vfs_unmount() can now safely be called from the kernel (fs_unmount() still
tried to access the uninitialized vnode in that case).
* That means that it's now safe to remove a mounted CD from the drive, it
will then be unmounted automatically.
* Added a check for partition::Device() - even though Ingo tells me it's
impossible, it was NULL once.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22922 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e122bd9 12-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish: Missed those changes in the previous commit:
* Added vfs_unmount(), which allows unmounting by dev_t (used by the DDM).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22910 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3d268eda 10-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* Extracted file_map API out of the file cache - it's now an optional service
that can be used by file systems.
* Changed the way the file cache works: instead of reading/writing to the
underlying device directly, it can now be used for any data source, ie.
also network file systems.
* As a result, the former pages_io() moved to the VFS layer, and can now be
called by a file system via {read|write}_file_io_vec_pages() (naming
suggestions are always welcomed :-)). It now gets an FD, and uses that to
communicate with the device (via its fs_{read|write}_pages() hooks).
* The file_cache_{read|write}() functions must now be called without holding
an I/O relevant file system lock. That allows the file cache to prepare the
pages without colliding with the page writer, IOW the "mayBlock" flag can
go into the attic again (yay!).
* This also results in a much better performance when the system does I/O and
is low on memory, as the page writer can now finally write back some pages,
and that even without maxing out the CPU :)
* The API changes put slightly more burden on the fs_{read|write}_pages()
hooks, but in combination with the file_map it's still pretty straight
forward. It just will have to dispatch the call to the underlying device
directly, usually it will just call its fs_{read|write}_pages() hooks
via the above mentioned calls.
* Ported BFS and FAT to the new API, the latter has not been tested, though.
* Also ported the API changes to the fs_shell. I also completely removed its
file cache level page handling - the downside is that device access is no
longer cached (ie. depends on the host OS now), the upside is that the code
is greatly simplified.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22886 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 53715fe0 01-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Got rid of the B_PARTITION_DESCENDANT_BUSY flag.
* Added CheckAndMarkBusy() and UnmarkBusy() methods to KPartition.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22801 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8354dac7 01-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Folded KPhysicalPartition into KPartition. Removed the notion of shadow
partitions from the disk device manager.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22800 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 32788795 01-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved partition scanning back to KDiskDeviceManager. ATM only
synchronous scanning is supported.
* Removed the disk device job support from the disk device manager.
* K{Disk,File,Partitioning}System:
- Remove querying and validation methods.
- Commented out the modification methods until their fate is decided.
* Removed obsolete _user_get_partitionable_spaces().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22799 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 45ae0aa1 23-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

It's not a good idea to write back large files while keeping the vnode busy.
The low memory handler now has two passes which should help there; however, it
might also accidently remove recently used vnodes, too. We could mark the clean
ones in some way if that turns out to be a problem.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22678 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0710d59c 08-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* Added a "canWait" argument to vfs_get_vnode() - you can use this to ignore
busy vnodes.
* dir_create_entry_ref() used get_vnode() incorrectly (and could therefore
potentially prevent a file system from doing proper locking when called
from the kernel).
* The vnode_store now uses this for its acquire_unreferenced_ref()
implementation (and therefore for the page writer).
* read_into_cache() and write_to_cache() were still marked inline.
* The system will now wait 10 secs for a busy vnode before returning an error.
* It will also no longer panic in that case.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22485 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0b7582a3 07-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Some types of files cannot be seeked and we need to fail in those cases.
We actually need to fail for sockets, too, but until I'm mistaken, we
can't identify them in the VFS. Fixes bug #1539.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22480 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 80f54692 06-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* struct vnode is an opaque type now, removed void* where it was used incorrectly.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22461 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 57026319 05-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reviewed checking of empty paths and fixed some occurrences. Thanks to
mjw for the hint. Fixes bug #1516.
* Changed _{kern,user}_create_symlink() to no longer check the supplied
link string. BeOS seems to do that, but this is not standard
conforming. The previous implementation even used the path processed
by check_path(), which would potentially have appended a ".".
* Some style cleanup.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22451 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3e9513aa 03-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* fs_{write|read}_pages() now has an additional argument "mayBlock".
* the page writer don't allow to block, while all other writers do. This fixes
bug #1509. The reason the page writer needs this is because it marks several
pages from different caches as busy.
* Fixed a warning about ASSERT being defined already in BFS, since
util/DoublyLinkedList.h now includes debug.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22434 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 636bfc08 02-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed fs/vfs_select.cpp to wait_for_objects.cpp and got rid of
vfs_select.h, respectively moved most of it into the new kernel
private header wait_for_objects.h.
* Added new experimental API functions wait_for_objects[_etc](). They
work pretty much like poll(), but also for semaphores, ports, and
threads.
* Removed the "ref" parameter from notify_select_events() and the
select_sync_pool functions as well as from fd_ops::fd_[de]select(). It
is no longer needed. The FS interface select() hook still has it,
though -- the VFS will always pass 0.
* de]select_fd() take a select_info* instead of a select_sync* + ref
pair, now. Added respective functions for semaphores, ports, and
threads.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22416 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 66c03dc3 30-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* fd.c -> fd.cpp
* Reworked the select support:
- The io_context additionally stores a table of lists of select_infos,
which enables it to deselect events of a pending select() when
closing a FD. This prevents a race condition potentially causing a
write to stale memory.
- The opaque selectsync* passed to FSs is now actually a select_info*.
This was necessary, since the FDs deselect() hook (unlike the
select() hook) doesn't take a "ref" argument and deselecting a
single info (e.g. caused by a premature close()) was not possible.
The select() hook's "ref" argument has become superfluous.
- It should now be relatively easy to implement a poll_on_steroids()
that can also wait for objects other than FDs (e.g. semaphores,
ports, threads etc.).
* Set/reset the signal mask in common_select(). This makes pselect()
work as required.
* Reorganized vfs_resize_fd_table().



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22391 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3392e9bc 29-Sep-2007 Axel Dörfler <axeld@pinc-software.de>

* Added some more debug output.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22375 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6d4aea47 25-Sep-2007 Axel Dörfler <axeld@pinc-software.de>

bonefish+axeld:
* Removed the vm_cache/vm_store ref_count duality that besides being a bit ugly
also created the page dameon cache retrieval problem: now, only areas (and
cache consumers) retrieve a reference to the store (and therefore, the vnode).
The page daemon doesn't need to care about this at all anymore, and the pseudo
references of the vm_cache could be removed again.
* Rearranged deletion of vnodes such that its ID can be reused directly after
fs_remove_vnode() has been called.
* vm_page_allocate_page() no longer panics when it runs out of pages, but just
waits for new pages to become available using the new sFreeCondition condition
variable - to make sure this happens in an acceptable time frame, it'll
trigger a run of the low memory handlers.
* Implemented a page_thief() that steals inactive pages from caches and puts
them into the free queue. It runs as a low memory handler.
* The file cache now sets the usage count on the pages it inserts into the
cache (needs some rework though, cache_io() doesn't do it yet).
* Instead of panicking, the kernel will currently dead lock in low memory
situations, since BFS does a bit too much in bfs_release_vnode().
* Some minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22315 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8687956a 09-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added a clarifying comment to free_vnode() and prevented the vnode
reference count to drop below 0 there.
* Added TODO describing a serious race condition between free_vnode()
and the page daemon.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22209 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 62454aae 08-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed get_mount(). It must also acquire the vnode lock before trying to
increment the root node vnode reference count. Otherwise it could race
with fs_unmount(). Fixes bug #1438.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22203 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 43ab7500 08-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Some cleanup. Fixed gcc 4 warning.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22202 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d1dc70fa 05-Aug-2007 Marcus Overhagen <marcusoverhagen@gmail.com>

FD_CLOEXEC is a flag, other bits may be set


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21829 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 58f6e8e5 17-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

* Merged vm_cache_ref and vm_cache to a single structure (Axel & Ingo).
* Renamed vm_cache.c to vm_cache.cpp


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21642 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bd187793 14-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

remove_vnode() will now return an error code if the vnode to be removed did not exist.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21614 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 25f46ea4 30-Jun-2007 Axel Dörfler <axeld@pinc-software.de>

* Reserving areas never put down their reference of their address space when
removed in several cases.
* vfs_get_vnode_cache() now always gives out a reference to the cache it
returns; if it needs to allocate a new one, the vnode owns one reference,
and the caller another.
* therefore, file_cache_create() now owns a reference to its vm_cache_ref, and
frees it in file_cache_delete().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21533 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 245aecda 21-Jun-2007 Axel Dörfler <axeld@pinc-software.de>

Got rid of vnode_id and mount_id, replaced with ino_t and dev_t.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21485 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f415aa28 28-May-2007 Axel Dörfler <axeld@pinc-software.de>

* create_vnode() now panicks when it could not find the freshly created vnode
in the vnode hash; that's a bug in the FS that shouldn't be ignored that way.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21262 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b5f602a7 27-May-2007 Jérôme Duval <korli@users.berlios.de>

added a missing newline, dunno why this message is displayed :)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21250 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1e768ed1 02-Apr-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

get_vnode_name():
* read_dir() is supposed to return B_OK and and a count of 0 when
reaching the end of the directory. In case the node in question could
not be found, we were looping infinitely.
* free_dir_cookie() was not invoked.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20519 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6376aa3f 23-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* The close-on-exit bitmap vfs_new_io_context() created was a byte
short, if the FD table size wasn't a multiple of 8.
* vfs_resize_fd_table() didn't seem to know at all about the
close-on-exit bitmap. The pointer in the io_context would point to
free()d memory afterwards. This explains the sporadically closed
stdin/out/err descriptors in programs started from Tracker and
Deskbar.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20413 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cf4ccd65 04-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Renamed the FS interface hook read_link() to read_symlink().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20330 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 12d359b8 04-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed write_link from the FS module interface. Adjusted all FS
add-ons accordingly and removed the syscall.
* Removed send_notification().
* Reimplemented notify_listener(). It used the unimplemented
send_notification(). Now it has a chance to work. Note that
notify_listener() is obsolete. I would already have removed it, if
there weren't lots of FS implementations still using it (Hint!).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20329 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 348be5b5 02-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced the new static lock sVnodeCoveredByMutex to guard the
vnode::covered_by fields. Together with sMountOpLock it allows write
access, either lock alone suffices for read access. Before
sMountOpLock had to be acquired for read (and write) access, which
meant that while mounting/unmounting a FS path resolution would have
to wait. In case of the UserlandFS this would even cause a deadlock
while mounting if the client tried to resolve the path of the device
to be mounted (e.g. by opening it).
* Added a clarifying comment about read access to the
fs_mount::covers_vnode/root_vnode field and removed locking in
resolve_volume_root_to_mount_point() which was not necessary for
explained reasons.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20308 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2f742879 02-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed get_vnode_name() to take a dirent* parameter instead of the
name (saves copying the name, if that has to be done anyway) and added a
wrapper version with the old interface.
* dir_vnode_to_path() was broken for file systems that didn't support
the get_vnode_name() hook. It resolved the mount point too early, so
that it was searching the mount point and not the FS root dir for the
node. It uses the get_vnode_name() function now (before resolving the
mount point).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20305 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9481e62b 01-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

is_vnode_removed() is now known as get_vnode_removed() and returns its
answer through a reference parameter.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20297 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6d366784 28-Feb-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Be nicer to FSs and fill in the known part of the fs_info *after* the FS
had its go. BeOS does the same.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20262 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 223bba10 28-Feb-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Resurrected is_vnode_removed().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20256 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c926cb8d 19-Feb-2007 François Revol <revol@free.fr>

Return sensible errors instead of -1. Added some TODO comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20166 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c8d3c6f4 19-Feb-2007 François Revol <revol@free.fr>

Implemented get/setrlimit(RLIMIT_NOVMON). Note the kernel calls don't set errno... but they're called by user versions. Might want to split them if needed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20165 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 793f5422 30-Aug-2006 Axel Dörfler <axeld@pinc-software.de>

Added a comment about the outcome of a potential problem.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18717 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c40fe37f 30-Aug-2006 Axel Dörfler <axeld@pinc-software.de>

* Reverted the changes r17693 made to vfs_get_vnode_cache(); instead, vm_create_vnode_cache()
will now grab a reference to the vnode as well if successful. This way, vfs_get_vnode_cache()
now actually works how it should: it will now always grab a reference to the cache and
its underlying vnode. This removes an extra reference to the vnode (and vm_cache) that
got ignored before and prevented volumes to be unmounted (or file caches to be removed).
Thanks to Korli for pointing this out.
* file_cache_create() is now aware of that extra vnode reference and releases it; unmounting
volumes is now working again as it should.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18716 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 355efe3e 24-Aug-2006 Jérôme Duval <korli@users.berlios.de>

improve debug command vnode_cache: it now accepts a device arg


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18618 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0ba03704 21-Jun-2006 Axel Dörfler <axeld@pinc-software.de>

Use B_MAX_SYMLINKS instead of SYMLINKS_MAX (which also fixes the build, btw).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17900 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8265e121 02-Jun-2006 Axel Dörfler <axeld@pinc-software.de>

Implemented mandatory file locking, BeOS style. BNode::Lock() and BNode::Unlock()
are now working as expected.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17697 a95241bf-73f2-0310-859d-f6bbb57e9c96


# acac7c68 01-Jun-2006 Axel Dörfler <axeld@pinc-software.de>

_vm_map_file() did in fact not work correctly, but the main problem was
vfs_get_vnode_cache() which did not acquire an extra reference to the
cache_ref when the cache had to be created.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17693 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 20914efd 25-May-2006 Axel Dörfler <axeld@pinc-software.de>

Made _user_open_entry_ref() a bit more relaxed and return B_BAD_VALUE on some
obvious errors.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17586 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4b25b1b9 19-May-2006 Axel Dörfler <axeld@pinc-software.de>

common_lock_node() now pretends to be successful - this should fix Vision not being
able to store its settings for now (bug #589).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17505 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3cb039ff 05-May-2006 Axel Dörfler <axeld@pinc-software.de>

When you try to mount a file image, BFS now only sees the normalized path instead
of the one supplied to fs_mount() (but not the /dev/disk/virtual/... entry, as that
wouldn't be that clear to the user).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17335 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 65bd831c 05-May-2006 Axel Dörfler <axeld@pinc-software.de>

* KDiskDeviceManager::_ScanPartition() can now run synchronously (and execute the
scan job in the calling thread).
* KDiskDeviceManager::InitialDeviceScan() now runs synchronously, so that
get_boot_partitions() doesn't need to do this ugly wait hack.
* KDiskDeviceManager::CreateFileDevice() can now run synchronously as well, which
fixes a deadlock in fs_mount() - note, mounting file devices still doesn't work,
though as Haiku's BFS doesn't allow this right now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17334 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4827dbe4 18-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed a bug in the VFS that could cause BFS to corrupt an inode:
dir_remove() did not normalize the path, and thus, could forward a "." as
name for the removed directory - which BFS didn't catch because it assumed
our VFS would work correctly...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17165 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a88c592f 18-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

Instead of ending up in an endless loop, fs_sync() will now bail out in
case get_vnode() fails.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17162 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fde87a10 18-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

Instead of waiting forever, get_vnode() will now fail after 3 seconds if the
vnode is not becoming unbusy (right now it even panics, but that can be removed
later on).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17161 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b2536cb5 16-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed bug #483:
* vfs_get_fs_node_from_path() now also work for absolute paths again (but
still for relative ones from the volume root) - it just tests if the
mount IDs fit, so it only returns successful if the path really is on
the desired mount.
* the Disk Device Manager publish functions now call devfs_publish_*()
correctly (by omitting the "/dev/" mount point).
* devfs_publish_partition() now accepts absolute device paths but relative
partition paths.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17138 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9a11448f 13-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

vfs_get_fs_node_from_path() didn't work correctly and ignored the mount_id
(ie. it only worked for absolute paths, but it shouldn't work for those at
all).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17127 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 97e06971 12-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

Added a "reenter" parameter to the {read|write}_pages() functions to give file
systems a chance to know if they have locked already.
This fixes a locking problem in BFS where one thread tried to acquire two read
locks (where someone else trying to acquire a write lock would have caused a
dead lock).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17108 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 675c19c9 10-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

* fs_sync() and free_vnode() now use the file system's fsync() hook to write back
changes made to a file instead of directly using vm_cache_write_modified() -
besides making the file system more independent from the file cache, this also
works around a possible dead lock (that is to be fixed in a later commit).
* fs_sync() no longer uses vnodes from the mount's vnode list directly to write
back the changes made to them, but gets them via ID instead - this makes sure
the vnode is in a valid state and fixes a race condition with free_vnode().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17059 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 606e0d36 27-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Factored out the vnode disconnection code from fs_unmount() to a separate
function, and added a vfs_disconnect_vnode() for other kernel components.
* devfs_unpublish_device() can now optionally make use of this call.
* Fixed the type check of devfs' unpublish_node().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16907 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 33dd8550 14-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16784 a95241bf-73f2-0310-859d-f6bbb57e9c96


# abb84c7d 08-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

Removing the nodes from the unused list in fs_unmount() had the side effect that
the root vnode was tried to be removed as well (which resulted in a crash).
Since playing with the root node reference count is a bad idea anyway and opens
a big race condition (with regards to the unused list), we no longer do that
now, until it's safe.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16665 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f951ca0e 08-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed a couple of bugs:
* fs_unmount() freed vnodes, but didn't remove them from the unused list if
needed.
* vfs_get_module_path() could put a vnode twice under several situations.
* vnode_path_to_vnode() now always puts the dir vnode, even if the provided
path is NULL. Documented the fact that it does eat the ref, too.
* Added a to-do item in vfs_get_vnode_cache() about a possible problem.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16662 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 311bcf39 07-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed a possible deadlock I've introduced earlier (since create_sem() calls
vfs_free_unused_vnodes()); the vnode mutex is now hold for much shorter times
only:
* Rewrote advisory_locking creation/maintenance to hold the vnode mutex only
for very short times.
* the vnode mutex is no longer held during file cache construction; instead,
the vnode is marked busy.
* Implemented an (incorrect for now) get_advisory_lock()


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16635 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9f6376a0 06-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* get_vnode() did not decrease the sUnusedVnodes counter when taking one node
of that list.
* Added a vfs_free_unused_vnodes() function that calls the low memory handler
directly.
* create_sem_etc() now calls the above function in case there are no semaphores
available anymore; this usually frees up to 2 semaphores per node (one from
the cache if there is a file cache attached, and eventually one from the
file system).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16610 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d98d96e9 06-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

Added debugger command that dumps info about the vnode usage.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16607 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0254f09d 05-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

It's not so problematic if a busy vnode was released; what is problematic is
if that was the last ref.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16590 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0d4c16e0 05-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Reduced the stack usage of most of the I/O paths - there were several places
that put one or more full paths on the stack before, which could cause some
problems under certain conditions.
* Cleaned up KPath, ie. use size_t instead of int32 where appropriate, added
license.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16585 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bb674499 03-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Finally implemented B_WATCH_MOUNT, ie. Tracker now shows newly mounted volumes
(mounting still only works from the Terminal).
* Shuffled functions in node_monitor.cpp around to clearly differentiate between
private, private kernel, and public kernel functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16575 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3ea7d1fc 27-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup, now returns B_NAME_TOO_LONG if the query string or mount parameters were
longer than 64k.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16527 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5a2ad00c 20-Feb-2006 Jérôme Duval <korli@users.berlios.de>

fix a TODO in _user_mount : added an argsLength parameter


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16480 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 979aeaf7 25-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed bug #97:
* BEntry::Remove() now uses _kern_remove_dir() for directories.
* Added fd parameter to _kern_remove_dir().
* Fixed LibBeAdapter's _kern_unlink() to only work on files, and
added _kern_remove_dir() for directories.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16078 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7817211a 16-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Allow only root to look at other team's file descriptors.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15992 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0e382a46 16-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Implemented a syscall to get information about the open file descriptors of all teams.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15991 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ddb7d0b6 15-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Implemented force unmounting - by passing the "-f" option to "unmount" you
can now safely unmount volumes that are still in use by some applications.
Minor fixes to the FD disconnection implementation:
* put_fd() checked the condition for being able to disconnect a descriptor
incorrectly (causing the FD to never be disconnected).
* remove_fd() would hand out disconnected descriptors (but should have
returned NULL for them).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15952 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 16cfe613 21-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed vfs_lookup_vnode() - it's not called with the mutex already locked anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15647 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ea2cd27e 21-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

* Fixed the strange vm_cache_ref reference count mechanism: now, a fresh
vm_cache_ref starts with a reference count of 1. When acquiring a vm_cache,
you no longer need to worry if that should go through the vm_store, or not;
as it now always does.
* map_backing_store() no longer needs to play with the vm_cache_ref
references.
* that simplified some code.
* vfs_get_vnode_cache() now grabs a reference to the cache, if successful.
* better balanced vnode ownership on vnode_store creation (vnode_store
released the vnode before if its creation failed).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15641 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 89f5f72a 16-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

* Added debug output to vm_low_memory.cpp.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15568 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d0d37bdf 16-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

* vfs_init() is now called later in the startup sequence - since no core kernel
service depends on it, it doesn't make any sense to call it that early in the
game.
* The VFS now has a low memory handler for vnodes as well. If there is enough
memory left, it won't free any vnodes anymore.
* Potential crashing bug fix: some functions did not check if the FD passed
in belonged to the right type; they just assumed it had a valid vnode, but
it could have had a mount structure associated as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15566 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 04cd47db 10-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

common_access() now follows the same logic as traversing paths: if the file system
doesn't export the fs_access() function, it assumes access is granted.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14816 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7121425e 20-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Turns out we could remove a mount point...
Under BeOS remove_vnode() is failing in this case, which looks like a good idea to imitate.
Also, pipefs/rootfs didn't handle that case - they even removed the entry before calling
remove_vnode() - they now behave correctly. And also BFS now returns the actual error code
received from remove_vnode() instead of B_ERROR.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14456 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2db3fced 17-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Moved vfs_bootstrap_file_systems() and vfs_mount_boot_file_system() out of vfs.cpp
and into its own file vfs_boot.cpp.

Added basic support for booting from CD - it doesn't give CDs a higher priority,
so you could end up booting from HD when you didn't explicetly select "CD-ROM"
in the boot loader. Eventually, it should only boot from HD in this case, if
booting from CD failed (because of a missing boot partition or whatever).

fs_mount(), _kern_mount(), and _user_mount() will now return the dev_t of the
mounted device, and not just B_OK. Maybe we should have fs_unmount() work on
a dev_t instead of a path as well...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14403 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9a63d903 06-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Added kernel private VFS functions vfs_entry_ref_to_vnode() and vfs_vnode_to_node_ref().
Minor cleanup of vfs.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14314 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 681779f1 06-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Our close-on-exec flag handling was broken: it's supposed to be specified per slot, not
per file descriptor (a descriptor can be shared among several slots). There is now a
second table in the io_context structure that contains that information in a bitmap.
There are now two new (private) functions to control the close-on-exec flag, fd_close_on_exec(),
and fd_set_close_on_exec().
F_DUPFD, dup(), and dup2() are supposed to clear the close-on-exec flag on the duplicated
slot - this fixes bug #57 (no output after a redirect of a shell builtin).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14313 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1670b8f5 06-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

num_used_fds counting was broken for dup2() and vfs_new_io_context() when it was
used with a parent context.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14311 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e8d4a05d 06-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed the "iocontext" command to "io_context" to match the structure name.
It now also accepts a team ID and will then dump its io_context.
Accidently mixed used/max FD counter.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14310 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 333735e8 05-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Added a new debugger command "iocontext" that prints out info about the kernel's
I/O context (or a specified one) including its FDs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14304 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f10cba9a 22-Sep-2005 Axel Dörfler <axeld@pinc-software.de>

Changed get_mount() to return a status code instead of just the mount or NULL.
Some fields of fs_mount were not properly initialized when FS's mount function
was called, and therefore, could let get_mount() return a mount structure that
was not yet read for public consumption (this should fix bug #51).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14223 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 47a54bea 28-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Rootfs now starts with 1 for the first inode ID.
Instead of -1, vnode_path_to_vnode() now returns the ID of the starting vnode when it
doesn't need to traverse the path at all.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14081 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7b285866 25-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed hash functions: when the key was lower than 0 (could happen with entry_refs
and node_refs passed in) they returned an invalid index (larger than range).
Fixed rootfs compilation with tracing turned on.
Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14065 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e0481f92 21-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Now marks a partition unmounted on unmount - that allows a volume to be remounted as often as you like.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14036 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b14757a 20-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

We now have a consistent scheme what the file system should do with its root
node: like in BeOS, it *must* own the root node (ie. via publish_vnode()),
unlike in BeOS, it must also drop that reference on unmount (symmetrical
behaviour definitely makes more sense to me than the Be way).
Since all existing file systems for Haiku behaved differently, I brought them
in line (only pipefs already adhered to that new standard for some reason,
rootfs did only released the node, devfs did nothing - despite it's probably
not really useful to be able to unmount them).
fs_mount() will now panic if a file system does not do this correctly (useful
for file system developing).
Unmounting is now theoretically working again: when trying to unmount a BFS
volume, the kernel crashes in the block cache destruction... (but that's work
for tomorrow).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14017 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e8e4accd 18-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Add some useful debugger commands to the VFS layer for dumping a vnode, an fs_mount, and
the mounts/vnodes list.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13971 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7964c56d 09-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Added vfs_get_cwd() call to get the mount_id and vnode_id of the current
working directory (instead of the full path).
Cleanup of some remaining "int" status variables (where it should have
been a "status_t").


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13924 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eab435cd 05-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

vfs_get_vnode_cache() now only allocates a new cache if requested: this
prevents the system to allocate caches for files that don't use or have
a file cache (ie. only those can be mmap()ed!).
Therefore, cache_prefetch() no longer crashes when trying to prefetch
files without a file cache.
read_into_cache() no longer does anything if the requested size is 0.
Fixed a bug in cache_prefetch_vnode(): if the cache couldn't be retrieved,
it put the vnode, but didn't own it (the caller does).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13904 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 95839f5c 03-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

The file cache now has another init method that is called after the boot
device becomes available.
Currently, it opens the "launch_speedup" module (if available), later it
should consult a settings file for what to do.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13894 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c50cfe23 02-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed crashing bug in remove_vnode(): it freed the vnode, but it didn't
remove it from the hash, and thus, left a dead pointer around.
free_vnode() does now also remove the vnode from the hash - this is done
so that the file system is notified about removal/put of the vnode before
there is a chance that this vnode is recreated/reloaded (could make the
life of file system writers a bit easier).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13877 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b72cf260 01-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed vfs_vnode_acquire_ref() to vnode_acquire_vnode().
Removed vfs_vnode_release_ref(), as vfs_put_vnode() already does the same thing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13867 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b7d8ef5a 01-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

The term vnode_ptr is not used anywhere else; renamed vfs_put_vnode_ptr() to vfs_put_vnode().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13865 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9882caaa 31-Jul-2005 Axel Dörfler <axeld@pinc-software.de>

The path resolving functions can now also fill in the ID of the parent directory.
This is currently only used for the file cache module API.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13862 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 54476a21 12-Jul-2005 Axel Dörfler <axeld@pinc-software.de>

file_create() now also supports FD relative path specifications.
This was the cause for some apps to put their settings files to the current
directory, and also that Tracker did not find some icons (from the icons
it installed in the MIME database).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13645 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ada59753 23-May-2005 Axel Dörfler <axeld@pinc-software.de>

fs_mount() and get_file_system() can now both handle file system names
in the form "bfs" and "file_systems/bfs/v1".


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12791 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 47f39c93 23-May-2005 Axel Dörfler <axeld@pinc-software.de>

Merged the disk device manager module interface for file systems with the
VFS's interface, so that a file system only has to implement one interface.
As a side effect, the automatic file system detection may now work (not yet
tested, though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12786 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d5b04e50 13-May-2005 Axel Dörfler <axeld@pinc-software.de>

First step into a new block allocation strategy for the block_cache
(right now, it's still malloc/free, just encapsulated in an allocator class).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12662 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6bdc405f 12-May-2005 Axel Dörfler <axeld@pinc-software.de>

Whenever KPath is used, it will now be tested if it could be initialized
(thanks to Ingo for the reminder...).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12652 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cbd1d997 11-May-2005 Axel Dörfler <axeld@pinc-software.de>

Changed all _kern_*() calls to use KPath instead of a path buffer on the stack.
This reduces the stack usage quite a lot, and since file system calls could be
nested (for example, a mounted image on a volume), definitely a must, too.
Might be a good idea for user calls, too, though, although it's not urgent.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12636 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0953c83e 02-May-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed another bug: after a partition had been mounted, it was only marked
mounted, but no one told it about its volume ID - that caused "mountvolume"
not to be able to return a valid mount point.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12548 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 47729f04 02-May-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a possible bug in path_to_vnode(): if called before a root
file system has been mounted, it would have crashed (that for example
happened if you deleted the kernel settings file...).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12547 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2d690920 13-Apr-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed system/core to system/kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12360 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eb62d3337b82f4dce6b1a0b3f116e38491c66f14 11-Sep-2015 Axel Dörfler <axeld@pinc-software.de>

VFS: Slight rework of the FD disconnect feature.

* This should fix ticket #4157, although I probably have missed
something.
* In any case, it no longer messes with the ref counts of the
file descriptor, and the race condition in put_fd() should be
gone.
* It's still rather messy all in all.


# 6adf7a0c75beebd9a9bd48602f50ac7c7ae8056e 11-Sep-2015 Axel Dörfler <axeld@pinc-software.de>

VFS: prevent FD inheritance for the kernel completely.

* Each io_context now has a "inherit_fds" member that decides whether
or not this context allows to inherit FDs to its children.
* This replaces the former O_CLOEXEC mechanism.


# e668e80db0334946b01d20e53b03c05dea0f2cb8 11-Sep-2015 Axel Dörfler <axeld@pinc-software.de>

VFS: Always open kernel FDs with O_CLOEXEC.

* Avoids leaking them into userland.


# 5d4501aa0187e1a8790784dc2ab3382a16660e93 20-Aug-2015 Michael Lotz <mmlr@mlotz.ch>

Assorted whitespace cleanup and typo fixes.


# efb0a3a853557e69ecf2bc88adc9a69ed08d1514 17-Aug-2015 Michael Lotz <mmlr@mlotz.ch>

EntryCache: Add entry_cache_add_missing() for negative caching.

It provides a way for filesystems to cache a lookup failure and
therefore prevents repeated lookups of missing entries. This is a
common scenario for example in command lookup and compiling, where
each directory in PATH or each include directory is searched for the
given entry.


# 3395fdcd6ab08d881ee3bfbb50413eb1c445595d 12-Jan-2015 Adrien Destugues <pulkomandy@gmail.com>

gcc4 build fix.

* offsetof is not allowed on non-POD types so we need to use
offset_of_member (gcc2 accepts offsetof, and C++11 relaxed the
constraints on where it is allowed so it should work there too)
* we have offset_of_member as a workaround until we switch to C++11,
move it from khash (which is soon to be removed) to list.h which is the
other place where it is used (for this one single call in our whole
codebase)

Also fix a typo in vfs.cpp.


# f9defd45266aef2138460ad8d719b452b3a158bc 12-Jan-2015 Adrien Destugues <pulkomandy@gmail.com>

VFS: migrate to BOpenHashTable.


# 76b8f002e1aef2f3b7311178b810f3ed6f505b1c 04-Nov-2014 François Revol <revol@free.fr>

Implement lseek(SEEK_END) on devices

While the partitioning system does publish partitions as block
devices and report their size in stat(), the old BeOS-style
drivers have no means of reporting it this way.
So we fall back to ioctl(B_GET_GEOMETRY) to find out the size.


# 22ea34153f39a2f995b505173e1571e2a5d39192 01-Nov-2014 Jessica Hamilton <jessica.l.hamilton@gmail.com>

access: fix to be POSIX compliant


# 6bbd25f071e5981c15444c8ba28a92b145b77566 29-Oct-2014 Ingo Weinhold <ingo_weinhold@gmx.de>

Make vfs_resize_fd_table() accessible in the kernel

Also update some types from int to uint32.


# 5a95af70a2c45a103b96046b5dae5c2b5a303dfa 25-Oct-2014 Axel Dörfler <axeld@pinc-software.de>

vfs/{b|btr|package|b}fs/ext2/exfat: common access check.

* Added VFS helper function check_access_permissions() that combines
several partially correct versions to the one true version (tm).
* All but BFS (since recently) missed the S_IXOTH for root on directories,
and all but packagefs missed proper group handling.


# 8efd5b761352ca5ba3b5118895c40eedb1cf692b 25-Oct-2014 Axel Dörfler <axeld@pinc-software.de>

vfs: check the X permission on set cwd.

* When you change the current working directory, you actually
should have the permission to enter that directory.
* This gives us a 0.04% better score on the perl test suite :-)


# 8ea3e9126db5df5dad3710b63db3383e8024c366 18-Oct-2014 Michael Lotz <mmlr@mlotz.ch>

Typo: Fix doubled "not" in comment.


# d64267ffb204088ad3ed9bae6078361a829d83de 09-Jun-2014 Jérôme Duval <jerome.duval@gmail.com>

vfs: checks whether the mount's unmounting flag is already set.

* thanks to Ingo for suggesting the idea, quoting him:
"by holding sVnodeLock read-locked, get_mount() ensures that fs_unmount() can't
process the nodes. If it is already past that point, the root node check
(not NULL, not busy, ref count > 0) is supposed to detect that. But it doesn't
look like this can work. fs_unmount() doesn't set the root node to NULL (the
root node field is NULL only during a short period in fs_mount()), but it just
frees the nodes after releasing sVnodeLock. So the not busy and ref count > 0
checks could already access freed memory".
* tested OK, this fixes #10522.
* replaced mount->root_vnode by the local variable with the same value.


# 38b150a9de3b51a7b9de6e6e85c066b57d43fc06 24-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

VFS FIFO: Add "fifo" KDL command

Prints information about a FIFO node and, optionally, its data buffer
content.


# 104c0688da028acab4a5b03801d111673dd091de 11-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

dir_vnode_to_path(): Fix uninitialized status variable


# 07f6506eb661220c5e2603c2c6896175a001fa69 11-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

VFS: Fix broken zero_pages()

Besides that it failed to actually iterate through the vectors, it
shouldn't try to clear physical memory in the first place. The iovecs
refer to virtual address ranges. Rename it to zero_iovecs() to avoid
confusion.


# 18640f25d904065f9cf16251fee884cdda906e3b 10-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

vfs: dir_vnode_to_path(): Fix bug with chroot on mount

Simplify the code, which also fixes the bug that the I/O context's root
was ignored when it was a mount point, thus resulting in globally rooted
paths in this case.


# 726e47bb80d83fe6af11edd409e5949d66102b9e 10-Sep-2013 Siarzhuk Zharski <zharik@gmx.li>

vfs:Remove extra put_vnode call on error B_LINK_LIMIT exit

Fixing the autoconf test: attempt to create file in place of already
existing symlink. On error exit put_vnode was called explicitly before
returning error. The second, implicit call to put_vnode was issued on
destroying the VNodePutter instance that references the same vnode. At
this time the vnode has references count equal to 0 so corresponding
panic was executed. Great thanks to Ingo for pointing it out!

Fixes #9140.


# a56422b448e15901c984daad5f4df2b94b6fff18 01-Aug-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

VFS: fs_mount(): fix FS name leak

Fixes #9909.


# 311e148798ae4738157c39ab7783b63e70203192 29-Apr-2013 Jérôme Duval <jerome.duval@gmail.com>

vfs: fixed two warnings.

* warnings about comparison between signed and unsigned integer expressions.


# 237127fbe4071abea20f3e5005f5a1e549f12788 22-Apr-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Fix _user_entry_ref_to_path() in chroot

* Add "bool kernel" parameter to vfs_entry_ref_to_path(), so it can be
specified for which I/O context the entry ref shall be translated.
* _user_entry_ref_to_path(): Use the calling team's I/O context instead
of the kernel's. Fixes the bug that in a chroot the syscall would
return a path for outside the chroot.


# 5b6fb78c407a1c15a6793e9009857d4dedfc331d 05-Apr-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

VFS: _kern_open_dir(): Fix NULL path case

It would create an empty path buffer and pass that on to dir_open(),
which accepts NULL, but not empty paths.


# 8627383bf7cc58f79f41a926331aa113814401d4 22-Mar-2013 Alex Smith <alex@alex-smith.me.uk>

Fixed compilation errors with ENABLE_TRACING set.


# 1aef6664d1e120c9dcfc5d7c96f6270243f984f7 22-Mar-2013 Alex Smith <alex@alex-smith.me.uk>

Fixed compilation of VFS/IORequest trace messages.


# 1a0386d743c1e6ffa823e2158192247509564c88 12-Mar-2013 Pawel Dziepak <pdziepak@quarnos.org>

Fix #8661: fcntl(fd, F_GETLK, ...) violates POSIX

The standard states that F_GETLK should check whether given lock would be
blocked by another one and return description of the conflicting one (or
set l_type to F_UNLCK if there is no collision).

Current implementation of F_GETLK performs completely different actions, it
"Retrieves the first lock that has been set by the current team". Moreover,
if there are no locks (advisory_locking == NULL) an error is returned
instead of l_type set to F_UNLCK.


# d50875de46aeb3378feda778b54d3fa288e2571a 02-Dec-2012 Michael Lotz <mmlr@mlotz.ch>

Use format macros in debug output.


# 195a0f350e3acd76856016f673c8a871ed687a07 21-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Changed argument type of fcntl syscall from uint32 to size_t.

Since this argument may be used to pass pointers, uint32 is not
correct for 64-bit. Effectively no change on 32-bit targets, both
size_t and uint32 are unsigned long there.


# c3f0fd28cda13d70a8c092003609442e4e29cf78 12-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed formatting of output in some debugger commands.

Currently all debugger commands assume 32-bit pointers when formatting their
output. This means that on x86_64 the output is incorrectly formatted. Fixed
this by adding a B_PRINTF_POINTER_WIDTH definition (16 on 64-bit, 8 on
32-bit), and using this to correctly format the output. Not all commands have
been fixed yet, but all VM, slab, VFS, team, thread and image commands should
be correct.


# d764d148b10b8b0f84bbf344ccc9cf35fdb2c99d 27-Jun-2012 Pawel Dziepak <pdziepak@quarnos.org>

Allow file systems to manage file locks

Haiku implements file locking at vfs level. That would not work for remote
and shared file systems, since they need to negotiate locks with peers.
This patch introduces three additional hooks in fs_interface that allow
file system module to take over the management of file locks.


# 4be4fc6b1faddbd037146214a0011d320842b4f3 15-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

More 64-bit compilation/safety fixes.


# 4bbb27e3ccf0b1e38ee4a63ca9ec765e167a72bd 12-Feb-2012 Jerome Duval <jerome.duval@gmail.com>

More 'GCC4.6 variable set but not used' fixes.


# 7ef47de9084a2b73db73fbed07ff62966eadff20 13-Feb-2012 czeidler <haiku@clemens-zeidler.de>

Revert "Finally applying the patch that adds support to add path information to stat and attr monitor messages."

Will recommit it when I have more time to work on the todos.

This reverts commit 610ef6c00781522022455c0cbf34495420b2db1d.


# 610ef6c00781522022455c0cbf34495420b2db1d 21-Jan-2012 czeidler <haiku@clemens-zeidler.de>

Finally applying the patch that adds support to add path information to stat and attr monitor messages.
* for all open FD the path information is stored in a map
* this info is used to fill the missing fields in the node monitor


# 04999b6cf99c5f5de4abc77d812cad5c497d2703 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Completed vfs_bind_mount_directory() support

We don't need to explicitly track the covered/covering nodes per mount
after all. In fs_unmount() we iterate through all vnodes multiple times
anyway and can deal with the covers/covered_by vnodes there. Also, the
root vnode doesn't need to be handled specially anymore.


# 1b08a68a4f3656bd2e0ab526418c5d97e547a5c7 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

vfs_bind_mount_directory(): Fail if unmounting


# 8855625e9eda5284a8d959695e0b86c51148aef0 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

fix_dirent(): Fix ref count leaks

* Only get an additional parent reference, when going to call
vnode_path_to_vnode().
* Put the reference of the vnode vnode_path_to_vnode() returns.


# e4320fd78c7c0e51adc84874e9406224fd616b8f 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

remove_vnode(): Also consider covering vnode busy


# 54e721afeb11349677b5b9e39c61312753a33cef 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add support for bind-mounting directories

* Add support function vfs_get_mount_point(), so a file system can get
its own mount point (i.e. the node it covers). Re-added
fs_mount::covers_vnode for that purpose -- the root node isn't know to
the VFS before the mount() hook returns.
* Add function vfs_bind_mount_directory() which bind-mounts a directory
to another. The Vnode::covers/covered_by mechanism is used, so this
isn't true bind-mounting, but sufficient for what we need ATM and
cheaper as well. The vnodes connected thus aren't tracked yet, which
is needed for undoing the connection when unmounting.
* get_vnode_name(): Don't use dir_read() to read the directory. Since we
have already resolved vnode to the covered vnode, we don't want the
dirents to be "fixed" to refer to the covering nodes. Such a vnode
simply wouldn't be found.


# f4a1387cea3b8a441bc1d952bc562ae34af6647c 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add vfs_ prefix to resolve_vnode_to_covering_vnode()


# 47ea54c55bed272f7c506b23d1ff8216e6a57a96 20-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Generalize use of Vnode::covered_by/covers

* Introduce Vnode flags for covered and covering. Can be used as a quick
check when one doesn't already hold sVnodeLock.
* Rename resolve_mount_point_to_volume_root() to
resolve_vnode_to_covering_vnode().
* Adjust all code that deals with transitions between mount points and
volume root vnodes to generally support covered/covering vnodes.


# 02be66ca1093b26d538f9aa56ede8564c910acdd 20-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced fs_mount::covers_vnode by Vnode::covers

Introduce a Vnode::covers field. It is currently only used for the root
node of an fs_mount, replacing fs_mount::covers_vnode.


# 7bb72b8daf2c3579a1f7fb341240e632c493e5b4 20-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Comment typo fixes


# a735bdebb94ce14c72f56204f022038de7a49e2f 31-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

Align all filesystem relevant places to use B_UNSUPPORTED for unsupported
instead of a mix of B_NOT_SUPPORTED and B_UNSUPPORTED. This allows checking for
a specific error code. Probably one of those should be phased out...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43025 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d5e36fb599b43a6a9dfb3cf8e95018fe15780219 10-Aug-2011 Axel Dörfler <axeld@pinc-software.de>

* Introduced new fs_lopen_attr_dir() function that opens the attribute
directory of a file without traversing leaf links (just like lstat()).
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42620 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 33272012fb9f54a00444e7213a59b7312d201095 10-Aug-2011 Axel Dörfler <axeld@pinc-software.de>

* Fixed reversed handling of O_NOTRAVERSE in attr_open(), and attr_create().
* Added support for O_NOFOLLOW for those two as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42619 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fe5928847a347b3a46eea68628388e60796e71db 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Completed vfs_bind_mount_directory() support

We don't need to explicitly track the covered/covering nodes per mount
after all. In fs_unmount() we iterate through all vnodes multiple times
anyway and can deal with the covers/covered_by vnodes there. Also, the
root vnode doesn't need to be handled specially anymore.


# 0be138ab2f4098d3910880c92f94de8f4c2ea0df 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

vfs_bind_mount_directory(): Fail if unmounting


# 19c48aa4ae39e2b2ff84224e66b9f8e7b0280c3f 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

fix_dirent(): Fix ref count leaks

* Only get an additional parent reference, when going to call
vnode_path_to_vnode().
* Put the reference of the vnode vnode_path_to_vnode() returns.


# 9561ddca0f8e80582cd352f8f80b187bce7195ed 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

remove_vnode(): Also consider covering vnode busy


# d61a8548f9d5efd322004bfd62c57e5a3891cdbf 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add support for bind-mounting directories

* Add support function vfs_get_mount_point(), so a file system can get
its own mount point (i.e. the node it covers). Re-added
fs_mount::covers_vnode for that purpose -- the root node isn't know to
the VFS before the mount() hook returns.
* Add function vfs_bind_mount_directory() which bind-mounts a directory
to another. The Vnode::covers/covered_by mechanism is used, so this
isn't true bind-mounting, but sufficient for what we need ATM and
cheaper as well. The vnodes connected thus aren't tracked yet, which
is needed for undoing the connection when unmounting.
* get_vnode_name(): Don't use dir_read() to read the directory. Since we
have already resolved vnode to the covered vnode, we don't want the
dirents to be "fixed" to refer to the covering nodes. Such a vnode
simply wouldn't be found.


# 313e1e37f229242df626cb34f466d388590d62d9 21-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Add vfs_ prefix to resolve_vnode_to_covering_vnode()


# 2e21fc543649e665507240f0803de9dddc26f152 20-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Generalize use of Vnode::covered_by/covers

* Introduce Vnode flags for covered and covering. Can be used as a quick
check when one doesn't already hold sVnodeLock.
* Rename resolve_mount_point_to_volume_root() to
resolve_vnode_to_covering_vnode().
* Adjust all code that deals with transitions between mount points and
volume root vnodes to generally support covered/covering vnodes.


# 3cc710798baa42c155dd2e5c4c75306755ae2fd7 20-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced fs_mount::covers_vnode by Vnode::covers

Introduce a Vnode::covers field. It is currently only used for the root
node of an fs_mount, replacing fs_mount::covers_vnode.


# 9280379a7bf876ccde70040d6b7448b85c1e48f5 20-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Comment typo fixes


# 24df65921befcd0ad0c5c7866118f922da61cb96 11-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged signals-merge branch into trunk with the following changes:
* Reorganized the kernel locking related to threads and teams.
* We now discriminate correctly between process and thread signals. Signal
handlers have been moved to teams. Fixes #5679.
* Implemented real-time signal support, including signal queuing, SA_SIGINFO
support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition
of the real-time signal range. Closes #1935 and #2695.
* Gave SIGBUS a separate signal number. Fixes #6704.
* Implemented <time.h> clock and timer support, and fixed/completed alarm() and
[set]itimer(). Closes #5682.
* Implemented support for thread cancellation. Closes #5686.
* Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554.
* Lots over smaller more or less related changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8775d8d25d66d46c31d929547b6f16b9a88900a1 05-Mar-2011 Jérôme Duval <korli@users.berlios.de>

dir_remove() now handles a path which ends with "/./" and fixed #6817.
Another way would be to disallow removing such a path, as Linux does.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40819 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 548836e4f8294e7ec90734f8cd79da9a9daa08a5 02-Mar-2011 Jérôme Duval <korli@users.berlios.de>

* if ioctl hook wasn't found, now returns B_DEV_INVALID_IOCTL
* in case fd_ioctl() was about to return B_DEV_INVALID_IOCTL, translate to ENOTTY to satisfy #7279.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40787 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 137c5fe2ba9706736db4af57584b663b1b282f6c 16-Jan-2011 Oliver Tappe <zooey@hirschkaefer.de>

* add implementation of bindfs, which can be used to bind-mount
a folder to some other place in the filesystem hierarchy
* add helper function to VFS that encapsulates the "conversion" of a
vnode-pointer to a fs_vnode-pointer (used by bindfs)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40238 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4535495d80c86e19e2610e7444a4fcefe3e0f8e6 10-Jan-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged the signals branch into trunk, with these changes:
* The team and thread kernel structures have been renamed to Team and Thread
respectively and moved into the new BKernel namespace.
* Several (kernel add-on) sources have been converted from C to C++ since
private kernel headers are included that are no longer C compatible.

Changes after merging:
* Fixed gcc 2 build (warnings mainly in the scary firewire bus manager).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 66e8557230e3b30984f25f9ea6b616c56ae7c2aa 02-Jan-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

common_rename(): Fixed incorrect check (array address instead of first
element, CID 4077).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40082 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2757dc8c3a2372875b83081ea9a453a2c04ccbfa 21-Nov-2010 François Revol <revol@free.fr>

Fix build with VFS_PAGES_IO_TRACING.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39566 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 31d8c43d1c04be453ff6b7afa3f2cdb95cde4bc6 28-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed CID 1262: waitForLock was not only -1 when exiting the loop, it didn't
make much sense to wake up any waiters either in this case.
* Fixed doubled semaphore deletion.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38418 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 87de0cb4e1cc09e5beb1a3500d239ca19b0210dd 17-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed CID 1199-1202: only call the cache listener in case the open succeeded
(this might also have derefenced a potentially freed vnode).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8e855d520a06880a32d7d481b8b9bab0b8359852 02-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Changed some POSIX error codes to native ones.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37842 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c019945cbd4e36914c6eba37e2f4c2d60a25b117 17-Jul-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added detail to the comment about why we can't call the create() hook without
O_EXCL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37555 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1cdc3cbbe41a904332b93f5185d9a3eeb00dd356 18-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

The vnode cache also considers the address space low resource state, now.
Together with vnode associated structures like file cache, VMCache, and file
system specific structures the impact on heap usage (and thus address space)
is considerable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37169 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 435c43f5912b109e7d5cf682865d2061e62fad8c 02-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced type generic_io_vec, which is similar to iovec, but uses types
that are wide enough for both virtual and physical addresses.
* DMABuffer, IORequest, IOScheduler,... and code using them: Use
generic_io_vec and generic_{addr,size}_t where necessary.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36997 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9d570af7c878ba30043b23e6dce5f3ae5578aa7c 24-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed the type of the "op" parameter of the fs_vnode_ops::ioctl() hook and
the _kern_ioctl() syscall from ulong to uint32.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36927 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1888e2289d471cdb8fdacb3ad2b65e353a7ac11a 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

bonefish+mmlr:
The O_CLOEXEC open mode wasn't actually set in the close-on-exec bitmap causing
all files opened with O_CLOEXEC (like done in the storage kit classes) to still
be inherited. This caused for example to be unable to unmount volumes when
opening apps while Tracker touched some files (i.e. copying some large files)
since these apps would inherit the file descriptor and therefore keep the
volume busy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36273 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74fc3e9a8bc4831206f84209be224cad7792dc0e 14-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

bonefish+mmlr:
* Add file descriptor and IO context tracing.
* Some minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36272 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7d9bce24834550b9473a11072bc5dc3da69067cd 27-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

debug_resolve_vnode_path(): Avoid duplicate slash at the beginning of the
path.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35642 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c35e2c70cba0295f8926aa255b5bbcb3fe5136f0 26-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added option "-p" to the "vnode" debugger command. Using the entry cache it
tries to resolve the vnode's path.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35626 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 21d9331efa64d6f4d1446d57b6ae79490431d8be 23-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Beautified the output of the "io_context" command.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35582 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d0e43cc7cbab464a1d09245052d4210a7b667e23 24-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

"vnode" does now also print the node type.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35280 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb1819be9514a50392eb87f9a593aca9fcc09fe6 07-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Eliminated sVnodeCoveredByMutex. The Vnode::covered_by field is now also
protected by the global vnodes lock. The contention mostly moves to other
locks, though. The total -j8 Haiku image build time is only reduced
minimally.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34938 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7fc65e14884ef98b696461957ef223f47768fdee 03-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

fs_unmount(): We need to hold the vnodes write lock after all. The upside is
that it saves us from locking the individual vnodes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34872 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a210e610534a28559091fc8a50b32171dbdecde1 03-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* free_unused_vnodes(): Be a good citizen and use vnode_used() instead of
playing with the unused list manually. This also clears the vnode's unused
flag, which wasn't done before and would thus cause corruption of the
unused list a bit later.
* fs_unmount():
- Fixed an iteration bug I introduced previously. The iterator would be
advanced twice per iteration, leading to NULL pointer dereferencing
when the vnode count was odd and skipping the checks for every other
vnode.
- All vnodes are going to be freed, so vnode_to_be_freed() has to invoked
for every one of them. The code wasn't adjusted correctly when
introducing the hot vnodes handling.
* Adjusted/improved some comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34871 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5484890096d122519e722d0a31b478eaa7e8ea1d 02-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved the unused vnode management to a new file. Well the few variables
used for it that is.
* The main cause for the heavy contention of the unused vnodes mutex was that
relatively few vnodes are actually used for a longer time. Mainly those are
the volume roots, mmap()ed files, and the files opened by programs. A good
deal of nodes -- particularly directories -- are just referenced for a very
short time, e.g. to resolve a path to a contained entry. This caused those
nodes to be added to and removed from the unused vnodes list very
frequently, thus resulting in a high contention of the mutex guarding it.
To address the problem I've introduced an approximation of a set of "hot"
vnodes, i.e. vnodes that have recently been marked unused. They are stored
in an array that by means of an r/w locker and atomic operations can most
of the time be accessed concurrently. Whenever it gets full, it is flushed
to the actual unused vnodes list.
* dec_vnode_ref_count(): No longer check the unused vnode count every time.
The called new vnode_unused() does only from time to time and returns when
the caller is expected to free some of the unused vnodes. As a side effect
this also fixes a bug I previously introduced: The unused vnode to be freed
was marked busy without being locked first.

The -j8 Haiku image test build shows that the changes reduce the contention
of the unused vnode list mutex to virtually zero without introducing any
significant contention of the new r/w lock. The VMCache lock contention also
seems to be decreased somewhat, which is probably not that surprising
considering that the page writer acquires/releases vnode references with the
cache lock held. The "pages" lock takes over even more contention, now
causing more than 100000 waits per second.
The total build time reduction is about 4.5%. Kernel time drops more than
10%.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34866 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ccbb7815ced1c3900042f36ff32ccd1f7f812d9 02-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved the vnode structure (to by Vnode class at some time in the future) into
its own header/source files.
* Changed vnode's bit fields to a single, atomically changeable int32 using
flags instead. Added respective accessor methods.
* Added a per-vnode mutex-like lock, which uses 2 bits of the structure and
32 global "buckets" which are used for waiter lists for the vnode locks.
* Reorganized the VFS locking a bit:
Renamed sVnodeMutex to sVnodeLock and made it an r/w lock. In most situations
it is now only read-locked to reduce its contention. The per-vnode locks guard
the fields of the vnode structure and the newly introduced sUnusedVnodesLock
has taken over the job to guard the unused vnodes list.

The main intent of the changes was to reduce the contention of the sVnodeMutex,
which was partially successful. In my standard -j8 Haiku image build test the
new sUnusedVnodesLock took over about a fourth of the former sVnodeMutex
contention, but the sVnodeLock and the vnode locks have virtually no contention
to speak of, now. A lot of contention migrated to the unrelated "pages" mutex
(another bottleneck). The overall build time dropped about 10 %.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34865 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb5c39cb6d83d81ecc3e7608cf208b53c7212fd2 01-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed TODO again. I tried a similar event mechanism as used for busy pages
in VMCache, but, if anything, that makes a -j8 build marginally slower. I
guess busy vnodes are encountered so rarely that the additional overhead for
a more intelligent algorithm isn't really worth it. Reduced the wait time,
though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34845 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f42efbcd26947b3394c94f7462ae2c0f6455a1d3 01-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved the entry cache implementation into its own file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34843 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7a9b8baa54b410f17a561570bf39e9d6c28c24f0 01-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Made vnode::type private, renamed it to fType, and added accessor methods. It
stores the value right-shifted by 12 bits, now, since those bits are not
relevant. This saves some bits and also resolves a TODO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34842 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3caec2871a079cb604982ce7e5fc56865a7b438d 01-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Resolved TODO in free_vnode(): There was a race condition between vnode
destruction and VMVnodeCache::AcquireUnreferencedStoreRef(). Solved by
adding a flag to VMVnodeCache and letting AcquireUnreferencedStoreRef()
fail, if set.
* Added TODO regarding replacing the snooze() waiting for busy vnodes.
* get_vnode(): Unlock sVnodeMutex while calling the put_vnode() hook on
error.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34841 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e50cf8765be50a7454c9488db38b638cf90805af 02-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved the VM headers into subdirectory vm/.
* Renamed vm_cache.h/vm_address_space.h to VMCache.h/VMAddressSpace.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34449 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a477e3cf200097774f88ed4e4134f87674a2a063 01-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Finished renaming of vm_cache to VMCache.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34424 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f31ffa6b8aa940bea5b13953697bc214ccd7bf5e 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Use O_CLOEXEC when open directories, attribute directories, indexes, and
queries.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34291 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 486fffdaaf7f16e65bea9f4fde7d5d3c3726ece8 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Forgot to add linkat(), this really closes #4928 now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34289 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb2500da15e8c574cbb343b8fc536d7094357f54 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Added missing AT_EACCESS.
* Implemented renameat(), faccessat(), fchownat(), fchmodat(), and mkfifoat().
* Added stub for mknodat().
* The kernel backend for faccessat() does not yet differentiate between
effective and real user/group IDs, though.
* Removed B_ENABLE_INCOMPLETE_POSIX_AT_SUPPORT, as we now support everything
(more or less). This also closes ticket #4928.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34288 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7ce581d7eb0618c10f6986abc3ddb32abd807db2 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Eliminated the extra buffer in dir_vnode_to_path(); we write directly to the
specified buffer now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34282 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 00362625b990ef6fffd8117df67e431893171453 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Added support for O_NOFOLLOW.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34279 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 432bb91f34eccedc387684e200db3e645b43a7a0 25-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* dir_vnode_to_path() now uses B_* error codes instead of POSIX ones, and also
returns the correct error code if the buffer was too small (should be ERANGE
instead of ENOBUF).
* Also, it is now independent of B_PATH_NAME_LENGTH, and therefore should
fulfill POSIX getcwd() requirements. This should also close ticket #3352.
* Is there any reason to allocate another buffer instead of using memmove()
at the end instead of memcpy()?


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34276 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1ba04177d3f10173d03433e9a7d37e46c2161428 25-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* load_image() now has exec() semantics wrt file descriptors; before each team
would always inherit them all, causing quite a number of open files.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34247 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 713cc7fc843376ae9c8d1adc2ab27aa762d6a025 17-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added fs_read_attr().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34085 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c3dbe62619cf35c94f43cc3340a55c04f5a3bc97 10-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

_user_open_dir(): Allow a NULL path to be passed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33973 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f40c5e32115c22bd1b76ee1abe607040c09681a9 05-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* common_rename() now checks the name for validity before passing it on to the
file systems, so those checks don't have to be duplicated there, anymore.
* Minor cleanup, mostly automatic whitespace.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33895 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 095a7d841532784712684844f93fa242017fae69 18-Oct-2009 Jérôme Duval <korli@users.berlios.de>

using chroot with a mount point wrongly exposed the mount point name: we now avoid resolving the volume root in case we hit the IO context root.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33645 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a9689e8492e520d532410c762bb3d5e3a5ac4819 30-Sep-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* VFS:
- Fixed vfs_get_vnode_from_fd() return type.
- Added vfs_open_vnode().
- Added a "bool traverseLeafLink" parameter to vfs_get_fs_node_from_path().
It was always resolving symlinks.
* device manager/devfs:
- devfs: get_node_for_path() no longer resolves leaf symlinks. That still
doesn't help with file disk devices, as creating partition wouldn't work
anyway.
- Pulled the module-related implementation part of BaseDevice into new class
AbstractModuleDevice and made all methods of BaseDevice virtual. Small
adjustments to devfs to be happy with the new BaseDevice interface.
- Added BaseDevice subclass FileDevice, which maps the interface to a file's
file descriptor. Still got a few TODOs, but should basically work.
- Use FileDevice for publishing file disk devices in devfs. Now those do
actually work, though there's some BFS trouble with one of the images I
tested.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33385 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a2bb34144733cba83af0ebd940df23802af2f237 01-Sep-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup, no functional change.

+ alphabranch


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32890 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7435db9ff0ca459441d8fe6f8b9eb64725de28e3 14-Aug-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* _user_read_dir(): Allocate a temporary heap buffer passed into the kernel
instead of using the user buffer. This frees the VFS and FS implementations
from handling user buffers.
* Adjusted fix_dirent() accordingly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32384 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 368fc35adf01677d4ca07c276fb58f4382fcf101 13-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Also have the uppper limit check in the assert.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32323 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 48cb56d8efa4b9d7e11948801de46d0275b473e8 13-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* We also shouldn't try to copy if the dirent is too large, obviously.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32314 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f9ba5c92e3db310ec7386d98784ac9b6beff175c 12-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Let fix_dirent() handle invalid reclen's gracefully.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32306 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a068dcb15a83460fe1bee5f8727af3ff12c66fe9 11-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* cdda_read_dir() could copy too many bytes into the provided buffer (worst
case was an unterminated string, though).
* fix_dirent() did not copy the trailing null-byte.
* Not yet entirely sure why, but this caused #4214.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32254 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7a6506e0fc86667de44a90a438838787a2fe6b3 06-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Replaced all "status < B_OK" with != B_OK - this should make the VFS layer
more robust against broken (userland) file systems.
* 80 character column cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32184 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 061d2ed1a2831e98270c30dec531a63b37251fd9 30-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* Creating a symlink now fails with B_NOT_SUPPORTED instead of
B_READ_ONLY_DEVICE if it has a write hook.
* This fixes bug #4141.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32004 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ae594ffd47d73edb1c9b9e1240a1ee667197472 28-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* Introduced dedicated syscalls for the deprecated BeOS fs_attr API. Before,
each attribute access needed 3 syscalls, now only one as it should.
* Renamed the new Haiku call fs_open_attr() to fs_fopen_attr(), and added a new
function fs_open_attr() that takes a path (same semantics as the
fs_[f]open_attr_dir() functions already present in BeOS).
* Merged former _kern_open_attr(), and _kern_create_attr() into one syscall.
* Cleaned up vfs.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31881 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5147963dcd57fefa4f63c484eb88e9eaf4002976 26-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

headers/private/kernel/util/OpenHashTable.h, Hugo's version, is a bit nicer than
Tracker's OpenHashTable.h which it should eventually replace. We've renamed the
class to BOpenHashTable and changed the interface slightly so that HashTableLink
became superfluous.
Adapted all the code that used it. Since the OpenHashTables no longer clash,
this should fix the GCC4 build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31791 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6def1a637b1ef1b915f87bb2fb015bd90559ff7f 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* In order to resolve mount points, fix_dirents() retrieved all vnodes from
disk; but since mount points are always kept in memory, it makes much more
sense to use lookup_vnode() instead.
* As a side effect, directory listings are no longer aborted when they contain
broken files that could not be retrieved anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31775 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 874f23496bbfc03fe82bb0340a0462446c5711c0 11-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Returning random stat data isn't really nice.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31010 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fa773c0ae535212b774a7f98d50cb6ece7b5d6c2 01-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

vnode_path_to_vnode(): Don't propagate the traverseLeafLink flag, if we've
decided to recursively resolve a symlink. We only have to do the resolution
when the flag is true anyway or the symlink is not the last component of
our path, in which case we have to resolve it anyway. Fixes #3986.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30937 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ce4db6ae11644d566396362274677bab3f9c516d 16-May-2009 Axel Dörfler <axeld@pinc-software.de>

* The covered vnode release was never put when it already was a mount point
during fs_mount(). This fixes bug #3934.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30773 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 78e7cdaedefec77f0b0d7cb145c34736c3553600 16-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Removed the get_next_removed_vnode() call again - besides the problems Ingo
pointed out, there is also an unsolvable race condition with BFS that other
file systems should share.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30204 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4e98292b8ee6eabfff9fd01a39e0aaf9da9a1fba 15-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Introduced new call get_next_removed_vnode() to be able to iterate over
removed but not yet deleted vnodes.
* Simplified get_vnode_removed().
* Header cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30176 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3cf43c26516b695e35b7433196a530f7541c4ca8 25-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed the fs_vnode_ops::create_dir() parameter for returning the ID of the
newly created dir. The VFS really doesn't need it and for some file systems
it might not be easy to get by. Several file systems (e.g. rootfs and fat)
were ignoring the parameter anyway.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29719 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c9bc3be3d9bdc347796afc45c4decfd6e08e112f 12-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup, no functional change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29480 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aa4ba93e25c1c63730ba69e04d3d96c3253924fd 08-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed src/system/kernel/device_manager/io_requests.{h,cpp} to
IORequest.{h,cpp}.
* Introduced public <io_requests.h> header. Currently it only declares the
single function BFS uses.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29446 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 43b2ca9108e66fb3f841f2c4fa102f83c6c5e5a0 02-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed wrong use of MutexLocker as pointed out by Korli - nice catch! This
could have caused a number of problems.
* Fixed coding style violation Ingo introduced.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29378 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5ecc4b37752beba35afeb7ef446f07c3c6d01971 01-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced ref-counting for the I/O contexts.
* The I/O context related vfs_*() functions have io_context* instead of void*
parameters/return values, now.
* vfs_new_io_context(): Lock the parent I/O context before getting its table
size. Otherwise the table size could change until we do.
* vfs_resize_fd_table(): Fixed use of MutexLocker. We created only a temporary
object, not one with function scope.
* Renamed load_image_etc() to load_image_internal() and added a parameter for
specifying the parent team of the one to create.
* Introduced a kernel private load_image_etc() with a few more arguments than
load_image().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29375 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f6d0017deab0036855f266cddaad5697577fabe9 28-Feb-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed duplicate parameter name.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29342 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2e47b62e2c49225cd4aa0478d453c48f5d5902f0 27-Feb-2009 Axel Dörfler <axeld@pinc-software.de>

* Consolidated '*' style.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29341 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ed3e5ec0311062fa5661aa1dead48533cc6477e3 27-Feb-2009 Axel Dörfler <axeld@pinc-software.de>

* zero_pages() did not fill in the _bytes parameter correctly - it returned how
many unclear bytes remained instead of how many were cleared. This caused
sparse files to show garbage instead of empty space. This fixes bug #2889.
* common_file_io_vec_pages() set "size" (size_t) from file_io_vecs::length
which is off_t without taking into account that important information could
be lost.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29339 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 63448c92a43a314d3cc7092c358888cff6270f06 23-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Better do the check for "." and ".." after stripping off superflous leafs as
otherwise a "rmdir ./" would still have caused the corruption.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29299 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 24a7f4c285b3ddaaf3761994d6524c1fb919d6bd 23-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Disallow removing the "." entry. We do the same for ".." already and it seems
to be in line with what other systems do as well. Also fixes bug #3476.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29296 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 77b26c3221eafb7a9209b072f0e264b74f325388 19-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

We need a longer filesystem string here to fit in all the possible layers.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29259 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49004dc730f842ea3c162b56dee63696c51d17c7 19-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Remove the additional fs_vnode_ops arugment from get_vnode() again as it's not
needed at all when used as intended. Thanks Ingo for the explanation on how this
is intended to work. Adjusted the overlay fs accordingly and updated/reverted
the changes to the other filesystems.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29250 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b1a58597b94bdc047e3587cf730577210db6aefb 18-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Add a new fs_volume op all_layers_mounted() that is called when all layers have
been mounted. This is to allow layered filesystems to setup internal data that
requires all the sub/super volumes to be available.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29248 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a26c24392042ca7bfad2e78f73a0b75c463c0455 14-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Adding volume ops to the overlay filesystem.
* Remove the previous method of applying the overlay by flags. In the future the
overlay can just be mounted as a filesystem layer. This is probably how layers
were intended to work in the first place.
* Move the filesystem module info and filesystem name from the fs_mount to the
fs_volume structure. Filesystem layering is done by having multiple layered
volumes and we want to be able to have a different fs per layer.
* Adapt VFS code to this move.
* Implement mounting layered filesystems. Specifying multiple filesystems
separated by a colon on mount will cause the layers to be set up and the
corresponding filesystems to be mounted at that layer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29199 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e5f12279dbc7d0fd20739c5c9d28545fddedcab 13-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Handle the overlay request flag in publish_vnode() as well.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 00405f2286fd370a0bd264d0bbac0cfa120e7646 09-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Add an additional argument to get_vnode() that gets the fs_vnode_ops of the
node. That is needed for a layered filesystem to be able to construct a full
fs_vnode out of a volume/inode pair.
* Adapt places where get_vnode is used. Sadly this is a C API and we can't just
use a default NULL for that argument.
* Introduce a flag B_VNODE_WANTS_OVERLAY_SUB_NODE that can be returned in the
flags field of a fs get_vnode call. A filesystem can use this flag to indicate
that it doesn't support the full set of fs features (attributes, write support)
and it'd like to have unsupported calls emulated by an overlay sub node.
* Add a perliminary overlay filesystem that emulates file attributes using files
on a filesystem where attributes aren't supported. It does currently only
support reading attributes/attribute directories though. All other calls are
just passed through to the super filesystem.
* Adjust places where a HAS_FS_CALL() is taken as a guarantee that the operation
is supported. For the overlay filesystem we may later return a B_UNSUPPORTED,
so make sure that in that case proper fallback options are taken.
* Make the iso9660 filesystem request overlay sub nodes. This can be fine tuned
later to only trigger where there are features on a CD that need emulation
at all.

If you happened to know the attribute file format and location you could build
an iso with read-only attribute support now. Note that this won't be enough to
get a bootable iso-only image as the query and index support is yet missing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29177 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c33667d400856680a8e0122300861eda77d1847a 01-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Fixing warnings under GCC4 in preparation to enable -Werror there as well:
* Replaced the use of offsetof() for structs that aren't PODs. Add a
offset_of_member() macro to util/khash.h because that's what it's used for
in our cases.
* Change the signature of add_debugger_command()/remove_debugger_command() on
GCC > 2 to avoid the depricated conversion from string constants to char *.
* Adding some "suggested" parenthesis. I know that not everyone likes that, but
it pointed out at least one bug that is fixed here as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29113 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f58d8cf2352699bd7c43294a82f7867c1ff73180 11-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* _user_flock() will no longer accept invalid operations, thus fixing bug #3141.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28889 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fbb7d4cd578af1cf098cbefa182537aa4585b82d 11-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* fs_write() is optional for read-only file systems. This fixes bug #3062 and
also #3083 (although I could not reproduce the latter).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28881 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6a90578f76470cc34c64494b1fe1bb69b7cda842 06-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* Removed a left-over mutex_unlock() that could cause a panic on removing
a busy vnode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28851 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5500d8a54f5db24d94e12019020d7ee26872efc7 06-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* All file descriptors that only refer to a mount now keep the mount, ie. they
won't call put_mount() before they are freed. Internally, this causes them
to grab a reference to the mount's root vnode.
* This fixes bug #3262.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28850 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 55ddbd7bca54878d861861e82c0c5a0d196c1b85 13-Nov-2008 Axel Dörfler <axeld@pinc-software.de>

* When a file system reports -1 offsets in its fs_get_file_map() function, this
will now accepted and regarded as sparse file data. FileMap::_Add() also
correctly joins multiple vecs with that offset together, FileMap::Translate()
will always report offset -1 even for offsets into that extent.
* read_file_io_vec_pages() (or rather, its backend common_file_io_vec_pages())
now supports sparse files, and will just clear the memory it should read from
offset -1 instead of passing a request to the vnode.
* ext2 now correctly reports sparse files. This should close bug #2889, as well
as #975.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28648 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7e621f16d0362cf81b58c63600781074c4fb25db 05-Nov-2008 Axel Dörfler <axeld@pinc-software.de>

* Use parse_expression() for argument parsing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28515 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 67804f25edcff8690f7ec142d8b0ba7702bfd5e5 27-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* fs_unmount() removed the vnodes of the fs_mount twice since r28215,
triggering an assert.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28344 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e967b93ab6f8d6fe27f8ca02123c39bc396b143d 26-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* vfs_stat_node_ref(): Added missing initialization of
stat::st_{dev,ino}.
* stat::st_rdev is unused, but at least initialize it with some
deterministing value. This makes Perl's lib/File/stat.t test happy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28333 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1894a0a98b5b2102f83c00b7273ba7654334f469 20-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Consistently use KDEBUG. It is always defined and therefore must be
checked with "#if".


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28247 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3b839d857b4bc92bde6faaa3a5db31398a4f2882 18-Oct-2008 Michael Lotz <mmlr@mlotz.ch>

The fs_mount structure now has a constructor/destructor and is used with new and
delete. Therefore the constructor/destructor of the contained EntryCache is also
called. The manual call of the destructor to the OpenHashTable inside the
EntryCache was therefore superflous and the destructor would be called twice,
leading to bug #2869.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28232 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 703aecaaa5c3b4a2df2cc80bf2bc2ad0a2287ab2 17-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Instead of having the mount_link, struct vnode now subclasses from
DoublyLinkedListLinkImpl, and fs_mount now uses a DoublyLinkedList instead
of a typeless struct list.
* Also added a constructor/destructor to fs_mount which simplifies and cleans
some code.
* This should not contain any functional changes :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28215 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 552c8edcd1a23c7106bd3976af7f2034078f995a 17-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* fs_sync() now holds the sVnodeMutex while iterating over the mount list.
* This has the advantage that we no longer need to call get_vnode(), and
instead can use lookup_vnode().
* This means at least most of the "corrupted BFS inode" messages should be
gone; they were produced when fs_sync() tried to get already deleted vnodes.
This was actually harmless, but doesn't really help in trusting your system :-)
* Also, it no longer tries to write back removed vnodes.
* And finally, it now uses a marker vnode when iterating over the list, so
that it doesn't need to break out of the loop anymore, and can always sync
all willing vnodes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28212 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e8d3eff9689f3436efa2863b9bf4afc84f79e0a3 26-Sep-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* vfs_normalize_path() and _user_normalize_path() use a common helper
function (normalize_path()), now. There was some code duplication
before.
* Added "bool traverseLink" parameter to vfs_normalize_path(). When
true and the leaf component is a symlink, it will be resolved.
* KPath:
- Added similar leaf link traversal parameter to SetTo() and
SetPath().
- Added Normalize().
- Added DetachBuffer(), which returns the object's current buffer and
unsets itself.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27751 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ee1a1571a21825526da904634316649f06647268 07-Sep-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Implemented a simple directory entry cache to speed up path resolution.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27366 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2aa5367afbbc2eb2edc35ed08df16d67407bf7a4 24-Aug-2008 Jérôme Duval <korli@users.berlios.de>

extended debug check for FS_CALL() to others FS_CALL() versions


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27189 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8cf7754bc7c786a958e86bc35bee36c2b74ff5bf 24-Aug-2008 Jérôme Duval <korli@users.berlios.de>

added a check in FS_CALL() for null hooks in KDEBUG mode


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27188 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2fd4fdcf3b0512c880033f4027941440fce93629 22-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Changed the way fix_dirent() copies the entry: it will now copy the complete
dirent without the name first, and will then check if the d_reclen member
is valid before copying the name.
* This shows the problem with the FAT file system that was revealed by r26859.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27128 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a3afb5ee0dab808bb0157f6d366b2852917267d1 09-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Handy on-demand debug tracing, I've used a few times already. So I leave
it commented out in the code for the time being.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26907 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49a7b6198dcc0bdcbe285b078a4c98f7a9a6d554 07-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* fix_dirent() now correctly handles buffers from userland.
* dir_read() now takes into account that we may have read more than one dir
entry, and calls fix_dirent() for each of them.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26859 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 58306fecd6c5645210f041ae4d88abe56016f841 02-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added tracing for vfs_{read,write}_pages).
* {read,write}_pages() use vfs_{read,write}_pages() now, instead of
invoking the FS {read,write}_pages() hooks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26750 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 15374c5dbdb2c6b700bb2191887cadad7ef9eb73 02-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Renamed thread_spinlock and team_spinlock to gThreadSpinlock and
gTeamSpinlock.
* Renamed the static global variables in smp.c to match our style guide.
* Minor other cleanup.
* Removed superfluous white space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26730 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9f6ae76f020cd6cf1fca7a3ae21ee7819581307d 01-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Added acquire_vnode() call that you can use to get another reference to an
inode - unlike get_vnode() the busy flag won't prevent you from getting that
reference.
* Changed put_vnode() to return an error in case the vnode couldn't be found.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26713 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7f12cc54a729622cd04940ee9400958413d99b21 30-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* It is now supported that I/O operations and requests are only handled
partially (e.g. due to hitting the end of file). The respective
classes have grown new methods and attributes to deal with that. The
"finished" callbacks have got additional parameters to indicate
whether the transfer was only partial and how much has been
transferred. Other callbacks and functions have a size_t* in/out
parameter instead of a simple size_t, now.
* vfs_{read,write}_pages() do now use the I/O request framework instead
of the underlying FS's {read,write}_pages() hooks (those should be
unused now). Furthermore they've got an additional "flags" parameter,
which is passed to IORequest::Init(), i.e. it allows to specify that
the given vecs refer to physical addresses.
* The file cache's read_into_cache() reads directly into physical
pages, now.
* Fixed bug in DoIO::IO(): The offset was not adjusted, so that all
pages were incorrectly transferred from/to the same location.
* Fixed broken subrequest scheduling loop head in
do_iterative_fd_io_iterate().
* Adjusted the test driver and implemented its io() hook. Using this
driver I/O requests are passed all the way from the VFS/VM to the
driver and through the I/O scheduler. It even seems to work. :-)
* Added missing const to the iovec* parameter of the IORequest::Init()
methods.
* Disabled some debug output by default. Added new optional debug
output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26692 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7df40c23f6259559b97604ba66d0384311c51e0b 28-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added handy function volume_for_vnode() which returns the fs_volume for
a given given fs_vnode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26669 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ec598fe493579e3d522453cb407ca3c6b57d715a 27-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added FS interface hooks io() and cancel_io(). The former is supposed
to provide asynchrounous (or only synchronous, if asynchronous is not
supported) I/O request support. It will eventually replace
{read,write}_pages(). None of the FS implementations implement them
yet.
* Implemented some support functions for request-based I/O. File system
implementations can use do_fd_io() which passes an I/O request to the
layer responsible for a given FD, and do_iterative_fd_io(), which
translates a request for a file to subrequests for the underlying
device and passes them on. Both fall back to synchrounous processing
when the io() hook is not supported.
Furthermore added vfs_synchronous_io() which should be handy for the
devfs to perform io_requests synchronously for devices that don't
support the io() hook.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26655 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ef7fb431edae5dce89a52bdc822a6bdbc104cf80 23-Jul-2008 Rene Gollent <anevilyak@gmail.com>

Remove extraneous put_vnode(). This would result in decrementing the vnode ref count even if an unmount operation failed, which in turn would cause other fun problems. This fixes tickets 1982 and 2538. However, there seems to be another problem remaining with unmounting: the placeholder dir in the rootfs is not removed when the volume is unmounted, or it's not reused correctly. As a consequence, on subsequent remounts of the same volume via Tracker or mountvolume, a new dir is created each time, leaving empty placeholders. (i.e. remounting the volume HaikuData results in the creation of /HaikuData1, 2, 3, 4, etc.).



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26586 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e6bd90c58dbae64f3b464edcff90dcb06e63a716 23-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* bfs_fsync() was the only place which could cause the
fs_vnode_ops::write_pages() to be called with fsReenter = true. Since
this is no longer the case, the argument has become superfluous. For
read_pages() it always was. Removed the argument from the functions
and all functions that propagated it.
* Some whitespace at the end of lines was removed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26579 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5c99d639708df9b4e2cc847b38d510149d19ec78 22-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged branch haiku/branches/developer/bonefish/vm into trunk. This
introduces the following relevant changes:
* VMCache:
- Renamed vm_cache to VMCache, merged it with vm_store and made it a
C++ class with virtual methods (replacing the store operations).
Turned the different store implementations into subclasses.
- Introduced MergeStore() callback, changed semantics of Commit().
- Changed locking and referencing semantics. A reference can only be
acquired/released with the cache locked. An unreferenced cache is
deleted and a mergeable cache merged when it is unlocked. This
removes the "busy" state of a cache and simplifies the page fault
code.
* Added VMAnonymousCache, which will implement swap support (work by
Zhao Shuai). It is not integrated and used yet, though.
* Enabled the mutex/recursive lock holder asserts.
* Fixed DoublyLinkedList::Swap().
* Generalized the low memory handler to a low resource handler. And made
semaphores and reserved memory handled resources. Made
vm_try_resource_memory() optionally wait (with timeout), and used that
feature to reserve memory for areas.
...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26572 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 541959e00aa2b8b1a9314c54f8ee152a3b93136a 17-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

Add (not really necessary) locking of the sMountMutex in case of KDEBUG to keep the assert in find_mount() happy.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26484 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 60f2ef17be7b98a2a30b95e6a7a33a2bde8e17e5 12-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added "partition_id partition" field to fs_volume, so that file
systems can get the partition they reside on easily.
* Updated TODO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26401 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 92c3ae2b69a016d7d51a3a1f487db72820489236 06-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Reverted r26293 again, as that "subtle" change also prevented any device I/O
from happening...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26294 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bed8516accd200d631e927343b17c02ea2f8854f 06-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* file_{read|write}() now only accept regular files, and will return either
B_BAD_VALUE or B_IS_A_DIRECTORY depending on the vnode type.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26293 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 469c26e73880c5da6d98e50460b6789fe89a35a9 06-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Since we now have a vnode::type field, several calls of read_stat() were no
longer necessary.
* Optimized file_seek() using this field, too; reading the stat is now only done
when necessary.
* file_read() and file_write() will now return B_IS_A_DIRECTORY so that not
every file system has to care about that particular error code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26292 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52ecda6ecfe4c9710969c0ece73e267bb4702df9 06-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Added some optional KDL command and statistics to the file map implementation.
* Turned them on for now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26291 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a8f9741c8c2815234e87b78167738057b976b537 04-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

* Removed -Wno-unused from all KernelMergeObjects in kernel Jamfiles.
* Fixed most of the warnings resulting from that by removing actually not used
variables or moving declaration into the #IF. Left unused functions there
though, as I wouldn't know if they are supposed to be used again.
* Fixed two statements with no effect (clamping to MAX_ANCILLARY_DATA_LEN in
socket.cpp and unsetting fCounterSem in MessagingService.cpp).
* Some style cleanups.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26253 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e1b630c55d9d0c25aef812efc9c2410f5ba53456 28-Jun-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced the global cache pages hash table by an IteratableSplayTree
per cache.
* Changed the strategy vm_cache_acquire_page_cache_ref() uses to ensure
that the cache isn't deleted while trying to get a reference. Instead
of the global cache pages hash table lock, it holds the global cache
list lock now. We acquire + release this lock in delete_cache() after
removing all pages and just before deleting the object.
* Some small optimizations using the property that the cache's pages are
ordered, now (vm_cache_resize(), vm_page_write_modified_page_range(),
vm_page_schedule_write_page_range()).
* Replaced some code counting a cache's pages by simply using
vm_cache::page_count.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26160 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 285b754fa76b51ebda5df7f3757a77d282ffd04f 24-Jun-2008 Axel Dörfler <axeld@pinc-software.de>

* dec_vnode_ref_count() can now also directly free the vnode if requested
(and if it isn't used anymore).
* vnode_low_memory_handler() now just calls it this way, so it doesn't have
to use two passes anymore, and can always write back vnodes without having
the busy flag set.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26124 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f5b3a6a7968b849c8cb3d06ffe6d19acccf910a8 05-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

* Initialize all static mutexes in the kernel through a MUTEX_INITIALIZER()
and remove the then unneeded mutex_init() for them.
* Remove the workaround for allowing uninitialized mutexes on kernel startup.
As they are all initialized statically through the MUTEX_INITIALIZER() now
this is not needed anymore.
* An uninitialized mutex will now cause a panic when used to find possibly
remaining cases.
* Remove now unnecessary driver_settings_init_post_sem() function.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25812 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 032f1e5f90adbf6b08f83d746a19d440b01180a5 01-Jun-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed an endless loop when using vfs_get_vnode_name() or the "wrong"
get_vnode_name() variant.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25750 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3cec30848cffa7709d0373f2053e4dc8467fea29 30-May-2008 Michael Lotz <mmlr@mlotz.ch>

Fix build with TRACE_VFS enabled and also fix a warning.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25726 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b0f5179aa51eb680cdeea656a8b11fdbc6b56d63 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed recursive_lock to use a mutex instead of a semaphore.
* Adjusted code using recursive locks respectively. The initialization
cannot fail anymore, and it is possible to use recursive locks in the
early boot process (even uninitialized, if in BSS), which simplifies
things a little.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25687 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1e18692e122a93b77376365bb5eff71bea765c84 26-May-2008 Axel Dörfler <axeld@pinc-software.de>

* get_vnode() now accepts a NULL parameter for the fsNode argument.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25660 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c44fb2a62c7ed7a6eea933260af3a32dfe87e51f 09-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Advisory locking fixes:
* Made the access strategy to vnode::advisory_locking consistent.
get_advisory_locking() was guarding it with sVnodeMutex,
create_advisory_locking() was using atomic_pointer_test_and_set(), and
release_advisory_lock() just set it unguardedly. We do use sVnodeMutex
consequently, now.
* Beautified create_advisory_locking() (got rid of the gotos,
reorganized the control flow).
* Fixed race conditions in acquire_advisory_lock(). It was always
unlocking and relocking the advisory_locking object when it didn't
have to wait, but in the meantime someone else could have changed the
locking situation. Reorganized the control flow, so that it only drops
the lock when it has to fail or wait. Using create_advisory_locking()
upfront simplifies the code quite a bit (and fixes another race
condition).

APR's testprocmutex test seems happy now, at least.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25407 a95241bf-73f2-0310-859d-f6bbb57e9c96


# adf376c941e3af8381aa890be77a2c6f66795639 08-May-2008 Axel Dörfler <axeld@pinc-software.de>

Replaced benaphores with mutexes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25378 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0c615a01ae49634aaf59fbe35b3d55b3bb8890df 01-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed old mutex implementation and renamed cutex to mutex.
* Trivial adjustments of code using mutexes. Mostly removing the
mutex_init() return value check.
* Added mutex_lock_threads_locked(), which is called with the threads
spinlock being held. The spinlock is released while waiting, of
course. This function is useful in cases where the existence of the
mutex object is ensured by holding the threads spinlock.
* Changed the two instances in the VFS code where an IO context of
another team needs to be locked to use mutex_lock_threads_locked().
Before it required a semaphore-based mutex implementation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25283 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 503912f7334fcae435933c024ba2b413a61903ad 30-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed the case that a file to be created non-exclusively is a symlink
(bug #2183).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25271 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 24280972976f3e70bd4357b646a3647e1c4fa131 29-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed superfluous uint32 ref parameter from select() FS hook.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25268 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b1d749f8f1d17830c8f24d49a21cdba1e174a0b0 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Added an atomic.h header that provides a C++ file with a templatized
64-bit safe version of atomic_test_and_set() for pointers:
atomic_pointer_test_and_set().
* The VFS is now using this function (it's not used anywhere else in the
kernel this way).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25260 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bbc25eb65048ae278bb2a955e8e86353ecff9a27 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Renamed temporary KDL variable from _cookie to _volume in the "mount"
command.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25251 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f8a2f7ce58808a6c1f31c9c1231c50580d236d60 25-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* attribute dirs shouldn't be locked out either; I've inverted the type check,
so that it now only checks for the type that allow locking.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25168 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d81dcabe8edda69c379e99c6917bd75f44dff1e9 25-Apr-2008 Bruno G. Albuquerque <bga@bug-br.org.br>

FS gurus, please review.

- get_new_fd() now checks if we are dealing with attributes before deciding to
bail out on a locked vnode.
- Enabled locking in MailSettings again as it now works.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25162 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0951fcb4a3c14b8f25ba751c300cda08216f5e12 24-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

vfs_create_special_node() always tried to create the node in "/".


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25139 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3118b3a7cbf56fb77ab7ceb02eae609a664c6d6f 11-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added fd_ops::set_flags() hook. It's only implemented by socket FDs
ATM.
* Changed common_fcntl() to also work for non-vnode-based FDs. Only the
operations that require a vnode do fail now. F_SETFL uses the new
fd_ops::set_flags() if available, falling back to the vnode respective
operation.
* Changed some direct accesses to file_descriptor::u::vnode. It was safe
in those cases, but might not be anymore if we ever change fd_vnode().

ftp can at least connect to servers again, now, but apparently we still
have a problem with syscall restarts -- downloads fail after one second,
when the timer goes off.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24917 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ac0e5c1ce5073978eb18ad75c112b6b9b4749ce7 11-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

The fs_sync() function (or any other, for that matter) must not hold the
sMountMutex lock when calling sync() on a file system. This fixes a potential
deadlock (I just encountered for the first time).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24915 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9493edbe9f0597da4585c2d9494976642d36de97 11-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

Applied patch by Christian Fasshauer:
* get_dir_path_and_leaf() now removes trailing slashes from the path.
* This fixes bug #2016, thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24913 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0fc6c43728b4223095fe258b32156fcacbfd6deb 10-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Resolved TODO: We can check for sockets, now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24906 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f8b4d83f2f310c288d3ba32c6371fb00ae2b4824 09-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

New service function vfs_create_special_node() to create special nodes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24883 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 037f70947f14b7e7d452543ad645f38d7c96f6eb 09-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Cleaned up KernelExport.h completely, removed deprecated and non implemented
API, uses the _PRINTFLIKE macro where appropriate.
* Got rid of the "qent" structure, struct timer now contains everything we
need. This makes the affected code in sem.cpp, signal.cpp, and timer.c much
cleaner, and resolves a few TODOs.
* Minor cleanup in vfs.cpp.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24871 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fc380199455ea67c8ed9b65b34e20b91133cfbb9 06-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Rename vfs_stat_entry_ref() to vfs_stat_node_ref() as that's what a dev_t and
ino_t combination really is.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24825 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e36a49e62cbad57eb5c88dd1a16ca39be3f4e3f 05-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added _kern_create_pipe() syscall, creating a pipe as an entryless
FIFO. Reimplemented pipe() to use it.
* pipefs is no longer mounted. Will remove the superfluous code soon.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24823 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 717705d81694d6cfdece53fd6a2396422e32938c 05-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

We get a reference to the node from create_special_node(), so we have to
release it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24817 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7ffafac8d76aa50ea68667e61038022220a90256 05-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reorganized the FS interface a little:
- Moved most file_system_module_info hooks into separate structures.
Those that operate on mounted volumes to fs_volume_ops, those
operating on a vnode to fs_vnode_ops.
- Got rid of the fs_volume, fs_cookie, fs_vnode typedefs. We use void*
again.
- Instead of a void* volume and node cookie hooks are passed a
fs_volume and fs_vnode structure pointer, which contain the cookie
and an ops pointer (fs_volume a few more things).
- The VFS {new,publish,get,...}_vnode() functions take a fs_volume*
instead of the volume ID. So does vfs_get_fs_node_from_path().
- Added type and flags arguments to publish_vnode() and the
get_vnode() hook and removed the type argument from lookup() hook.
Added vnode::type using formerly unused bits to store the node type.
Simplified a few things in the VFS due to the now always available
node type.
- Added fs_volume_ops::{create,delete}_sub_vnode() and
fs_vnode_ops::get_super_vnode() hooks. They are used to support file
system layers, e.g. allowing to extend an FS not supporting BeOS
attribute with attribute support. Needs some more work in the VFS.
- Added fs_vnode_ops::create_special_node() hook for creating special
nodes (e.g. FIFOs).
* Adjusted the built-in file systems and BFS according to the interface
changes. Removed all other FSs from the image for the time being.
We'll see whether further API changes are necessary before porting
them.
* Adjusted the bfs_shell accordingly.
* Implemented create_special_node() in rootfs to support special nodes.
* Added support for FIFOs:
- Added syscall _kern_create_fifo() (used by mkfifo()), which creates
a special node (type S_IFIFO) in the respective file system.
- When a special node is published the VFS creates a respective sub
node. Currently only FIFOs are supported.
- Added a little support for FIFO subnodes by using functionality from
the pipefs.
- Added mkfifo to the image. It can create FIFOs in the rootfs, but
the FIFOs aren't really usable ATM, since they still work like
pipes, i.e. readers and writers need to have them open at the same
time.
* Some smaller changes in the VFS:
- Made the *_CALL macros nicer to use (vargs).
- Refactored FS entry lookup into new function lookup_dir_entry().
- create_vnode() no longer just calls the FS create() hook. First it
looks up the entry and uses open_vnode(), if it already exists. This
is necessary for two reasons: 1) The FS might not support create()
while still allowing to open() entries. 2) When the FS has other
layers on to of it (or the respective node) it might not be
responsible for opening the node.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24816 a95241bf-73f2-0310-859d-f6bbb57e9c96


# efb965d5596e99bc2d3bd0cb6c7ee6c4a81a2637 05-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Introduce vfs_stat_entry_ref() that allows to stat a vnode based on a dev_t
and ino_t instead of a path. Supposed to work with node monitoring messages.
Took the name from vfs_entry_ref_to_path() that takes the same arguments, but
suggestions for a better name are welcome.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24813 a95241bf-73f2-0310-859d-f6bbb57e9c96


# de73100825d330c9be828c508dd64d4d31cb6a2e 01-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Also check whether the supplied vnode is a directory, if there's only
one path component.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24736 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0cc0b6fc8f3451e7e793980e2a3035675805ade8 01-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed resolution of symlinks path components, broken since
r24721/r24722. After resolving a symlink we weren't updating the local
type variable to the type of the link target, so that the directory
check in the next iteration would always fail.
* Added TODO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24735 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b987779d7f78748a257ede83116c7f121eebd5df 01-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

Revised my previous patch as outlined in the previous one:
* No longer checks for the path delimiter twice.
* Now also checks if the first part of the path is a directory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24722 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6800e4f8ba370bc79df266a086200a1474ecb581 01-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

Reverted r24720, and at least fixed the problematic return code after the
first loop - the vnode passed in would still need to be checked, though.
Eventually, it would be nice to move the check to the top, though, so that
we don't need to search for the patch delimiter twice.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24721 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b48c7f231ad09efc25d71a18a824f5bfa09618a4 01-Apr-2008 Bruno G. Albuquerque <bga@bug-br.org.br>

- vnode_path_to_vnode() now returns B_NOT_A_DIRECTORY instead of B_NOT_ALLOWED
as expected by POSIX programs. This allowed be to compile Haiku under itself
without any hacks at all, so I guess this means that now we are officially
self-hosting!



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24720 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 360be1fc45416df27312c38d2268b466621bbae7 29-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Implemented support for chroot:
- Added a "root" vnode to the io_context. It is used for resolving
paths and converting nodes to paths instead of sRoot. Some more
passing around of io_context structures was necessary.
- Introduced a new lock sIOContextRootLock to protect
io_context::root. The current uses of io_context::io_mutex
(put_vnode(), remove_vnode() while holding it) looked too suspicious
to use that mutex in vnode_path_to_vnode().
- Added _kern_change_root() syscall and chroot() libroot function.
- Added chroot coreutils program to the image. Funnily it seems to be
much easier to set up a little jail than under Linux (just copy
bash and libroot.so into respective subdirs; mount another pipefs
if you want pipe support).
With Haiku allowing direct access to directories via inode IDs
jailing is obviously not very secure at the moment.
- Added /var/empty to the image. It will be the chroot target for ssh.
* Changed vfs.cpp:get_cwd() so that the io_context::io_mutex is no
longer held when calling dir_vnode_to_path().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24673 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c117a6d887caefe7aacdddb08bb6557d100f106 29-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added function vfs_read_stat() that also allows for stat()ing files in
the user IO context from within the kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24667 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9e79133f4d76f11f86241a0e841c03e1487f3c6c 27-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Reverted r22315 as far as free_vnode() is concerned: removing the
vnode from the hash before putting it caused all sorts of problems.
* For example, BFS would trim its preallocations when the vnode is put;
if someone would read that same vnode after it had been removed, but
before BFS could trim it, it would read the old vnode which still
seemed to own the blocks which would subsequently be freed.
* This fixes bug #1914, and should also fix bug #1956.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24607 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e9d948ce2df288e048f88f344025957bc80ff1c3 18-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* entry_ref_to_vnode() now gets a "traverse" argument, so that it is
able to resolve symlinks.
* file_open_entry_ref() now evaluates the openMode and passes the
correct "traverse" argument to entry_ref_to_vnode(). This fixes bug
#1932 (symlink refs wouldn't be resolved).
* dir_open_entry_ref() now always resolves symlinks, all other uses of
entry_ref_to_vnode() keep their previous behaviour, though.
* Fixed warnings; since Ingo's header changes, NULL now causes a warning
when it is used as int.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24442 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1b32947d3f6c19dc1716a27d50361dcf59c27882 17-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Aligned the semantics of the read_symlink() FS module hook with the
readlink() function. It is no longer required to null-terminate the
string, shall not fail, if the buffer is too small, and shall return
the length of the string actually written into the buffer.
* Adjusted rootfs, devfs, and bfs accordingly. Also adjusted their
read_stat() hooks to return the correct symlink length in st_size.
* Our readlink() does now comply to the standard (and BeOS).
Additionally if the buffer is big enough it is nice to non-conforming
apps and null-terminates it.
* BSymLink::ReadLink() explicitly null-terminates the string now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24425 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f542307a9887b9cc5c2a6c0e6aa8c9795ebdce45 09-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

We didn't copy the close-on-exec flags on fork(), thus always leaving
all FDs in a fork()+exec()ed child open. Makes Perl test
t/run/cloexec.t pass.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24336 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3f89bce410469ee2c3c7f65f47423c5671ed43d2 09-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* The module code now uses find_directory() and no hard-coded paths anymore.
* It now also supports the common directory path.
* search_module() checked the module paths in the wrong order, ie. it preferred
modules in the system directory over the user directory.
* Clarified comment in vfs_get_module_path().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24323 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fa28330bbf9d39c01ad3016a777bedaa5960eedb 09-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Explained under which circumstances vnode_path_to_vnode() will clobber the
buffer of the provided "path" argument.
* Applied patch by Vasilis to fix some warnings when build on Linux (missing
const on certain functions). We should probably fix the original
{add|remove}_debugger_command() functions in Haiku as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24322 a95241bf-73f2-0310-859d-f6bbb57e9c96


# daa6f66e11da97a634ee103f74e742da9c4a5f78 04-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24236 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0c415f6265d58c8cf07307e6742e4b42a64f2eee 27-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

"leaf" may be NULL, fixed crashing bug I introduced with
vfs_entry_ref_to_path().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24154 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4f26630d823fe7367a7ba80563779546204de671 27-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Factored a vfs_entry_ref_to_path() out of _user_entry_ref_to_path()
and made it public (within the kernel).
* _user_entry_ref_to_path() is now using that function.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24151 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 849246ba7741fbf9f8b59ea76013917205094e69 19-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

Improved (and tested) the advisory file locking mechanism a bit:
* our flock::l_len was inclusive, while it's exclusive (the last byte locked
is (l_start - 1 + l_len) not just (l_start + l_len).
* F_UNLCK removes all locks of the calling process that are within the specified
region - existing locks might also cut or divided.
* Apparently, a single team can lock the same region as often as it wants.
* advisory_locking is now using a DoublyLinkedList instead of its C counterpart.
* advisory_lock now has start + end fields, instead of offset + len, it's
handier this way.
* This fixes bug #1791.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24020 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4048494ce44a925d3d1e40e4ffb9abe670b4b827 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
* Implemented automatic syscall restarts:
- A syscall can indicate that it has been interrupted and can be
restarted by setting a respective bit in thread::flags. It can
store parameters it wants to be preserved for the restart in
thread::syscall_restart::parameters. Another thread::flags bit
indicates whether it has been restarted.
- handle_signals() clears the restart flag, if the handled signal
has a handler function installed and SA_RESTART is not set. Another
thread flag (THREAD_FLAGS_DONT_RESTART_SYSCALL) can prevent syscalls
from being restarted, even if they could be (not used yet, but we
might want to use it in resume_thread(), so that we stay
behaviorally compatible with BeOS).
- The architecture specific syscall handler restarts the syscall, if
the restart flag is set. Implemented for x86 only.
- Added some support functions in the private <syscall_restart.h> to
simplify the syscall restart code in the syscalls.
- Adjusted all syscalls that can potentially be restarted accordingly.
- _user_ioctl() sets new thread flag THREAD_FLAGS_IOCTL_SYSCALL while
calling the underlying FS's/driver's hook, so that syscall restarts
can also be supported there.
* thread_at_kernel_exit() invokes handle_signals() in a loop now, as
long as the latter indicates that the thread shall be suspended, so
that after waking up signals received in the meantime will be handled
before the thread returns to userland. Adjusted handle_signals()
accordingly -- when encountering a suspending signal we don't check
for further signals.
* Fixed sigsuspend(): Suspending the thread and rescheduling doesn't
result in the correct behavior. Instead we employ a temporary
condition variable and interruptably wait on it. The POSIX test
suite test passes, now.
* Made the switch_sem[_etc]() behavior on interruption consistent.
Depending on when the signal arrived (before the call or when already
waiting) the first semaphore would or wouldn't be released. Now we
consistently release it.
* Refactored _user_{read,write}[v]() syscalls. Use a common function for
either pair. The iovec version doesn't fail anymore, if anything could
be read/written at all. It also checks whether a complete vector
could be read/written, so that we won't skip data, if the underlying
FS/driver couldn't read/write more ATM.
* Some refactoring in the x86 syscall handler: The int 99 and sysenter
handlers use a common subroutine to avoid code duplication.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23983 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4af8877673574aa1b9d4150fc7addbc2d2f019a1 17-Feb-2008 Marcus Overhagen <marcusoverhagen@gmail.com>

build fix for r23929


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23982 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9ae93dcd7fa2b673f5f6c8e5488a547350fe3e2f 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

_user_normalize_path() was broken for symlinks in absolute paths.
Fixes #1778.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23969 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2c986936dfb7ff4f5723641b100d280a44dda479 07-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added new syscall _kern_normalize_path() to normalize a path.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a32a4683ff8eb994524d5ab8eba13d93fe90c0ff 03-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* Implemented flock() semantics to the advisory locking backend. Not tested
(must also compare to BSD; I've looked at their sources, but I might have
missed something).
* Added sys/file.h and the flock() system call.
* common_fcntl() could forget to put back the file descriptor on some error
conditions (I guess we should introduce and use a DescriptorGetter class).
* Cleaned up fcntl.h, moved the BSD extensions S_IREAD and S_IWRITE to
sys/stat.h where they belong, and added the missing S_IEXEC to them.
* Added some more comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23836 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 731262c6dd0752b72ee2353d678edde643bf9daf 21-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Rethought fs_sync(): since we no longer deadlock when calling
vm_cache_write_modified() here anymore since quite some time, it actually
doesn't make any sense to call the file system's "fsync" method here.
This should make syncing all file systems much faster when many vnodes are
in use.
* If a file system doesn't use the file cache, it can still just sync everything
it needs to in its "sync" method.
* Added a TODO item on how to improve sync speed further, if necessary.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23679 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b9074efcb78d914f902047cc8410532d42ce7bbb 16-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed the "vnodes" KDL command when called without any arguments.
* Fixed the usage text of the "help" KDL command.
* Made the "ambiguous command" warning shorter, so that it will still fit in
the exception buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23565 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dd80f32ac37f32193ff302a2358eb003acb8d51a 16-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Added support for the "--help" argument for all VFS debugger commands.
* Added some temporary variables to the commands.
* Use parse_expression() where appropriate.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23556 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2eceeabaea5b72d200067b7d25e610c29ee329ea 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Fix comment.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23466 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0fc976d9003f9e61913cf2eb648dfd59bc1e9b41 12-Jan-2008 Ithamar R. Adema <ithamar.adema@team-embedded.nl>

Fix problem with CLOEXEC also being handled on fork(). For details on expected (BeOS) behaviour, see http://www.freelists.org/archives/openbeos/12-2001/msg00280.html

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23456 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f3ecf93d37877f5c7bf4f4298ed011ae84e86e89 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Added the cookie/private_node fields to the mounts/vnodes list in KDL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23455 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a52c1759ac6f899186a557ba6ae0f27468a3ad8b 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Fixed two bugs in the vnode disconnecting code found by bonefish+mmlr:
* vfs_disconnect_vnode() did not put away its vnode reference.
* disconnect_mount_or_vnode_fds() did always throw the current working
directory of all apps on the same mount away, even if only a specific
vnode should have been disconnected.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23445 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 34b3b26b3b8c46ba46ddde037b10dd173f4936d6 10-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged branch haiku/branches/developer/bonefish/optimization revision
23139 into trunk, with roughly the following changes (for details svn
log the branch):
* The int 99 syscall handler is now fully in assembly.
* Added a sysenter/sysexit handler and use it on Pentiums that support
it (via commpage).
* Got rid of i386_handle_trap(). A bit of functionality was moved into
the assembly handler which now uses a jump table to call C functions
handling the respective interrupt.
* Some optimizations to get user debugger support code out of the
interrupt handling path.
* Introduced a thread::flags fields which allows to skip handling of
rare events (signals, user debug enabling/disabling) on the
common interrupt handling path.
* Got rid of the explicit iframe stack. The iframes can still be
retrieved by iterating through the stack frames.
* Made the commpage an architecture independent feature. It's used for
the real time data stuff (instead of creating a separate area).
* The x86 CPU modules can now provide processor optimized versions for
common functions (currently memcpy() only). They are used in the
kernel and are provided to the userland via commpage entries.
* Introduced build system feature allowing easy use of C structure
member offsets in assembly code.

Changes after merging:
* Fixed merge conflict in src/system/kernel/arch/x86/arch_debug.cpp
(caused by refactoring and introduction of "call" debugger command).



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23370 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4accd841c7331a6674a4c5db4d9b2686d7eb8bac 06-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a big bug in common_file_io_vec_pages(): vecOffset was not correctly
set when the first chunk of the file could be read in directly, causing it
to read data to a wrong place in the buffer.
* Reading in the first chunk directly would have also only worked if vecIndex
and vecOffset was 0 when calling the function.
* Applied the fs_shell changes in file_map to the kernel version as well (the
constructor already worked correctly, though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23265 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb431b443bca48124de6b4d921fa16cac07e7ec0 13-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* vfs_unmount() can now safely be called from the kernel (fs_unmount() still
tried to access the uninitialized vnode in that case).
* That means that it's now safe to remove a mounted CD from the drive, it
will then be unmounted automatically.
* Added a check for partition::Device() - even though Ingo tells me it's
impossible, it was NULL once.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22922 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e122bd99ec62ea5bf4adbcfebb4a28f8b604e28 12-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish: Missed those changes in the previous commit:
* Added vfs_unmount(), which allows unmounting by dev_t (used by the DDM).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22910 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3d268eda3d0ca504c865533347decf27b54025b6 10-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* Extracted file_map API out of the file cache - it's now an optional service
that can be used by file systems.
* Changed the way the file cache works: instead of reading/writing to the
underlying device directly, it can now be used for any data source, ie.
also network file systems.
* As a result, the former pages_io() moved to the VFS layer, and can now be
called by a file system via {read|write}_file_io_vec_pages() (naming
suggestions are always welcomed :-)). It now gets an FD, and uses that to
communicate with the device (via its fs_{read|write}_pages() hooks).
* The file_cache_{read|write}() functions must now be called without holding
an I/O relevant file system lock. That allows the file cache to prepare the
pages without colliding with the page writer, IOW the "mayBlock" flag can
go into the attic again (yay!).
* This also results in a much better performance when the system does I/O and
is low on memory, as the page writer can now finally write back some pages,
and that even without maxing out the CPU :)
* The API changes put slightly more burden on the fs_{read|write}_pages()
hooks, but in combination with the file_map it's still pretty straight
forward. It just will have to dispatch the call to the underlying device
directly, usually it will just call its fs_{read|write}_pages() hooks
via the above mentioned calls.
* Ported BFS and FAT to the new API, the latter has not been tested, though.
* Also ported the API changes to the fs_shell. I also completely removed its
file cache level page handling - the downside is that device access is no
longer cached (ie. depends on the host OS now), the upside is that the code
is greatly simplified.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22886 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 53715fe060e108eb46185d16a710bce4f0cbaa61 01-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Got rid of the B_PARTITION_DESCENDANT_BUSY flag.
* Added CheckAndMarkBusy() and UnmarkBusy() methods to KPartition.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22801 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8354dac78e2ce5da2e5ee1826c37dbc12cacbd18 01-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Folded KPhysicalPartition into KPartition. Removed the notion of shadow
partitions from the disk device manager.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22800 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 327887959e06348e47b1aa0965f3679e2576dba8 01-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved partition scanning back to KDiskDeviceManager. ATM only
synchronous scanning is supported.
* Removed the disk device job support from the disk device manager.
* K{Disk,File,Partitioning}System:
- Remove querying and validation methods.
- Commented out the modification methods until their fate is decided.
* Removed obsolete _user_get_partitionable_spaces().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22799 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 45ae0aa1aadb1067c55e7402f2beec4d3ef8dc18 23-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

It's not a good idea to write back large files while keeping the vnode busy.
The low memory handler now has two passes which should help there; however, it
might also accidently remove recently used vnodes, too. We could mark the clean
ones in some way if that turns out to be a problem.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22678 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0710d59c1c6edace8ad333b1e3e86f9931e4e3f0 08-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* Added a "canWait" argument to vfs_get_vnode() - you can use this to ignore
busy vnodes.
* dir_create_entry_ref() used get_vnode() incorrectly (and could therefore
potentially prevent a file system from doing proper locking when called
from the kernel).
* The vnode_store now uses this for its acquire_unreferenced_ref()
implementation (and therefore for the page writer).
* read_into_cache() and write_to_cache() were still marked inline.
* The system will now wait 10 secs for a busy vnode before returning an error.
* It will also no longer panic in that case.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22485 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0b7582a306ebaf22e7e5ed44f6930b24478d6dec 07-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Some types of files cannot be seeked and we need to fail in those cases.
We actually need to fail for sockets, too, but until I'm mistaken, we
can't identify them in the VFS. Fixes bug #1539.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22480 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 80f54692912d728f5780e9d78d7643828edaaa2a 06-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* struct vnode is an opaque type now, removed void* where it was used incorrectly.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22461 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 570263197eb178eba5f042054229c07c3fe74e64 05-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reviewed checking of empty paths and fixed some occurrences. Thanks to
mjw for the hint. Fixes bug #1516.
* Changed _{kern,user}_create_symlink() to no longer check the supplied
link string. BeOS seems to do that, but this is not standard
conforming. The previous implementation even used the path processed
by check_path(), which would potentially have appended a ".".
* Some style cleanup.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22451 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3e9513aa4a8bf5f2fb2b86a767ffe46f6e626acc 03-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* fs_{write|read}_pages() now has an additional argument "mayBlock".
* the page writer don't allow to block, while all other writers do. This fixes
bug #1509. The reason the page writer needs this is because it marks several
pages from different caches as busy.
* Fixed a warning about ASSERT being defined already in BFS, since
util/DoublyLinkedList.h now includes debug.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22434 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 636bfc08aeaaa7f1bab813c5aa2e8e666b40ec64 02-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed fs/vfs_select.cpp to wait_for_objects.cpp and got rid of
vfs_select.h, respectively moved most of it into the new kernel
private header wait_for_objects.h.
* Added new experimental API functions wait_for_objects[_etc](). They
work pretty much like poll(), but also for semaphores, ports, and
threads.
* Removed the "ref" parameter from notify_select_events() and the
select_sync_pool functions as well as from fd_ops::fd_[de]select(). It
is no longer needed. The FS interface select() hook still has it,
though -- the VFS will always pass 0.
* de]select_fd() take a select_info* instead of a select_sync* + ref
pair, now. Added respective functions for semaphores, ports, and
threads.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22416 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 66c03dc3a92b84f0320b1c350238396cdf203cc7 30-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* fd.c -> fd.cpp
* Reworked the select support:
- The io_context additionally stores a table of lists of select_infos,
which enables it to deselect events of a pending select() when
closing a FD. This prevents a race condition potentially causing a
write to stale memory.
- The opaque selectsync* passed to FSs is now actually a select_info*.
This was necessary, since the FDs deselect() hook (unlike the
select() hook) doesn't take a "ref" argument and deselecting a
single info (e.g. caused by a premature close()) was not possible.
The select() hook's "ref" argument has become superfluous.
- It should now be relatively easy to implement a poll_on_steroids()
that can also wait for objects other than FDs (e.g. semaphores,
ports, threads etc.).
* Set/reset the signal mask in common_select(). This makes pselect()
work as required.
* Reorganized vfs_resize_fd_table().



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22391 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3392e9bcd6178db96dd433fc50544f961b90f816 29-Sep-2007 Axel Dörfler <axeld@pinc-software.de>

* Added some more debug output.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22375 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6d4aea47962e0ea08b81327fbbf93b32ae821177 25-Sep-2007 Axel Dörfler <axeld@pinc-software.de>

bonefish+axeld:
* Removed the vm_cache/vm_store ref_count duality that besides being a bit ugly
also created the page dameon cache retrieval problem: now, only areas (and
cache consumers) retrieve a reference to the store (and therefore, the vnode).
The page daemon doesn't need to care about this at all anymore, and the pseudo
references of the vm_cache could be removed again.
* Rearranged deletion of vnodes such that its ID can be reused directly after
fs_remove_vnode() has been called.
* vm_page_allocate_page() no longer panics when it runs out of pages, but just
waits for new pages to become available using the new sFreeCondition condition
variable - to make sure this happens in an acceptable time frame, it'll
trigger a run of the low memory handlers.
* Implemented a page_thief() that steals inactive pages from caches and puts
them into the free queue. It runs as a low memory handler.
* The file cache now sets the usage count on the pages it inserts into the
cache (needs some rework though, cache_io() doesn't do it yet).
* Instead of panicking, the kernel will currently dead lock in low memory
situations, since BFS does a bit too much in bfs_release_vnode().
* Some minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22315 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8687956af2ed154458d42f7c6a7ea7c8f7dee17a 09-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added a clarifying comment to free_vnode() and prevented the vnode
reference count to drop below 0 there.
* Added TODO describing a serious race condition between free_vnode()
and the page daemon.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22209 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 62454aae669ee5458ef7077c3a858c094d0d68fb 08-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed get_mount(). It must also acquire the vnode lock before trying to
increment the root node vnode reference count. Otherwise it could race
with fs_unmount(). Fixes bug #1438.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22203 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 43ab7500cc2e4c74cf474133b08e2975c53c00c1 08-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Some cleanup. Fixed gcc 4 warning.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22202 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d1dc70fa5fd827aa28c7bf03b5ca8014676bd365 05-Aug-2007 Marcus Overhagen <marcusoverhagen@gmail.com>

FD_CLOEXEC is a flag, other bits may be set


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21829 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 58f6e8e5e4aeee797ecd3bb7bed17d5a3a2029c0 17-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

* Merged vm_cache_ref and vm_cache to a single structure (Axel & Ingo).
* Renamed vm_cache.c to vm_cache.cpp


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21642 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bd1877933fad61fd08982d3b8bcc63181a081b6f 14-Jul-2007 Axel Dörfler <axeld@pinc-software.de>

remove_vnode() will now return an error code if the vnode to be removed did not exist.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21614 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 25f46ea449ca29e08bef64ef93eb5d5b117d7e2f 30-Jun-2007 Axel Dörfler <axeld@pinc-software.de>

* Reserving areas never put down their reference of their address space when
removed in several cases.
* vfs_get_vnode_cache() now always gives out a reference to the cache it
returns; if it needs to allocate a new one, the vnode owns one reference,
and the caller another.
* therefore, file_cache_create() now owns a reference to its vm_cache_ref, and
frees it in file_cache_delete().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21533 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 245aecda8ac43fc2c0c0bac6a7e4016efa9b71e1 21-Jun-2007 Axel Dörfler <axeld@pinc-software.de>

Got rid of vnode_id and mount_id, replaced with ino_t and dev_t.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21485 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f415aa28bec600badf82c80494ce38d9647ab2ad 28-May-2007 Axel Dörfler <axeld@pinc-software.de>

* create_vnode() now panicks when it could not find the freshly created vnode
in the vnode hash; that's a bug in the FS that shouldn't be ignored that way.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21262 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b5f602a702ffe76c51c6e392b8c4f7c70040110c 27-May-2007 Jérôme Duval <korli@users.berlios.de>

added a missing newline, dunno why this message is displayed :)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21250 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1e768ed1d33e21faabb52b3b80d49a0027ac745b 02-Apr-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

get_vnode_name():
* read_dir() is supposed to return B_OK and and a count of 0 when
reaching the end of the directory. In case the node in question could
not be found, we were looping infinitely.
* free_dir_cookie() was not invoked.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20519 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6376aa3f7aedc3b315b6ab0307fc3f14f72e814c 23-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* The close-on-exit bitmap vfs_new_io_context() created was a byte
short, if the FD table size wasn't a multiple of 8.
* vfs_resize_fd_table() didn't seem to know at all about the
close-on-exit bitmap. The pointer in the io_context would point to
free()d memory afterwards. This explains the sporadically closed
stdin/out/err descriptors in programs started from Tracker and
Deskbar.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20413 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cf4ccd6575bb584d54921cf42a173ee9046696ef 04-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Renamed the FS interface hook read_link() to read_symlink().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20330 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 12d359b85a22246a568569b09b6587534e98aacc 04-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed write_link from the FS module interface. Adjusted all FS
add-ons accordingly and removed the syscall.
* Removed send_notification().
* Reimplemented notify_listener(). It used the unimplemented
send_notification(). Now it has a chance to work. Note that
notify_listener() is obsolete. I would already have removed it, if
there weren't lots of FS implementations still using it (Hint!).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20329 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 348be5b50b94292ec72fe6b0dd743c428f388a9f 02-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced the new static lock sVnodeCoveredByMutex to guard the
vnode::covered_by fields. Together with sMountOpLock it allows write
access, either lock alone suffices for read access. Before
sMountOpLock had to be acquired for read (and write) access, which
meant that while mounting/unmounting a FS path resolution would have
to wait. In case of the UserlandFS this would even cause a deadlock
while mounting if the client tried to resolve the path of the device
to be mounted (e.g. by opening it).
* Added a clarifying comment about read access to the
fs_mount::covers_vnode/root_vnode field and removed locking in
resolve_volume_root_to_mount_point() which was not necessary for
explained reasons.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20308 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2f742879c89a2e69a907ca8b419253ec51162a4a 02-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed get_vnode_name() to take a dirent* parameter instead of the
name (saves copying the name, if that has to be done anyway) and added a
wrapper version with the old interface.
* dir_vnode_to_path() was broken for file systems that didn't support
the get_vnode_name() hook. It resolved the mount point too early, so
that it was searching the mount point and not the FS root dir for the
node. It uses the get_vnode_name() function now (before resolving the
mount point).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20305 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9481e62bdbacde8797ed4ab1f1208fc7ba786a7c 01-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

is_vnode_removed() is now known as get_vnode_removed() and returns its
answer through a reference parameter.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20297 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6d3667845fc9d55ff3ab2aa21cfd7f8e0a006d58 28-Feb-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Be nicer to FSs and fill in the known part of the fs_info *after* the FS
had its go. BeOS does the same.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20262 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 223bba10f3cd044b904fa91cc0271d34faaf700b 28-Feb-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Resurrected is_vnode_removed().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20256 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c926cb8d8a7084caa0cfe59838160200fee1c57d 19-Feb-2007 François Revol <revol@free.fr>

Return sensible errors instead of -1. Added some TODO comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20166 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c8d3c6f470e287e6712272fd03490c8b7b5e5208 19-Feb-2007 François Revol <revol@free.fr>

Implemented get/setrlimit(RLIMIT_NOVMON). Note the kernel calls don't set errno... but they're called by user versions. Might want to split them if needed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20165 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 793f542244051f787b5e54c35452892c2bb8a6f3 30-Aug-2006 Axel Dörfler <axeld@pinc-software.de>

Added a comment about the outcome of a potential problem.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18717 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c40fe37f0b9ed23d499abfbb4dbc51ae282bba1b 30-Aug-2006 Axel Dörfler <axeld@pinc-software.de>

* Reverted the changes r17693 made to vfs_get_vnode_cache(); instead, vm_create_vnode_cache()
will now grab a reference to the vnode as well if successful. This way, vfs_get_vnode_cache()
now actually works how it should: it will now always grab a reference to the cache and
its underlying vnode. This removes an extra reference to the vnode (and vm_cache) that
got ignored before and prevented volumes to be unmounted (or file caches to be removed).
Thanks to Korli for pointing this out.
* file_cache_create() is now aware of that extra vnode reference and releases it; unmounting
volumes is now working again as it should.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18716 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 355efe3ec181844d50e35ce0c9799ed10a6689b6 24-Aug-2006 Jérôme Duval <korli@users.berlios.de>

improve debug command vnode_cache: it now accepts a device arg


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18618 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0ba0370464602e792dd23b08ac6e0c8a3e9f7ad4 21-Jun-2006 Axel Dörfler <axeld@pinc-software.de>

Use B_MAX_SYMLINKS instead of SYMLINKS_MAX (which also fixes the build, btw).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17900 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8265e1210cefdff2a0553dc2a0696bb3cb2396bf 02-Jun-2006 Axel Dörfler <axeld@pinc-software.de>

Implemented mandatory file locking, BeOS style. BNode::Lock() and BNode::Unlock()
are now working as expected.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17697 a95241bf-73f2-0310-859d-f6bbb57e9c96


# acac7c6834809fa3626c3c27dda7ef398419acd9 01-Jun-2006 Axel Dörfler <axeld@pinc-software.de>

_vm_map_file() did in fact not work correctly, but the main problem was
vfs_get_vnode_cache() which did not acquire an extra reference to the
cache_ref when the cache had to be created.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17693 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 20914efdcf7ef2591fb62f787758dae9696a7ac7 25-May-2006 Axel Dörfler <axeld@pinc-software.de>

Made _user_open_entry_ref() a bit more relaxed and return B_BAD_VALUE on some
obvious errors.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17586 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4b25b1b99a456b052e8b490e3c60e882238aed49 19-May-2006 Axel Dörfler <axeld@pinc-software.de>

common_lock_node() now pretends to be successful - this should fix Vision not being
able to store its settings for now (bug #589).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17505 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3cb039fffa0cf6f88f44d0a4c847d2660d69d89a 05-May-2006 Axel Dörfler <axeld@pinc-software.de>

When you try to mount a file image, BFS now only sees the normalized path instead
of the one supplied to fs_mount() (but not the /dev/disk/virtual/... entry, as that
wouldn't be that clear to the user).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17335 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 65bd831cbbb39791cefba28f9a343cbe0c7210fe 05-May-2006 Axel Dörfler <axeld@pinc-software.de>

* KDiskDeviceManager::_ScanPartition() can now run synchronously (and execute the
scan job in the calling thread).
* KDiskDeviceManager::InitialDeviceScan() now runs synchronously, so that
get_boot_partitions() doesn't need to do this ugly wait hack.
* KDiskDeviceManager::CreateFileDevice() can now run synchronously as well, which
fixes a deadlock in fs_mount() - note, mounting file devices still doesn't work,
though as Haiku's BFS doesn't allow this right now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17334 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4827dbe47a1ae3d3153ca6ec5bfe86b7febd1506 18-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed a bug in the VFS that could cause BFS to corrupt an inode:
dir_remove() did not normalize the path, and thus, could forward a "." as
name for the removed directory - which BFS didn't catch because it assumed
our VFS would work correctly...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17165 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a88c592fb33512b5744cf1211e69902971fa27d5 18-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

Instead of ending up in an endless loop, fs_sync() will now bail out in
case get_vnode() fails.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17162 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fde87a10942ccc17f45ee7264a6907d16e6914e1 18-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

Instead of waiting forever, get_vnode() will now fail after 3 seconds if the
vnode is not becoming unbusy (right now it even panics, but that can be removed
later on).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17161 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b2536cb5d660bb11e93f98d2c45637535e02da28 16-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed bug #483:
* vfs_get_fs_node_from_path() now also work for absolute paths again (but
still for relative ones from the volume root) - it just tests if the
mount IDs fit, so it only returns successful if the path really is on
the desired mount.
* the Disk Device Manager publish functions now call devfs_publish_*()
correctly (by omitting the "/dev/" mount point).
* devfs_publish_partition() now accepts absolute device paths but relative
partition paths.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17138 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9a11448fbde0b9467623a3874095cd71cc2631a1 13-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

vfs_get_fs_node_from_path() didn't work correctly and ignored the mount_id
(ie. it only worked for absolute paths, but it shouldn't work for those at
all).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17127 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 97e069713b80839b9dd5441b9f4d37d891b452d8 12-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

Added a "reenter" parameter to the {read|write}_pages() functions to give file
systems a chance to know if they have locked already.
This fixes a locking problem in BFS where one thread tried to acquire two read
locks (where someone else trying to acquire a write lock would have caused a
dead lock).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17108 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 675c19c9cffae598092f7df48b9725d9a3d03650 10-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

* fs_sync() and free_vnode() now use the file system's fsync() hook to write back
changes made to a file instead of directly using vm_cache_write_modified() -
besides making the file system more independent from the file cache, this also
works around a possible dead lock (that is to be fixed in a later commit).
* fs_sync() no longer uses vnodes from the mount's vnode list directly to write
back the changes made to them, but gets them via ID instead - this makes sure
the vnode is in a valid state and fixes a race condition with free_vnode().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17059 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 606e0d364e0c814450efb2ba37bd216d6a1241fc 27-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Factored out the vnode disconnection code from fs_unmount() to a separate
function, and added a vfs_disconnect_vnode() for other kernel components.
* devfs_unpublish_device() can now optionally make use of this call.
* Fixed the type check of devfs' unpublish_node().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16907 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 33dd85501fcd44f8bbba908790b12d3e3124f5e1 14-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16784 a95241bf-73f2-0310-859d-f6bbb57e9c96


# abb84c7d51dcaaeacc7a3a0f75404f18b10167a6 08-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

Removing the nodes from the unused list in fs_unmount() had the side effect that
the root vnode was tried to be removed as well (which resulted in a crash).
Since playing with the root node reference count is a bad idea anyway and opens
a big race condition (with regards to the unused list), we no longer do that
now, until it's safe.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16665 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f951ca0e6a0cf852e1daa7e6c282f12bae77789d 08-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed a couple of bugs:
* fs_unmount() freed vnodes, but didn't remove them from the unused list if
needed.
* vfs_get_module_path() could put a vnode twice under several situations.
* vnode_path_to_vnode() now always puts the dir vnode, even if the provided
path is NULL. Documented the fact that it does eat the ref, too.
* Added a to-do item in vfs_get_vnode_cache() about a possible problem.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16662 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 311bcf391fac2b8037a78756d630e1ddf91254c7 07-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed a possible deadlock I've introduced earlier (since create_sem() calls
vfs_free_unused_vnodes()); the vnode mutex is now hold for much shorter times
only:
* Rewrote advisory_locking creation/maintenance to hold the vnode mutex only
for very short times.
* the vnode mutex is no longer held during file cache construction; instead,
the vnode is marked busy.
* Implemented an (incorrect for now) get_advisory_lock()


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16635 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9f6376a0c752eb965d97c400eb3bb27dbc102775 06-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* get_vnode() did not decrease the sUnusedVnodes counter when taking one node
of that list.
* Added a vfs_free_unused_vnodes() function that calls the low memory handler
directly.
* create_sem_etc() now calls the above function in case there are no semaphores
available anymore; this usually frees up to 2 semaphores per node (one from
the cache if there is a file cache attached, and eventually one from the
file system).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16610 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d98d96e9e502c22e8bd53bc92abdff21f7d92a65 06-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

Added debugger command that dumps info about the vnode usage.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16607 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0254f09df28c131c21f24116b74477cdf5f9de3b 05-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

It's not so problematic if a busy vnode was released; what is problematic is
if that was the last ref.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16590 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0d4c16e0c08ba45ee32177fae63fdeb5b71b52a1 05-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Reduced the stack usage of most of the I/O paths - there were several places
that put one or more full paths on the stack before, which could cause some
problems under certain conditions.
* Cleaned up KPath, ie. use size_t instead of int32 where appropriate, added
license.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16585 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bb674499f8713cb5a125c7718c3d108f8f440b04 03-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Finally implemented B_WATCH_MOUNT, ie. Tracker now shows newly mounted volumes
(mounting still only works from the Terminal).
* Shuffled functions in node_monitor.cpp around to clearly differentiate between
private, private kernel, and public kernel functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16575 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3ea7d1fcbe15d798f9891c3b8a547bd049de3709 27-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup, now returns B_NAME_TOO_LONG if the query string or mount parameters were
longer than 64k.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16527 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5a2ad00cab1adde7fe59540ca5ef692c7e83b3a3 20-Feb-2006 Jérôme Duval <korli@users.berlios.de>

fix a TODO in _user_mount : added an argsLength parameter


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16480 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 979aeaf71cf0c238793ee9a49d91997342ce5fdb 25-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed bug #97:
* BEntry::Remove() now uses _kern_remove_dir() for directories.
* Added fd parameter to _kern_remove_dir().
* Fixed LibBeAdapter's _kern_unlink() to only work on files, and
added _kern_remove_dir() for directories.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16078 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7817211a381481da6f6b13303cbb4dfbf5df5a08 16-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Allow only root to look at other team's file descriptors.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15992 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0e382a46670b2bfa5317d2c6a350c1cb6f99aa42 16-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Implemented a syscall to get information about the open file descriptors of all teams.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15991 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ddb7d0b6a64f423f3d39992eacfb5e13e7a94e7b 15-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Implemented force unmounting - by passing the "-f" option to "unmount" you
can now safely unmount volumes that are still in use by some applications.
Minor fixes to the FD disconnection implementation:
* put_fd() checked the condition for being able to disconnect a descriptor
incorrectly (causing the FD to never be disconnected).
* remove_fd() would hand out disconnected descriptors (but should have
returned NULL for them).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15952 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 16cfe613cd3028d520f728ff2efba253f558da82 21-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed vfs_lookup_vnode() - it's not called with the mutex already locked anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15647 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ea2cd27e57272fe016f285c1762252da775ddfc2 21-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

* Fixed the strange vm_cache_ref reference count mechanism: now, a fresh
vm_cache_ref starts with a reference count of 1. When acquiring a vm_cache,
you no longer need to worry if that should go through the vm_store, or not;
as it now always does.
* map_backing_store() no longer needs to play with the vm_cache_ref
references.
* that simplified some code.
* vfs_get_vnode_cache() now grabs a reference to the cache, if successful.
* better balanced vnode ownership on vnode_store creation (vnode_store
released the vnode before if its creation failed).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15641 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 89f5f72a150519ca74bb3a82a40cefc2954a6acf 16-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

* Added debug output to vm_low_memory.cpp.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15568 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d0d37bdfd170587307c6f64678b739e69341dd69 16-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

* vfs_init() is now called later in the startup sequence - since no core kernel
service depends on it, it doesn't make any sense to call it that early in the
game.
* The VFS now has a low memory handler for vnodes as well. If there is enough
memory left, it won't free any vnodes anymore.
* Potential crashing bug fix: some functions did not check if the FD passed
in belonged to the right type; they just assumed it had a valid vnode, but
it could have had a mount structure associated as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15566 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 04cd47db5920f3d3a23c523dafd07ceae5e51c2d 10-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

common_access() now follows the same logic as traversing paths: if the file system
doesn't export the fs_access() function, it assumes access is granted.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14816 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7121425eb599ad42f6e070d4edd8b879ba75748d 20-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Turns out we could remove a mount point...
Under BeOS remove_vnode() is failing in this case, which looks like a good idea to imitate.
Also, pipefs/rootfs didn't handle that case - they even removed the entry before calling
remove_vnode() - they now behave correctly. And also BFS now returns the actual error code
received from remove_vnode() instead of B_ERROR.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14456 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2db3fced5f119bb3f7c8b8a3ac3fe60190f76e6c 17-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Moved vfs_bootstrap_file_systems() and vfs_mount_boot_file_system() out of vfs.cpp
and into its own file vfs_boot.cpp.

Added basic support for booting from CD - it doesn't give CDs a higher priority,
so you could end up booting from HD when you didn't explicetly select "CD-ROM"
in the boot loader. Eventually, it should only boot from HD in this case, if
booting from CD failed (because of a missing boot partition or whatever).

fs_mount(), _kern_mount(), and _user_mount() will now return the dev_t of the
mounted device, and not just B_OK. Maybe we should have fs_unmount() work on
a dev_t instead of a path as well...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14403 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9a63d903970648f924ab2a70bc92761d2ea31a03 06-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Added kernel private VFS functions vfs_entry_ref_to_vnode() and vfs_vnode_to_node_ref().
Minor cleanup of vfs.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14314 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 681779f1c8f009c46030c12878e588bc2443d353 06-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Our close-on-exec flag handling was broken: it's supposed to be specified per slot, not
per file descriptor (a descriptor can be shared among several slots). There is now a
second table in the io_context structure that contains that information in a bitmap.
There are now two new (private) functions to control the close-on-exec flag, fd_close_on_exec(),
and fd_set_close_on_exec().
F_DUPFD, dup(), and dup2() are supposed to clear the close-on-exec flag on the duplicated
slot - this fixes bug #57 (no output after a redirect of a shell builtin).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14313 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1670b8f596897bfe1b4e55b73d0a9e8acfebf801 06-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

num_used_fds counting was broken for dup2() and vfs_new_io_context() when it was
used with a parent context.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14311 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e8d4a05d8beb7065a1929a1cf07e63a69f9f9e42 06-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed the "iocontext" command to "io_context" to match the structure name.
It now also accepts a team ID and will then dump its io_context.
Accidently mixed used/max FD counter.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14310 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 333735e881af0dd107dbd11f94ba5d2db3dc5f83 05-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Added a new debugger command "iocontext" that prints out info about the kernel's
I/O context (or a specified one) including its FDs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14304 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f10cba9aec9f17134d5922e0a9b244b358ac9bbe 22-Sep-2005 Axel Dörfler <axeld@pinc-software.de>

Changed get_mount() to return a status code instead of just the mount or NULL.
Some fields of fs_mount were not properly initialized when FS's mount function
was called, and therefore, could let get_mount() return a mount structure that
was not yet read for public consumption (this should fix bug #51).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14223 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 47a54bea537dbe733209005d80334716d137a31a 28-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Rootfs now starts with 1 for the first inode ID.
Instead of -1, vnode_path_to_vnode() now returns the ID of the starting vnode when it
doesn't need to traverse the path at all.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14081 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7b285866ffd4fbf1069a31917f8c923ad2ac45fd 25-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed hash functions: when the key was lower than 0 (could happen with entry_refs
and node_refs passed in) they returned an invalid index (larger than range).
Fixed rootfs compilation with tracing turned on.
Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14065 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e0481f928ec4346f39d72ee5951330448e7d5234 21-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Now marks a partition unmounted on unmount - that allows a volume to be remounted as often as you like.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14036 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5b14757a30be0b805e2688cdc5341177f2d703fb 20-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

We now have a consistent scheme what the file system should do with its root
node: like in BeOS, it *must* own the root node (ie. via publish_vnode()),
unlike in BeOS, it must also drop that reference on unmount (symmetrical
behaviour definitely makes more sense to me than the Be way).
Since all existing file systems for Haiku behaved differently, I brought them
in line (only pipefs already adhered to that new standard for some reason,
rootfs did only released the node, devfs did nothing - despite it's probably
not really useful to be able to unmount them).
fs_mount() will now panic if a file system does not do this correctly (useful
for file system developing).
Unmounting is now theoretically working again: when trying to unmount a BFS
volume, the kernel crashes in the block cache destruction... (but that's work
for tomorrow).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14017 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e8e4accd16d85239f29fefb2fe4ee7f65da117dd 18-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Add some useful debugger commands to the VFS layer for dumping a vnode, an fs_mount, and
the mounts/vnodes list.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13971 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7964c56d67bb6283a76db7f540f1a807173556ec 09-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Added vfs_get_cwd() call to get the mount_id and vnode_id of the current
working directory (instead of the full path).
Cleanup of some remaining "int" status variables (where it should have
been a "status_t").


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13924 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eab435cd59a30d144ecc077fbdbc1bb37b3eb5a6 05-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

vfs_get_vnode_cache() now only allocates a new cache if requested: this
prevents the system to allocate caches for files that don't use or have
a file cache (ie. only those can be mmap()ed!).
Therefore, cache_prefetch() no longer crashes when trying to prefetch
files without a file cache.
read_into_cache() no longer does anything if the requested size is 0.
Fixed a bug in cache_prefetch_vnode(): if the cache couldn't be retrieved,
it put the vnode, but didn't own it (the caller does).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13904 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 95839f5c9276596236cd5b6658465e588e2811e0 03-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

The file cache now has another init method that is called after the boot
device becomes available.
Currently, it opens the "launch_speedup" module (if available), later it
should consult a settings file for what to do.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13894 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c50cfe23dd4850e5dad3eba17f2ec9c9d38cf210 02-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed crashing bug in remove_vnode(): it freed the vnode, but it didn't
remove it from the hash, and thus, left a dead pointer around.
free_vnode() does now also remove the vnode from the hash - this is done
so that the file system is notified about removal/put of the vnode before
there is a chance that this vnode is recreated/reloaded (could make the
life of file system writers a bit easier).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13877 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b72cf2601fbc931d2b3224e285eb26d09b20ea5e 01-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed vfs_vnode_acquire_ref() to vnode_acquire_vnode().
Removed vfs_vnode_release_ref(), as vfs_put_vnode() already does the same thing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13867 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b7d8ef5a0d83bbf8f8d642e00d36db65f3407b3f 01-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

The term vnode_ptr is not used anywhere else; renamed vfs_put_vnode_ptr() to vfs_put_vnode().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13865 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9882caaadd59685d38312cd1c45fe377c7c68366 31-Jul-2005 Axel Dörfler <axeld@pinc-software.de>

The path resolving functions can now also fill in the ID of the parent directory.
This is currently only used for the file cache module API.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13862 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 54476a21b570f9b6d38d0a500606e2fd5e121001 12-Jul-2005 Axel Dörfler <axeld@pinc-software.de>

file_create() now also supports FD relative path specifications.
This was the cause for some apps to put their settings files to the current
directory, and also that Tracker did not find some icons (from the icons
it installed in the MIME database).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13645 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ada5975312c5edd41aa14d34f167df3ac02aa2e8 23-May-2005 Axel Dörfler <axeld@pinc-software.de>

fs_mount() and get_file_system() can now both handle file system names
in the form "bfs" and "file_systems/bfs/v1".


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12791 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 47f39c93cbd7db06e72642b047f1fc327852684c 23-May-2005 Axel Dörfler <axeld@pinc-software.de>

Merged the disk device manager module interface for file systems with the
VFS's interface, so that a file system only has to implement one interface.
As a side effect, the automatic file system detection may now work (not yet
tested, though).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12786 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d5b04e50f8eca76ce5e6690dc8873861fa978de0 13-May-2005 Axel Dörfler <axeld@pinc-software.de>

First step into a new block allocation strategy for the block_cache
(right now, it's still malloc/free, just encapsulated in an allocator class).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12662 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6bdc405f759e30aa253635ab76a565747f3d2306 12-May-2005 Axel Dörfler <axeld@pinc-software.de>

Whenever KPath is used, it will now be tested if it could be initialized
(thanks to Ingo for the reminder...).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12652 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cbd1d9977f62c3f1eca8dd75a20aead47a0ae0e8 11-May-2005 Axel Dörfler <axeld@pinc-software.de>

Changed all _kern_*() calls to use KPath instead of a path buffer on the stack.
This reduces the stack usage quite a lot, and since file system calls could be
nested (for example, a mounted image on a volume), definitely a must, too.
Might be a good idea for user calls, too, though, although it's not urgent.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12636 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0953c83ebd428b1d46312d00684d33558fa3fb89 02-May-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed another bug: after a partition had been mounted, it was only marked
mounted, but no one told it about its volume ID - that caused "mountvolume"
not to be able to return a valid mount point.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12548 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 47729f044c76e7b7e87c2bbf6eeb3c3af9033461 02-May-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a possible bug in path_to_vnode(): if called before a root
file system has been mounted, it would have crashed (that for example
happened if you deleted the kernel settings file...).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12547 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2d690920ac4d0cd27eb3c118fb2b0862615869e0 13-Apr-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed system/core to system/kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12360 a95241bf-73f2-0310-859d-f6bbb57e9c96