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
This commit is contained in:
Michael Lotz
2008-04-03 18:14:11 +00:00
parent bacaf1148c
commit 06da81f012
3 changed files with 214 additions and 9 deletions
@@ -65,6 +65,9 @@ public:
status_t ScanPartition(KPartition* partition);
partition_id CreateDevice(const char *path, bool *newlyCreated = NULL);
status_t DeleteDevice(const char *path);
partition_id CreateFileDevice(const char* filePath,
bool* newlyCreated = NULL);
status_t DeleteFileDevice(const char *filePath);
@@ -90,13 +93,9 @@ public:
KDiskSystem *LoadDiskSystem(disk_system_id id);
KDiskSystem *LoadNextDiskSystem(int32 *cookie);
// Watching
// TODO: Watching service for the kernel. The userland watching is handled
// by the registrar.
status_t InitialDeviceScan();
status_t RescanDiskSystems();
status_t StartMonitoring();
private:
static status_t _CheckMediaStatusDaemon(void* self);
@@ -117,10 +116,13 @@ private:
status_t _ScanPartition(KPartition *partition);
// used by the other _ScanPartition() version only
status_t _AddRemoveMonitoring(const char *path, bool add);
struct DeviceMap;
struct DiskSystemMap;
struct PartitionMap;
struct PartitionSet;
class DeviceWatcher;
BLocker fLock;
DeviceMap *fDevices;
@@ -129,6 +131,7 @@ private:
PartitionSet *fObsoletePartitions;
thread_id fMediaChecker;
volatile bool fTerminating;
DeviceWatcher *fDeviceWatcher;
static KDiskDeviceManager *sDefaultManager;
};