History log of /haiku/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp
Revision Date Author Comments
# a90d5c6d 18-Feb-2022 Augustin Cavalier <waddlesplash@gmail.com>

kernel/disk_device_manager: Improve tracing code.

* Use the standard TRACE{|_ALWAYS|_ERROR} setup.

* Put DBG(OUT... code as TRACE.

Makes syslog output from this module significantly less verbose
in default builds.


# 598b8e19 09-Sep-2019 Augustin Cavalier <waddlesplash@gmail.com>

kernel/disk_device_manager: Continue scanning after invalid partitions.

As the inline comment notes, just because we could not scan one
partition does not mean we won't be able to scan the following ones.
This fixes scanning for disks on certain systems following axeld's
change in 7c2135591ba90958b5c8d92a2a5ef8a930c9ee28.

Part of #15330.


# 6967695c 24-Jul-2019 Adrien Destugues <pulkomandy@pulkomandy.tk>

PVS V547: always false comparisons

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


# 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


# 7c213559 28-Dec-2018 Axel Dörfler <axeld@pinc-software.de>

KDiskDeviceManager: Ignore invalid partitions

* Partitions with negative offsets were already ignored, now also ignore
those with an invalid size of block size, too.

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


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


# 7b4084f7 11-Nov-2014 Adrien Destugues <pulkomandy@gmail.com>

reject partitions with negative offset

I had a KDL when trying to read an audio CD which apparently uses this
as a copy protection scheme.
I don't know if this is the right place to do this, the KDL would happen
further down when the intel partitionning system or bfs would try to
read data from the disk at offset -2048.


# c24adb29 19-Apr-2013 Rene Gollent <anevilyak@gmail.com>

Rework DefaultNotificationService registration.

- Instead of implicitly registering and unregistering a service
instance on construction/destruction, DefaultNotificationService
now exports explicit Register()/Unregister() calls, which subclasses
are expected to call when they're ready.

- Adjust all implementing subclasses. Resolves an issue with deadlocks
when booting a DEBUG=1 build.


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


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

More 64-bit compilation/safety fixes.


# 5cea9928 20-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Unlock the auto locker before deleting the object or else you will find
yourself in KDL.


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


# 9837ec16 20-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed spelling.


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


# 3066f3db 15-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Reverted r33547, this closes bug #4782 - this is obviously a regression in
GCC4.
* Adapted code accordingly.


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


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

* Got rid of the duplicated functionalities provided by RWLocker.cpp, and
Locker.cpp.
* The services are now using recursive_locks, and rw_locks instead.


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


# 9cca7d50 31-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Backported r32851 from the r1alpha branch.


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


# 92e143c1 29-Aug-2009 Rene Gollent <anevilyak@gmail.com>

Fix regression introduced in r32526: registering the device watcher for node monitoring needs to happen synchronously, otherwise a race condition occurs: unless you're very lucky, the event for creating the raw device would happen before the async thread had a change to add the node monitor, and as such the listener would miss it, and never trigger a filesystem/partition scan. As a result, whether or not adding a USB stick would actually show a volume was essentially russian roulette. Fixes ticket #4345.

+alphabranch


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


# 6d908f83 19-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Must be careful which functions to call in the notifications handler, or else
you can easily produce a dead lock. This should fix the system hang
experienced as part of bug #4223.


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


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

* So many style violations in so few lines of code...


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


# 1bf034d2 16-May-2009 Bruno G. Albuquerque <bga@bug-br.org.br>

- Check if we had any changes in status before sending a notification for a new
inserted media. This fixes ticket #3921.



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


# efd536ff 11-Apr-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Cleared up a misconception in the notification mechanism. We already had
methods that used an "event mask" field. There was no need to introduce
a "flags" field for the same purpose.
* Renamed protected DefaultNotificationService methods (removed "_" prefix).
* Adjusted the code providing a notification service accordingly.
* Changed the event message several notification services generated by renaming
the "opcode" field to "event".
* Implemented the TEAM_ADDED event and also added a TEAM_EXEC event.
* Added notifications for threads and images.
* Added visitor-like iteration functions for teams, threads, and images.


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


# 3f78b216 18-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Implemented a basic notification mechanism. Right now, only media changes and
device additions/removals can be monitored.
* Minor cleanup.


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


# 3ba6733d 13-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

* CID 312 and CID 313: The device can be NULL in ReadLockPartition().
* CID 314 and CID 315: Same as above just for WriteLockPartition.


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


# 729e189a 21-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Cleanup, no functional change.


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


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

* Try to create unknown devices before failing in RegisterDevice(), and
RegisterPartition().


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


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

* _user_find_partition() did not work for partitions (only for devices), as it
did not set the "devicesOnly" flag to false when calling RegisterDevice().
* ddm_userland_interface.cpp incorrectly wrote to userland memory when it
assigned "neededSize" in several places.
* Replaced on-stack path with the UserStringParameter class where appropriate.
* Made the UserStringParameter class castable to char*.
* Minor cleanup in KDiskDeviceManager.cpp.


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


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

* RescanDiskSystems() now locks the disk device manager, as it clobbers the
disk system lists.
* Added module watching; on module changes, it will now automatically rescan
the disk systems.


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


# 8531599a 30-Jun-2008 Axel Dörfler <axeld@pinc-software.de>

* KDiskDeviceManager::RescanDiskSystems() now also rescans all partitions with
the newly found disk systems.
* _ScanPartition() now allows to restrict the disk systems to a predefined set.
* _ScanPartition() now even scans partitions that already have a disk system
assigned; if a better one is found, the existing one is replaced. It will
ignore mounted or partitions with children, though.
* KPartition now also stores the priority of the disk system assigned to it.


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


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

Print actual floating point number, instead of integer fraction.


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


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

* Replace the path based lstat in the device watcher with the new device/node
based one. The path based version could not have worked for entry removed
notifications at all as the node is removed from the directory at this point
already
* Forgot to delete the device watcher instance after removing all monitors
* The PartitionRegistrar in DeleteDevice() was set to already locked which is
not the case
* Someone probably forgot to add a PartitionRegistrar to the media checker - it
did register the device on each run but never actually unregistered it, which
obviously messed up the reference counting a bit

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


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

Implement node monitoring in the kernel disk device manager.

* Added {Create|Delete}Device() analogous to {Create|Delete}FileDevice
* Added a small DeviceWatcher class that reacts to entry creation/removal
* Implemented a way to start/stop node monitoring
* Start watching for devices after the boot volume has been mounted and the
the second initial scan was run

The disk device manager now creates and scans a device when a "raw" node is
published and deletes the device on removal. This makes hot-plugging of disk
devices (for example memory sticks using usb_disk) work. Their partitions will
be scanned and published so they can be mounted. Somehow the removal of the
partitions does not yet work however, any insights are welcome.

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


# 64a19b44 12-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

Philippe was right, of course, the media checker thread did not bother to
check the fTerminating flag, so it would never quit (too bad no one ever quits
it anyway :-)). Thanks for proofreading!


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


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

On a media change, the KDiskDevice must do a bit more than it did:
* it now updates the partition data,
* the flags,
* and the disk geometry - and that now allows the session add-on to actually
detect a newly inserted CD.


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


# 88ef4111 12-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* Added an UninitializeMedia() method to KDiskDevice that also resets the
device geometry.
* If SetTo() reports no media, and GetGeometry() fails, the device geometry
is now reset as well.
* KDiskDeviceManager::_ScanPartition() no longer unmarks the partition busy;
this is now done by the caller, and done independently from the outcome of
_ScanPartition(). This also fixes the problem that devices with no media
were never marked unbusy (and thus were ignored subsequently).


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


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

axeld + bonefish:
* Unmount when uninitializing a partition.
* Finished the media checker implementation, i.e. we rescan when a media
was inserted and uninitialize when ejected.
* Turned the disk device media checker from a kernel daemon into a thread.


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


# c9830ce0 10-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* KDiskDeviceManager::{Find,Load}DiskSystem() can also find the disk
system by pretty name (not only module name) now.
* _user_initialize_partition() loads the disk system by pretty name.


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


# e544dd59 19-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* Fixed a possible dead lock between the kernel daemon and the DDM; the media
status checker now only tries to lock the manager, it won't wait anymore.
* Added MediaChanged() and UpdateMediaStatusIfNeeded() methods to KDiskDevice.
* KDiskDeviceManager::_CheckMediaStatus() now uses these new methods; it should
no longer detect removed media more than once :-)


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


# 80474417 17-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

The disk device manager now periodically checks for media changes - all it does
is dump its findings, but it's an (untested) start.


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


# 8c8f8c84 04-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added scan_partition() function which can be used by disk systems (e.g.
in *_initialize()) to save some work.


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


# fe679b9f 19-Jul-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld+bonefish:
* Refactored RescanDiskSystems(). Pulled out a function
_RescanDiskSystems() that scans for either file or partitioning
systems. RescanDiskSystems(), which scanned for file systems only
before, is used from the constructor as well (open_module_list()
works in the early boot process since a while).
* Made InitialDeviceScan() and partition scanning safe to be called a second
time. We call it directly after the kernel has mounted the boot
volume, now, so that additional disk systems from the boot volume have a
chance to recognize previously unrecognized partitions. This is a
temporary change only; later the disk device manager shall
automatically find out when new disk systems/devices/whatever are
available.


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


# 6c3245f6 05-Jan-2007 Marcus Overhagen <marcusoverhagen@gmail.com>

fixed error return in _Scan() function. now only returns B_OK when a device was found.


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


# d564275b 03-Sep-2006 Jérôme Duval <korli@users.berlios.de>

added disk systems rescan to DiskDeviceManager, and called it in the post init phase
the next step would be to rescan the partition tree with a job to recognize unrecognized partitions (asynchronously ?)


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


# 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


# 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


# 7b4084f717395bd88d3f7e21760619570252117e 11-Nov-2014 Adrien Destugues <pulkomandy@gmail.com>

reject partitions with negative offset

I had a KDL when trying to read an audio CD which apparently uses this
as a copy protection scheme.
I don't know if this is the right place to do this, the KDL would happen
further down when the intel partitionning system or bfs would try to
read data from the disk at offset -2048.


# c24adb29503ec78c6d076801e1d82d16140e3413 19-Apr-2013 Rene Gollent <anevilyak@gmail.com>

Rework DefaultNotificationService registration.

- Instead of implicitly registering and unregistering a service
instance on construction/destruction, DefaultNotificationService
now exports explicit Register()/Unregister() calls, which subclasses
are expected to call when they're ready.

- Adjust all implementing subclasses. Resolves an issue with deadlocks
when booting a DEBUG=1 build.


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


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

More 64-bit compilation/safety fixes.


# 5cea99288b18b32aaa9a58fd4ec6b843f94a8a3c 20-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Unlock the auto locker before deleting the object or else you will find
yourself in KDL.


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


# 9837ec16c86f0a533600230350e8e89203d1e9e8 20-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed spelling.


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


# 3066f3dbf87e3b5a9ea12f7e81ded55f6d6f2bd9 15-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Reverted r33547, this closes bug #4782 - this is obviously a regression in
GCC4.
* Adapted code accordingly.


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


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

* Got rid of the duplicated functionalities provided by RWLocker.cpp, and
Locker.cpp.
* The services are now using recursive_locks, and rw_locks instead.


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


# 9cca7d50e927cb1a870b264f276d1ca7a587e08d 31-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Backported r32851 from the r1alpha branch.


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


# 92e143c14a99855fa931f879521e203783fcf7c8 29-Aug-2009 Rene Gollent <anevilyak@gmail.com>

Fix regression introduced in r32526: registering the device watcher for node monitoring needs to happen synchronously, otherwise a race condition occurs: unless you're very lucky, the event for creating the raw device would happen before the async thread had a change to add the node monitor, and as such the listener would miss it, and never trigger a filesystem/partition scan. As a result, whether or not adding a USB stick would actually show a volume was essentially russian roulette. Fixes ticket #4345.

+alphabranch


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


# 6d908f83f30ae4c95761f14dfb31597448464165 19-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Must be careful which functions to call in the notifications handler, or else
you can easily produce a dead lock. This should fix the system hang
experienced as part of bug #4223.


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


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

* So many style violations in so few lines of code...


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


# 1bf034d2f59572b7f67b412bdba39c5a45356780 16-May-2009 Bruno G. Albuquerque <bga@bug-br.org.br>

- Check if we had any changes in status before sending a notification for a new
inserted media. This fixes ticket #3921.



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


# efd536ff89954302f42c59e2c71fba45e5cb4c25 11-Apr-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Cleared up a misconception in the notification mechanism. We already had
methods that used an "event mask" field. There was no need to introduce
a "flags" field for the same purpose.
* Renamed protected DefaultNotificationService methods (removed "_" prefix).
* Adjusted the code providing a notification service accordingly.
* Changed the event message several notification services generated by renaming
the "opcode" field to "event".
* Implemented the TEAM_ADDED event and also added a TEAM_EXEC event.
* Added notifications for threads and images.
* Added visitor-like iteration functions for teams, threads, and images.


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


# 3f78b216ad39f9f51adcedcbc75e770a51d232c9 18-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Implemented a basic notification mechanism. Right now, only media changes and
device additions/removals can be monitored.
* Minor cleanup.


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


# 3ba6733d61caed7c14c9c0233de118354746ce16 13-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

* CID 312 and CID 313: The device can be NULL in ReadLockPartition().
* CID 314 and CID 315: Same as above just for WriteLockPartition.


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


# 729e189a48d8d60ade863236af69b57c37ee2aa5 21-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Cleanup, no functional change.


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


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

* Try to create unknown devices before failing in RegisterDevice(), and
RegisterPartition().


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


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

* _user_find_partition() did not work for partitions (only for devices), as it
did not set the "devicesOnly" flag to false when calling RegisterDevice().
* ddm_userland_interface.cpp incorrectly wrote to userland memory when it
assigned "neededSize" in several places.
* Replaced on-stack path with the UserStringParameter class where appropriate.
* Made the UserStringParameter class castable to char*.
* Minor cleanup in KDiskDeviceManager.cpp.


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


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

* RescanDiskSystems() now locks the disk device manager, as it clobbers the
disk system lists.
* Added module watching; on module changes, it will now automatically rescan
the disk systems.


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


# 8531599a27883696031d0ab3358dc3e78a3b29ce 30-Jun-2008 Axel Dörfler <axeld@pinc-software.de>

* KDiskDeviceManager::RescanDiskSystems() now also rescans all partitions with
the newly found disk systems.
* _ScanPartition() now allows to restrict the disk systems to a predefined set.
* _ScanPartition() now even scans partitions that already have a disk system
assigned; if a better one is found, the existing one is replaced. It will
ignore mounted or partitions with children, though.
* KPartition now also stores the priority of the disk system assigned to it.


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


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

Print actual floating point number, instead of integer fraction.


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


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

* Replace the path based lstat in the device watcher with the new device/node
based one. The path based version could not have worked for entry removed
notifications at all as the node is removed from the directory at this point
already
* Forgot to delete the device watcher instance after removing all monitors
* The PartitionRegistrar in DeleteDevice() was set to already locked which is
not the case
* Someone probably forgot to add a PartitionRegistrar to the media checker - it
did register the device on each run but never actually unregistered it, which
obviously messed up the reference counting a bit

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


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

Implement node monitoring in the kernel disk device manager.

* Added {Create|Delete}Device() analogous to {Create|Delete}FileDevice
* Added a small DeviceWatcher class that reacts to entry creation/removal
* Implemented a way to start/stop node monitoring
* Start watching for devices after the boot volume has been mounted and the
the second initial scan was run

The disk device manager now creates and scans a device when a "raw" node is
published and deletes the device on removal. This makes hot-plugging of disk
devices (for example memory sticks using usb_disk) work. Their partitions will
be scanned and published so they can be mounted. Somehow the removal of the
partitions does not yet work however, any insights are welcome.

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


# 64a19b4444229f1173e35a5009f03a7efbdce552 12-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

Philippe was right, of course, the media checker thread did not bother to
check the fTerminating flag, so it would never quit (too bad no one ever quits
it anyway :-)). Thanks for proofreading!


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


# 7333992516c6e0e1c62c0fce64863392013507cd 12-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

On a media change, the KDiskDevice must do a bit more than it did:
* it now updates the partition data,
* the flags,
* and the disk geometry - and that now allows the session add-on to actually
detect a newly inserted CD.


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


# 88ef41115466c4ee4900a270ebd5dcdd1be6f730 12-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* Added an UninitializeMedia() method to KDiskDevice that also resets the
device geometry.
* If SetTo() reports no media, and GetGeometry() fails, the device geometry
is now reset as well.
* KDiskDeviceManager::_ScanPartition() no longer unmarks the partition busy;
this is now done by the caller, and done independently from the outcome of
_ScanPartition(). This also fixes the problem that devices with no media
were never marked unbusy (and thus were ignored subsequently).


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


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

axeld + bonefish:
* Unmount when uninitializing a partition.
* Finished the media checker implementation, i.e. we rescan when a media
was inserted and uninitialize when ejected.
* Turned the disk device media checker from a kernel daemon into a thread.


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


# c9830ce0f582866c38cd80506a0da8fd8706c8a6 10-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* KDiskDeviceManager::{Find,Load}DiskSystem() can also find the disk
system by pretty name (not only module name) now.
* _user_initialize_partition() loads the disk system by pretty name.


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


# e544dd59154d2d123ec74c778176bdb995ae7f08 19-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* Fixed a possible dead lock between the kernel daemon and the DDM; the media
status checker now only tries to lock the manager, it won't wait anymore.
* Added MediaChanged() and UpdateMediaStatusIfNeeded() methods to KDiskDevice.
* KDiskDeviceManager::_CheckMediaStatus() now uses these new methods; it should
no longer detect removed media more than once :-)


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


# 8047441723ec3959627771b4bcfac154fca4a08f 17-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

The disk device manager now periodically checks for media changes - all it does
is dump its findings, but it's an (untested) start.


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


# 8c8f8c84209c539c801ce0df111d8ee50e39362c 04-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added scan_partition() function which can be used by disk systems (e.g.
in *_initialize()) to save some work.


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


# fe679b9fa7210f8c0622ff33f723d87d8f8732ad 19-Jul-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld+bonefish:
* Refactored RescanDiskSystems(). Pulled out a function
_RescanDiskSystems() that scans for either file or partitioning
systems. RescanDiskSystems(), which scanned for file systems only
before, is used from the constructor as well (open_module_list()
works in the early boot process since a while).
* Made InitialDeviceScan() and partition scanning safe to be called a second
time. We call it directly after the kernel has mounted the boot
volume, now, so that additional disk systems from the boot volume have a
chance to recognize previously unrecognized partitions. This is a
temporary change only; later the disk device manager shall
automatically find out when new disk systems/devices/whatever are
available.


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


# 6c3245f6a79c8af8d5004e7749281a7855eda362 05-Jan-2007 Marcus Overhagen <marcusoverhagen@gmail.com>

fixed error return in _Scan() function. now only returns B_OK when a device was found.


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


# d564275ba7c6dd4b5e2ca5de251927dcde6b134d 03-Sep-2006 Jérôme Duval <korli@users.berlios.de>

added disk systems rescan to DiskDeviceManager, and called it in the post init phase
the next step would be to rescan the partition tree with a job to recognize unrecognized partitions (asynchronously ?)


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


# 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


# 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