2003-06-10 03:04:54 +04:00
|
|
|
// KDiskDeviceManager.h
|
|
|
|
|
|
|
|
#ifndef _K_DISK_DEVICE_MANAGER_H
|
|
|
|
#define _K_DISK_DEVICE_MANAGER_H
|
|
|
|
|
|
|
|
#include "disk_device_manager.h"
|
2003-06-11 02:35:57 +04:00
|
|
|
#include "Locker.h"
|
2003-06-10 03:04:54 +04:00
|
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
namespace DiskDevice {
|
|
|
|
|
|
|
|
class KDiskDevice;
|
|
|
|
class KDiskDeviceJob;
|
|
|
|
class KDiskDeviceJobQueue;
|
|
|
|
class KDiskSystem;
|
2003-06-23 03:00:20 +04:00
|
|
|
class KFileDiskDevice;
|
2003-06-10 03:04:54 +04:00
|
|
|
class KPartition;
|
|
|
|
|
|
|
|
class KDiskDeviceManager {
|
2003-06-11 02:35:57 +04:00
|
|
|
public:
|
2003-06-10 03:04:54 +04:00
|
|
|
KDiskDeviceManager();
|
|
|
|
~KDiskDeviceManager();
|
|
|
|
|
2003-06-11 02:35:57 +04:00
|
|
|
status_t InitCheck() const;
|
|
|
|
|
2003-06-10 03:04:54 +04:00
|
|
|
// Singleton Creation, Deletion, and Access
|
|
|
|
|
|
|
|
static status_t CreateDefault();
|
|
|
|
static void DeleteDefault();
|
|
|
|
static KDiskDeviceManager *Default();
|
|
|
|
|
|
|
|
// Locking
|
|
|
|
|
|
|
|
bool Lock();
|
|
|
|
void Unlock();
|
|
|
|
|
|
|
|
// Disk Device / Partition Management
|
|
|
|
|
2003-06-12 01:59:27 +04:00
|
|
|
// manager must be locked
|
2003-07-05 03:45:26 +04:00
|
|
|
KDiskDevice *FindDevice(const char *path);
|
2003-07-15 05:05:50 +04:00
|
|
|
KDiskDevice *FindDevice(partition_id id, bool deviceOnly = true);
|
2003-07-05 03:45:26 +04:00
|
|
|
KPartition *FindPartition(const char *path, bool noShadow = false);
|
|
|
|
KPartition *FindPartition(partition_id id, bool noShadow = false);
|
|
|
|
KFileDiskDevice *FindFileDevice(const char *filePath);
|
|
|
|
|
|
|
|
KDiskDevice *RegisterDevice(const char *path);
|
2003-07-15 05:05:50 +04:00
|
|
|
KDiskDevice *RegisterDevice(partition_id id, bool deviceOnly = true);
|
2003-06-13 02:21:10 +04:00
|
|
|
KDiskDevice *RegisterNextDevice(int32 *cookie);
|
2003-07-05 03:45:26 +04:00
|
|
|
KPartition *RegisterPartition(const char *path, bool noShadow = false);
|
|
|
|
KPartition *RegisterPartition(partition_id id, bool noShadow = false);
|
|
|
|
KFileDiskDevice *RegisterFileDevice(const char *filePath);
|
2003-06-23 03:00:20 +04:00
|
|
|
|
2003-07-16 01:39:34 +04:00
|
|
|
KDiskDevice *ReadLockDevice(partition_id id, bool deviceOnly = true);
|
|
|
|
KDiskDevice *WriteLockDevice(partition_id id, bool deviceOnly = true);
|
|
|
|
// The device is also registered and must be unregistered by the
|
|
|
|
// caller.
|
|
|
|
KPartition *ReadLockPartition(partition_id id);
|
|
|
|
KPartition *WriteLockPartition(partition_id id);
|
|
|
|
// Both the device and the partition is also registered and must be
|
|
|
|
// unregistered by the caller.
|
|
|
|
|
2003-07-15 05:05:50 +04:00
|
|
|
partition_id CreateFileDevice(const char *filePath);
|
2003-06-23 03:00:20 +04:00
|
|
|
status_t DeleteFileDevice(const char *filePath);
|
2003-07-15 05:05:50 +04:00
|
|
|
status_t DeleteFileDevice(partition_id id);
|
2003-06-10 03:04:54 +04:00
|
|
|
|
|
|
|
// manager must be locked
|
2003-06-13 02:21:10 +04:00
|
|
|
int32 CountDevices();
|
2003-07-02 20:29:33 +04:00
|
|
|
KDiskDevice *NextDevice(int32 *cookie);
|
2003-06-10 03:04:54 +04:00
|
|
|
|
2003-06-11 02:35:57 +04:00
|
|
|
bool PartitionAdded(KPartition *partition); // implementation internal
|
|
|
|
bool PartitionRemoved(KPartition *partition); //
|
2003-06-25 03:56:16 +04:00
|
|
|
bool DeletePartition(KPartition *partition); //
|
2003-06-10 03:04:54 +04:00
|
|
|
|
|
|
|
// Jobs
|
|
|
|
|
|
|
|
// manager must be locked
|
2003-06-11 02:35:57 +04:00
|
|
|
KDiskDeviceJob *JobWithID(disk_job_id id);
|
|
|
|
int32 CountJobs();
|
|
|
|
KDiskDeviceJob *JobAt(int32 index);
|
2003-06-10 03:04:54 +04:00
|
|
|
|
|
|
|
// manager must be locked
|
2003-06-11 02:35:57 +04:00
|
|
|
bool AddJobQueue(KDiskDeviceJobQueue *jobQueue);
|
|
|
|
int32 CountJobQueues();
|
|
|
|
KDiskDeviceJobQueue *JobQueueAt(int32 index);
|
2003-06-10 03:04:54 +04:00
|
|
|
|
|
|
|
// Disk Systems
|
|
|
|
|
|
|
|
// manager must be locked
|
2003-07-09 03:23:27 +04:00
|
|
|
KDiskSystem *FindDiskSystem(const char *name);
|
|
|
|
KDiskSystem *FindDiskSystem(disk_system_id id);
|
2003-06-11 02:35:57 +04:00
|
|
|
int32 CountDiskSystems();
|
2003-07-02 20:29:33 +04:00
|
|
|
KDiskSystem *NextDiskSystem(int32 *cookie);
|
2003-06-10 03:04:54 +04:00
|
|
|
|
2003-07-20 00:26:48 +04:00
|
|
|
KDiskSystem *LoadDiskSystem(const char *name);
|
2003-06-13 02:21:10 +04:00
|
|
|
KDiskSystem *LoadDiskSystem(disk_system_id id);
|
|
|
|
KDiskSystem *LoadNextDiskSystem(int32 *cookie);
|
|
|
|
|
2003-06-10 03:04:54 +04:00
|
|
|
// Watching
|
|
|
|
|
|
|
|
// TODO: Watching service for the kernel. The userland watching is handled
|
|
|
|
// by the registrar.
|
2003-06-11 02:35:57 +04:00
|
|
|
|
2003-06-13 02:21:10 +04:00
|
|
|
status_t InitialDeviceScan();
|
|
|
|
|
2003-06-11 02:35:57 +04:00
|
|
|
private:
|
2003-06-12 01:59:27 +04:00
|
|
|
status_t _AddPartitioningSystem(const char *name);
|
|
|
|
status_t _AddFileSystem(const char *name);
|
|
|
|
status_t _AddDiskSystem(KDiskSystem *diskSystem);
|
2003-06-11 02:35:57 +04:00
|
|
|
|
2003-06-14 02:08:10 +04:00
|
|
|
bool _AddDevice(KDiskDevice *device);
|
|
|
|
bool _RemoveDevice(KDiskDevice *device);
|
|
|
|
|
2003-06-13 02:21:10 +04:00
|
|
|
status_t _Scan(const char *path);
|
2003-06-23 03:00:20 +04:00
|
|
|
status_t _ScanDevice(KDiskDevice *device);
|
2003-06-13 02:21:10 +04:00
|
|
|
status_t _ScanPartition(KPartition *partition);
|
|
|
|
|
2003-07-02 20:29:33 +04:00
|
|
|
struct DeviceMap;
|
|
|
|
struct DiskSystemMap;
|
|
|
|
struct PartitionMap;
|
|
|
|
struct PartitionSet;
|
|
|
|
|
2003-06-11 02:35:57 +04:00
|
|
|
BLocker fLock;
|
2003-07-02 20:29:33 +04:00
|
|
|
DeviceMap *fDevices;
|
|
|
|
PartitionMap *fPartitions;
|
|
|
|
DiskSystemMap *fDiskSystems;
|
|
|
|
PartitionSet *fObsoletePartitions;
|
2003-06-11 02:35:57 +04:00
|
|
|
|
|
|
|
static KDiskDeviceManager *fDefaultManager;
|
2003-06-10 03:04:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace DiskDevice
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
|
|
|
using BPrivate::DiskDevice::KDiskDeviceManager;
|
|
|
|
|
|
|
|
#endif // _K_DISK_DEVICE_MANAGER_H
|