* 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
This commit is contained in:
@@ -102,6 +102,7 @@ private:
|
|||||||
struct DiskSystemMap;
|
struct DiskSystemMap;
|
||||||
struct PartitionMap;
|
struct PartitionMap;
|
||||||
struct PartitionSet;
|
struct PartitionSet;
|
||||||
|
class DiskSystemWatcher;
|
||||||
class DeviceWatcher;
|
class DeviceWatcher;
|
||||||
|
|
||||||
static status_t _CheckMediaStatusDaemon(void* self);
|
static status_t _CheckMediaStatusDaemon(void* self);
|
||||||
@@ -132,6 +133,7 @@ private:
|
|||||||
PartitionSet *fObsoletePartitions;
|
PartitionSet *fObsoletePartitions;
|
||||||
thread_id fMediaChecker;
|
thread_id fMediaChecker;
|
||||||
volatile bool fTerminating;
|
volatile bool fTerminating;
|
||||||
|
DiskSystemWatcher *fDiskSystemWatcher;
|
||||||
DeviceWatcher *fDeviceWatcher;
|
DeviceWatcher *fDeviceWatcher;
|
||||||
|
|
||||||
static KDiskDeviceManager *sDefaultManager;
|
static KDiskDeviceManager *sDefaultManager;
|
||||||
|
|||||||
@@ -21,11 +21,13 @@
|
|||||||
#include <VectorSet.h>
|
#include <VectorSet.h>
|
||||||
|
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
#include <util/kernel_cpp.h>
|
|
||||||
|
|
||||||
#include <NodeMonitor.h>
|
#include <NodeMonitor.h>
|
||||||
|
|
||||||
|
#include <boot_device.h>
|
||||||
|
#include <kmodule.h>
|
||||||
#include <node_monitor.h>
|
#include <node_monitor.h>
|
||||||
#include <Notifications.h>
|
#include <Notifications.h>
|
||||||
|
#include <util/kernel_cpp.h>
|
||||||
#include <vfs.h>
|
#include <vfs.h>
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
@@ -92,6 +94,30 @@ struct KDiskDeviceManager::PartitionSet : VectorSet<KPartition*> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class KDiskDeviceManager::DiskSystemWatcher : public NotificationListener {
|
||||||
|
public:
|
||||||
|
DiskSystemWatcher(KDiskDeviceManager* manager)
|
||||||
|
:
|
||||||
|
fManager(manager)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~DiskSystemWatcher()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void EventOccured(NotificationService& service,
|
||||||
|
const KMessage* event)
|
||||||
|
{
|
||||||
|
if (event->GetInt32("opcode", -1) != B_ENTRY_REMOVED)
|
||||||
|
fManager->RescanDiskSystems();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
KDiskDeviceManager* fManager;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// DeviceWatcher
|
// DeviceWatcher
|
||||||
class KDiskDeviceManager::DeviceWatcher : public NotificationListener {
|
class KDiskDeviceManager::DeviceWatcher : public NotificationListener {
|
||||||
public:
|
public:
|
||||||
@@ -170,6 +196,7 @@ KDiskDeviceManager::KDiskDeviceManager()
|
|||||||
fObsoletePartitions(new(nothrow) PartitionSet),
|
fObsoletePartitions(new(nothrow) PartitionSet),
|
||||||
fMediaChecker(-1),
|
fMediaChecker(-1),
|
||||||
fTerminating(false),
|
fTerminating(false),
|
||||||
|
fDiskSystemWatcher(NULL),
|
||||||
fDeviceWatcher(new(nothrow) DeviceWatcher(this))
|
fDeviceWatcher(new(nothrow) DeviceWatcher(this))
|
||||||
{
|
{
|
||||||
if (InitCheck() != B_OK)
|
if (InitCheck() != B_OK)
|
||||||
@@ -905,9 +932,17 @@ KDiskDeviceManager::StartMonitoring()
|
|||||||
{
|
{
|
||||||
// do another scan, this will populate the devfs directories
|
// do another scan, this will populate the devfs directories
|
||||||
InitialDeviceScan();
|
InitialDeviceScan();
|
||||||
|
|
||||||
|
// start monitoring the disk systems
|
||||||
|
fDiskSystemWatcher = new(std::nothrow) DiskSystemWatcher(this);
|
||||||
|
if (fDiskSystemWatcher != NULL) {
|
||||||
|
start_watching_modules(kFileSystemPrefix, *fDiskSystemWatcher);
|
||||||
|
start_watching_modules(kPartitioningSystemPrefix,
|
||||||
|
*fDiskSystemWatcher);
|
||||||
|
}
|
||||||
|
|
||||||
// start monitoring all dirs under /dev/disk
|
// start monitoring all dirs under /dev/disk
|
||||||
status_t result = _AddRemoveMonitoring("/dev/disk", true);
|
return _AddRemoveMonitoring("/dev/disk", true);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -959,10 +994,14 @@ KDiskDeviceManager::RescanDiskSystems()
|
|||||||
{
|
{
|
||||||
DiskSystemMap addedSystems;
|
DiskSystemMap addedSystems;
|
||||||
|
|
||||||
|
Lock();
|
||||||
|
|
||||||
// rescan for partitioning and file systems
|
// rescan for partitioning and file systems
|
||||||
_RescanDiskSystems(addedSystems, false);
|
_RescanDiskSystems(addedSystems, false);
|
||||||
_RescanDiskSystems(addedSystems, true);
|
_RescanDiskSystems(addedSystems, true);
|
||||||
|
|
||||||
|
Unlock();
|
||||||
|
|
||||||
// rescan existing devices with the new disk systems
|
// rescan existing devices with the new disk systems
|
||||||
int32 cookie = 0;
|
int32 cookie = 0;
|
||||||
while (KDiskDevice *device = RegisterNextDevice(&cookie)) {
|
while (KDiskDevice *device = RegisterNextDevice(&cookie)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user