History log of /haiku/src/system/kernel/device_manager/devfs.cpp
Revision Date Author Comments
# 425ac1b6 20-Jun-2023 Alexander von Gluck IV <kallisti5@unixzen.com>

refactor: Swap %Ld for %lld in all format usages

* %Ld is an undocumented alias for %lld in glibc.
* muslc doesn't implement it for this reason.
* While we will likely never drop %Ld support,
lets clean house and set a better example.

Change-Id: Id46dad3104abae483e80cc5c05d1464d3ecd8030
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6636
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 8e17b43d 14-Oct-2022 Jérôme Duval <jerome.duval@gmail.com>

kernel/device_manager: Implement B_GET_DRIVER_FOR_DEVICE

for legacy and new drivers.

This is an opcode for ioctl that can be used on almost any device entry found in /dev.
When used, ioctl will fill a buffer with the absolute path to the driver file that is
being used by the device.

This opcode was available in BeOS R5, though remained unimplemented in Haiku since
the introduction of the Device Manager almost two decades ago.

Original change by Jacob Secunda.

Change-Id: Ic49141b677b4158a63918459d4048450c825447c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5078
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 442298d4 25-Jun-2022 Jérôme Duval <jerome.duval@gmail.com>

kernel/devfs: improve devfs_compute_geometry_size

the old code could lead to an odd head count, thus a smaller partition size.
with power of two, this works at least accurately if the size is aligned.
we should probably introduce a new ioctl or extend the current one to avoid this problem.

Change-Id: Ia6c034262b1756e901d6ad76ab17b278b2314631
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5398
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# c1461831 07-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

devfs: Do not perform synchronous requests in devfs_io.

In some circumstances, we can wind up iterating on requests
by recursing through this function once per "iteration" due to
how vfs_synchronous_io works. This can run out of stack, as
was seen in #9900 and potentially other tickets.

An initial attempt was made to fix the problem in hrev45906,
but it was quickly reverted because it seems to have broken
I/O for all devices that do not support the "IO" hook.

This solution is much simpler: the VFS layer already can handle
vnodes' IO hooks returning B_UNSUPPORTED and then falling back
to synchronous I/O just as if they had no IO hook at all.
This should hopefully cause iteration to occur without recursion.

Tested by booting off a USB drive (the usb_disk driver does not
support the IO hook, so all requests must be translated.)

May fix #9900.


# 711e2dc0 01-Dec-2021 Augustin Cavalier <waddlesplash@gmail.com>

Adjust all struct dirent creations (again), this time to use offsetof().

The dirent struct is not packed, so offsetof(dirent, d_name) != sizeof(dirent).
Thus in order not to waste the alignment bytes (which are significant,
on x86_64 at least, sizeof(dirent)==32, but offsetof(...)=26.)

This is also the most portable way to handle things, and should
work just fine in cross-platform code that has a non-zero-sized d_name.


# 9d242fb9 18-Nov-2021 Augustin Cavalier <waddlesplash@gmail.com>

file_systems & Tracker: Do not assume sizeof(dirent) contains 1 byte for the name.

At present, it does, but that is an oddity we have preserved from BeOS
that the next commit is going to remove. (This commit thus wastes 1 byte
without the following one.)

Most changes are pretty straightforward: only a +1 is needed,
and a few removed from sizing calculations. Some filesystems like UDF
originally passed back the length with the \0 included, so they have
been adjusted further. UFS2 had some other sizing problems which are also
corrected in this commit.


# bd02d81c 30-Jun-2021 David Sebek <dasebek@gmail.com>

Fix trim-related issues

Fixes:
* Use uint64 instead of off_t when handling offset and size
of the trimmed range in the fs_trim_data structure
* BlockAllocator::Trim: Correct the size of a buffer
* ram_disk, mmc: Do not trim past device capacity

Improvements:
* BlockAllocator::Trim: Because the received offset and size
are ignored by BFS (the functionality is not implemented yet),
return B_UNSUPPORTED if the range does not cover the whole
partition
* ram_disk, mmc: More accurate calculation of the number
of trimmed bytes
* devfs: Add a uint64 version of translate_partition_access()

Change-Id: I24f4c08674f123ad33a5fef6e28996a4ada6ff0d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4155
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 325ec499 30-Jun-2021 David Sebek <dasebek@gmail.com>

devfs: Fix debug message format identifiers

This patch fixes compilation errors on x86_64 when TRACE_DEVFS
is defined. Only format identifiers that caused compilation
errors are changed. Commented-out TRACE's are left unchanged.

Change-Id: I4e803920665eaac7fbc5cec2ffb7778c262bf9c0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4151
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>


# cef80a1f 17-Jan-2021 Adrien Destugues <pulkomandy@pulkomandy.tk>

devfs: translate partition offsets in B_TRIM_DEVICE

Fixes bfs part of #10336. Untested on SATA (don't have a testing drive
to sacrifice) but working fine on SD/MMC.

This requires moving the copy from kernel to userland into the devfs. As
a result the code in the disk drivers becomes a bit simpler.

Also add some documentation for the common ioctls to implement for a
disk device.

Change-Id: Ie84b6a1d293828d33902a64b3c9d4b19aa6eacb1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3640
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# bc231fc7 20-May-2020 Jérôme Duval <jerome.duval@gmail.com>

kernel/fs: rootfs and devfs readlink behavior change

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


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

kernel: devfs: 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 device does not have Select().

Bug: 13965


# 6f7fc220 07-Mar-2016 Axel Dörfler <axeld@pinc-software.de>

NodeMonitor: Added B_WATCH_CHILDREN flag.

* Added a directory argument for notify_{stat/attribute}_changed().
* This allows to watch only a directory, and get the notifications for
all of its files, not just add/remove entry notifications.


# 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.


# 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.


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

Missing std::nothrow on new

Forgot to add this when migrating to BOpenHashTable.


# 6a89f804 09-Jan-2015 Adrien Destugues <pulkomandy@gmail.com>

devfs: migrate to BOpenHashTable

For #9552.


# 28092be1 29-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

devfs: Add devfs_{get,put}_device()

devfs_get_device() returns the device for a given path (if any), also
acquiring a reference to its vnode (thus ensuring the device won't go
away). devfs_put_device() puts the device vnode's reference.


# e26c3df4 29-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

devfs: Remove superfluous create() hook

We don't support creation of files and the VFS calls open() when an
entry already exists.


# 5163e1c6 27-Jul-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Revert "Introduce vnode op supports_operation(), fix devfs_io()"

This reverts commit 98a5231fe5497c526849f2d84b1a9bbcbdfd2dbc.


# 98a5231f 27-Jul-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Introduce vnode op supports_operation(), fix devfs_io()

devfs_io() can't fall back to calling vfs_synchronous_io(), if the
device driver doesn't support handling requests asynchronously. The
presence of the io() hook leads the VFS (do_iterative_fd_io()) to
believe that asynchronous handling is supported and set a
finished-callback on the request which calls the io() hook to start the
next chunk. Thus, instead of iterating through the request in a loop
the iteration happens recursively. For sufficiently fragmented requests
the stack may overflow (ticket #9900).

* Introduce a new vnode operation supports_operation(). It can be called
by the VFS to determine whether a present hook is actually currently
supported for a given vnode.
* devfs: implement the new hook and remove the fallback handling in
devfs_io().
* vfs_request_io.cpp: use the new hook to determine whether the io()
hook is really supported.


# a0641688 27-Apr-2013 Michael Lotz <mmlr@mlotz.ch>

Fix truncation of comparison value introduced in 848acd67.

Casting the difference of the two off_t values to size_t may truncate
the result. Doing so before the comparison will therefore break it.
Instead cast the size to off_t to get around the signed versus unsigned
integer expression comparison and then cast the result of the comparison
to size_t again. Should fix #9714.


# 848acd67 26-Apr-2013 Jérôme Duval <jerome.duval@gmail.com>

devfs: casts as size_t before comparing.

* error: comparison between signed and unsigned integer expressions.


# 9b9cb227 08-Oct-2012 Axel Dörfler <axeld@pinc-software.de>

Consolidated and fixed device_geometry computation.

* The only implementation that would accept more than 2 TB was the one in
scsi_disk. But even that one was limited to 63 TB.
* Now there is a new utility function devfs_compute_geometry_size() which
does it correctly for sizes up to 2^64 which should be good enough for
quite some time :-)
* This fixes bug #8992.


# 294711f9 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Changed {,u}int64 to be long rather than long long on x86_64.


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

More 64-bit compilation/safety fixes.


# a42c52c0 30-Dec-2011 Philippe Saint-Pierre <stpere@gmail.com>

devfs: Fix memory leak

Following r25662 (where devfs was migrated to the new driver architecture),
the issue noted in CID 872 and already fixed in r25643 was reintroduced.


# 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


# 31cf5e52 26-Mar-2011 Axel Dörfler <axeld@pinc-software.de>

* Cleanup, no functional change.


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


# c7b27349 18-Oct-2010 Rene Gollent <anevilyak@gmail.com>

Another build fix.


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


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

* Fixed CID 1293: a vnode reference, and the cookie could be leaked.
* Minor cleanup.


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


# 1d578e15 02-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed more address types related issues. Mostly printf() or comparison
warnings, but also some oversights from earlier changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37000 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


# 0e4ea02d 23-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Use add_debugger_command_etc() for adding the debugger commands.
* Added a "devfs_cookie" command.


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


# 14429e89 08-Jan-2010 Michael Lotz <mmlr@mlotz.ch>

Reverted the part of r31520 that made devfs_unpublish_partition() take a raw
device path + child partition name. When a "raw" device is unpublished the node
removal notification triggers the partition and child partitions to be
unpublished/removed. Since in that case the "raw" node is already unpublished
trying to resolve it in devfs_unpublish_partition() again to unpublish the child
partitions would fail, leaving the child partition nodes behind. When a new raw
device would then become available publishing its partitions would fail because
of these left behind nodes, causing bug #4587. Seeing that this code is more
compact and straight forward anyway I don't quite see why it was changed in the
first place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34967 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


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

* Fixed a dead lock when drivers were scanned: we must not hold the devfs lock
when scanning for drivers, as that reverts the standard locking order with
locks like the device manager lock. There is now a dedicated scan_lock for
each directory.
* get_device_name() now locks itself which also adds a missing lock in the
B_GET_PATH_FOR_DEVICE ioctl().
* Minor refactoring; the directory init code was duplicated over several places
in the source file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33465 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


# b2350565 02-Sep-2009 Michael Lotz <mmlr@mlotz.ch>

Fix two problems in devfs_io:
* An off by one error prevented the very last block of a device to be accessed
through IO.
* In case of error the request wasn't notified causing anyone (the page writer
for example) to wait forever for the request to complete.


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


# a365e1cf 11-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Patch by Bryce Groff, some changes by myself:
* devfs:
- devfs_[un]publish_partition(): They no longer get the partition path as
parameter, but rather the device path and the partition name.
- Added devfs_rename_partition(), which renames an already published
partition node.
* KPartition/KDiskDevice:
- Replaced the fPublished flag by fPublishedName, the name under which the
partition is published. This simplifies UnpublishDevice() and makes it
practically infallible.
- Added GetFileName(), which only returns the partition's file name.
Simplified GetPath() by using it.
- When a partition is added/removed the subsequent sibling partitions get a
new index. Now we also rename their published device nodes (and those of
their descendents). When something goes wrong we unpublish the concerned
partition's device to be on the safe side. Would be a shame to accidentally
format the wrong partition, eh? :-)


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


# fa00207c 15-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Made the internal file systems correctly handle the timespec struct stat
times.


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


# cb894815 04-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Only call Removed() on the device if the device actually got removed, not if
only one of its partitions went away. This should fix #3983.
* Minor cleanup.


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


# 6015793f 12-May-2009 Axel Dörfler <axeld@pinc-software.de>

* Instead of deleting the device directly, we now only remove it from its
parent.
* Additionally, when a vnode is deleted, the new BaseDevice::Removed() method is
called that will remove the device from its parent if needed, and delete it
then.
* This should fix #3856.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30726 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


# 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


# 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


# 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


# 9a2cfc4a 07-Nov-2008 Axel Dörfler <axeld@pinc-software.de>

* BaseDevice::InitDevice() and UninitDevice() must not be called with the devfs
lock held - that was a relict of the past.
* This fixes bug #2535.


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


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

* "devfs_node" now also dumps the partition info, if any.


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


# 2c348abb 30-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Most of the other file systems now maintain the st_blocks value. It might not
always be correct, but should be at least close.


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


# 8ec35e36 17-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Forgot to set the BaseDevice inode ID; devfs_unpublish_device() now works
as intended.


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


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

* Added new devfs_unpublish_device() that gets a BaseDevice instead of a path.
* Added inode ID member to BaseDevice to make this possible.
* Removed unused and unmaintained legacy_driver::devices_published field.
* Implemented legacy driver's unpublish_driver().
* Reenabled legacy driver reloading on changes.
* Renamed devfs_driver_{added|removed}() to driver_{added|removed}(), and
made them private.
* Simplified deletion of device_node lists (no need to use an iterator here),
added device unpublishing.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27033 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


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

Implemented the devfs io() hook.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26660 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


# 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


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

* Removed I/O scheduler knowledge from devfs - it will be moved into the
drivers that need it.


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


# 6ad2f357 09-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Both, rootfs, and devfs did not correctly report the number of entries
returned by fs_read_dir().
* Removed superfluous white space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26338 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


# 0dedf9f0 04-Jun-2008 Axel Dörfler <axeld@pinc-software.de>

* Removed the now superfluous pnp_devfs.h header.
* There was a leftover in devfs that still needed it.


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


# 9a18e1d2 30-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Do not delete the device handed over to the devfs when deleting the vnode
as it seems devfs should not take over ownership. The device is deleted
in republish_driver for legacy drivers before the call to devfs_unpublish_device
that in turn deletes the vnode. This looks generally suspicious to me as
the device pointer the devfs vnode may still use gets invalid for a certain
amount of time (until the node is unpublished). So maybe the devfs should
take ownership of the device afterall and it shouldn't be deleted by the
device_manager/legacy driver functions. Axel please review.
* Do not try to delete the IOScheduler for now as creating one is disabled
currently too.

This fixes the crash on rescans of legacy drivers as seen when unplugging
USB devices.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25729 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


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

* BaseDevice didn't initialize the fInitialized member, and thus causing bug
#2265.
* Device::InitDevice()/UninitDevice() are called from outside of the device
manager, so they better lock it.
* Turned off debug output in devfs and the device manager.
* Fixed debug output in devfs to print the actual vnode/cookie values, instead
of the structures the VFS passes in now.


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


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

* Integration of the new driver architecture.
* Moved devfs from fs/ to device_manager/, and separated the legacy driver
support from it.
* Removed fast_log module.
* There are a couple of (temporary) regressions, though:
- legacy SATA and ISA IDE support is disabled, the drivers haven't been
ported yet.
- The not yet used ATA bus manager hasn't been ported yet, either.
- AHCI changes have not been tested.
- the listdev command has been removed from the build (as it currently
doesn't work anymore).
- device manager generated IDs currently are not freed anymore when a device
node is removed.
- generic drivers can't yet use the new driver architecture.
- simple busses that do not support device types won't work yet.
- legacy driver publishing/unpublishing (ie. what USB needs) has not been
tested, and may be broken.


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


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

Missing std::nothrow on new

Forgot to add this when migrating to BOpenHashTable.


# 6a89f8040fbc385a9298e5afd4ae33a4dbc5b734 09-Jan-2015 Adrien Destugues <pulkomandy@gmail.com>

devfs: migrate to BOpenHashTable

For #9552.


# 28092be1969370f0c4a92536ed066c5700cc56f0 29-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

devfs: Add devfs_{get,put}_device()

devfs_get_device() returns the device for a given path (if any), also
acquiring a reference to its vnode (thus ensuring the device won't go
away). devfs_put_device() puts the device vnode's reference.


# e26c3df48cc8599688803a11f35535ec3f89c6b6 29-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

devfs: Remove superfluous create() hook

We don't support creation of files and the VFS calls open() when an
entry already exists.


# 5163e1c62dc454d84d5cfbd4558b84b8195a44fa 27-Jul-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Revert "Introduce vnode op supports_operation(), fix devfs_io()"

This reverts commit 98a5231fe5497c526849f2d84b1a9bbcbdfd2dbc.


# 98a5231fe5497c526849f2d84b1a9bbcbdfd2dbc 27-Jul-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Introduce vnode op supports_operation(), fix devfs_io()

devfs_io() can't fall back to calling vfs_synchronous_io(), if the
device driver doesn't support handling requests asynchronously. The
presence of the io() hook leads the VFS (do_iterative_fd_io()) to
believe that asynchronous handling is supported and set a
finished-callback on the request which calls the io() hook to start the
next chunk. Thus, instead of iterating through the request in a loop
the iteration happens recursively. For sufficiently fragmented requests
the stack may overflow (ticket #9900).

* Introduce a new vnode operation supports_operation(). It can be called
by the VFS to determine whether a present hook is actually currently
supported for a given vnode.
* devfs: implement the new hook and remove the fallback handling in
devfs_io().
* vfs_request_io.cpp: use the new hook to determine whether the io()
hook is really supported.


# a064168869792934f3a0910f71705b49aff27cde 27-Apr-2013 Michael Lotz <mmlr@mlotz.ch>

Fix truncation of comparison value introduced in 848acd67.

Casting the difference of the two off_t values to size_t may truncate
the result. Doing so before the comparison will therefore break it.
Instead cast the size to off_t to get around the signed versus unsigned
integer expression comparison and then cast the result of the comparison
to size_t again. Should fix #9714.


# 848acd672c1e1ee3cd9b18a3c746ca0c69bc567f 26-Apr-2013 Jérôme Duval <jerome.duval@gmail.com>

devfs: casts as size_t before comparing.

* error: comparison between signed and unsigned integer expressions.


# 9b9cb227c7835fa55076dafac035a25e30b089ff 08-Oct-2012 Axel Dörfler <axeld@pinc-software.de>

Consolidated and fixed device_geometry computation.

* The only implementation that would accept more than 2 TB was the one in
scsi_disk. But even that one was limited to 63 TB.
* Now there is a new utility function devfs_compute_geometry_size() which
does it correctly for sizes up to 2^64 which should be good enough for
quite some time :-)
* This fixes bug #8992.


# 294711f98c107cf2d9d05b7fc34cd863e87bd358 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Changed {,u}int64 to be long rather than long long on x86_64.


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

More 64-bit compilation/safety fixes.


# a42c52c07edccdba81f159c17b17775010bdba6e 30-Dec-2011 Philippe Saint-Pierre <stpere@gmail.com>

devfs: Fix memory leak

Following r25662 (where devfs was migrated to the new driver architecture),
the issue noted in CID 872 and already fixed in r25643 was reintroduced.


# 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


# 31cf5e520a5f3aa5567d3b1c9cf66678d082f0b2 26-Mar-2011 Axel Dörfler <axeld@pinc-software.de>

* Cleanup, no functional change.


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


# c7b27349eecafa7d9cda9f774b5edf63593334a1 18-Oct-2010 Rene Gollent <anevilyak@gmail.com>

Another build fix.


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


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

* Fixed CID 1293: a vnode reference, and the cookie could be leaked.
* Minor cleanup.


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


# 1d578e15fe5b5c3ff62866ae81aef529d00d7762 02-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed more address types related issues. Mostly printf() or comparison
warnings, but also some oversights from earlier changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37000 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


# 0e4ea02d0a7bc406f0d7ebee20f12d207f01f6c3 23-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Use add_debugger_command_etc() for adding the debugger commands.
* Added a "devfs_cookie" command.


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


# 14429e896e713224e2c0773523ef3c132df02c0d 08-Jan-2010 Michael Lotz <mmlr@mlotz.ch>

Reverted the part of r31520 that made devfs_unpublish_partition() take a raw
device path + child partition name. When a "raw" device is unpublished the node
removal notification triggers the partition and child partitions to be
unpublished/removed. Since in that case the "raw" node is already unpublished
trying to resolve it in devfs_unpublish_partition() again to unpublish the child
partitions would fail, leaving the child partition nodes behind. When a new raw
device would then become available publishing its partitions would fail because
of these left behind nodes, causing bug #4587. Seeing that this code is more
compact and straight forward anyway I don't quite see why it was changed in the
first place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34967 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


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

* Fixed a dead lock when drivers were scanned: we must not hold the devfs lock
when scanning for drivers, as that reverts the standard locking order with
locks like the device manager lock. There is now a dedicated scan_lock for
each directory.
* get_device_name() now locks itself which also adds a missing lock in the
B_GET_PATH_FOR_DEVICE ioctl().
* Minor refactoring; the directory init code was duplicated over several places
in the source file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33465 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


# b2350565baa9c7b422c4a9bc1ac558ba636dd33c 02-Sep-2009 Michael Lotz <mmlr@mlotz.ch>

Fix two problems in devfs_io:
* An off by one error prevented the very last block of a device to be accessed
through IO.
* In case of error the request wasn't notified causing anyone (the page writer
for example) to wait forever for the request to complete.


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


# a365e1cfbb80d7d2ee91e6515fa7090906cd5a4e 11-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Patch by Bryce Groff, some changes by myself:
* devfs:
- devfs_[un]publish_partition(): They no longer get the partition path as
parameter, but rather the device path and the partition name.
- Added devfs_rename_partition(), which renames an already published
partition node.
* KPartition/KDiskDevice:
- Replaced the fPublished flag by fPublishedName, the name under which the
partition is published. This simplifies UnpublishDevice() and makes it
practically infallible.
- Added GetFileName(), which only returns the partition's file name.
Simplified GetPath() by using it.
- When a partition is added/removed the subsequent sibling partitions get a
new index. Now we also rename their published device nodes (and those of
their descendents). When something goes wrong we unpublish the concerned
partition's device to be on the safe side. Would be a shame to accidentally
format the wrong partition, eh? :-)


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


# fa00207c50d24a0c867ec4123c351f85256fcbbf 15-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Made the internal file systems correctly handle the timespec struct stat
times.


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


# cb8948154c875e72009b719c1e3f5615a6a1d451 04-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Only call Removed() on the device if the device actually got removed, not if
only one of its partitions went away. This should fix #3983.
* Minor cleanup.


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


# 6015793f57d08929e6e27b7bdc690835ac98eedc 12-May-2009 Axel Dörfler <axeld@pinc-software.de>

* Instead of deleting the device directly, we now only remove it from its
parent.
* Additionally, when a vnode is deleted, the new BaseDevice::Removed() method is
called that will remove the device from its parent if needed, and delete it
then.
* This should fix #3856.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30726 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


# 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


# 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


# 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


# 9a2cfc4ab1fa6a4f7745d60e127e16329ccea801 07-Nov-2008 Axel Dörfler <axeld@pinc-software.de>

* BaseDevice::InitDevice() and UninitDevice() must not be called with the devfs
lock held - that was a relict of the past.
* This fixes bug #2535.


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


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

* "devfs_node" now also dumps the partition info, if any.


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


# 2c348abbf7aca35c66b88e159bdafa41f2a9743f 30-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Most of the other file systems now maintain the st_blocks value. It might not
always be correct, but should be at least close.


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


# 8ec35e364a10060bb0923a620792a062db0f9444 17-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Forgot to set the BaseDevice inode ID; devfs_unpublish_device() now works
as intended.


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


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

* Added new devfs_unpublish_device() that gets a BaseDevice instead of a path.
* Added inode ID member to BaseDevice to make this possible.
* Removed unused and unmaintained legacy_driver::devices_published field.
* Implemented legacy driver's unpublish_driver().
* Reenabled legacy driver reloading on changes.
* Renamed devfs_driver_{added|removed}() to driver_{added|removed}(), and
made them private.
* Simplified deletion of device_node lists (no need to use an iterator here),
added device unpublishing.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27033 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


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

Implemented the devfs io() hook.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26660 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


# 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


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

* Removed I/O scheduler knowledge from devfs - it will be moved into the
drivers that need it.


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


# 6ad2f357dcf08b4ca35eb945f8d2ec1e58d84ef6 09-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Both, rootfs, and devfs did not correctly report the number of entries
returned by fs_read_dir().
* Removed superfluous white space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26338 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


# 0dedf9f0815b78b897924e62902febfad3fb046e 04-Jun-2008 Axel Dörfler <axeld@pinc-software.de>

* Removed the now superfluous pnp_devfs.h header.
* There was a leftover in devfs that still needed it.


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


# 9a18e1d269f663f5cc0d3fb62d2c286888c42e88 30-May-2008 Michael Lotz <mmlr@mlotz.ch>

* Do not delete the device handed over to the devfs when deleting the vnode
as it seems devfs should not take over ownership. The device is deleted
in republish_driver for legacy drivers before the call to devfs_unpublish_device
that in turn deletes the vnode. This looks generally suspicious to me as
the device pointer the devfs vnode may still use gets invalid for a certain
amount of time (until the node is unpublished). So maybe the devfs should
take ownership of the device afterall and it shouldn't be deleted by the
device_manager/legacy driver functions. Axel please review.
* Do not try to delete the IOScheduler for now as creating one is disabled
currently too.

This fixes the crash on rescans of legacy drivers as seen when unplugging
USB devices.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25729 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


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

* BaseDevice didn't initialize the fInitialized member, and thus causing bug
#2265.
* Device::InitDevice()/UninitDevice() are called from outside of the device
manager, so they better lock it.
* Turned off debug output in devfs and the device manager.
* Fixed debug output in devfs to print the actual vnode/cookie values, instead
of the structures the VFS passes in now.


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


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

* Integration of the new driver architecture.
* Moved devfs from fs/ to device_manager/, and separated the legacy driver
support from it.
* Removed fast_log module.
* There are a couple of (temporary) regressions, though:
- legacy SATA and ISA IDE support is disabled, the drivers haven't been
ported yet.
- The not yet used ATA bus manager hasn't been ported yet, either.
- AHCI changes have not been tested.
- the listdev command has been removed from the build (as it currently
doesn't work anymore).
- device manager generated IDs currently are not freed anymore when a device
node is removed.
- generic drivers can't yet use the new driver architecture.
- simple busses that do not support device types won't work yet.
- legacy driver publishing/unpublishing (ie. what USB needs) has not been
tested, and may be broken.


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