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;
|
2003-07-30 04:18:16 +04:00
|
|
|
class KDiskDeviceJobFactory;
|
2003-06-10 03:04:54 +04:00
|
|
|
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-07-30 04:18:16 +04:00
|
|
|
KDiskDeviceJob *FindJob(disk_job_id id);
|
2003-06-11 02:35:57 +04:00
|
|
|
int32 CountJobs();
|
2003-07-30 04:18:16 +04:00
|
|
|
KDiskDeviceJob *NextJob(int32 *cookie);
|
2003-06-10 03:04:54 +04:00
|
|
|
|
|
|
|
// manager must be locked
|
2003-07-30 04:18:16 +04:00
|
|
|
status_t AddJobQueue(KDiskDeviceJobQueue *jobQueue);
|
2003-08-03 22:39:12 +04:00
|
|
|
// the device must be write locked
|
2003-07-30 04:18:16 +04:00
|
|
|
status_t RemoveJobQueue(KDiskDeviceJobQueue *jobQueue);
|
|
|
|
status_t DeleteJobQueue(KDiskDeviceJobQueue *jobQueue);
|
|
|
|
// called when the execution is done
|
2003-06-11 02:35:57 +04:00
|
|
|
int32 CountJobQueues();
|
2003-07-30 04:18:16 +04:00
|
|
|
KDiskDeviceJobQueue *NextJobQueue(int32 *cookie);
|
2003-06-10 03:04:54 +04:00
|
|
|
|
2003-08-02 03:59:26 +04:00
|
|
|
KDiskDeviceJobFactory *JobFactory() const;
|
|
|
|
|
2003-08-03 22:39:12 +04:00
|
|
|
// manager must *not* be locked
|
|
|
|
status_t UpdateBusyPartitions(KDiskDevice *device);
|
|
|
|
status_t UpdateJobStatus(KDiskDeviceJob *job, uint32 status,
|
|
|
|
bool updateBusyPartitions);
|
|
|
|
|
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-07-30 04:18:16 +04:00
|
|
|
bool _RemoveJobQueue(KDiskDeviceJobQueue *jobQueue);
|
|
|
|
|
2003-08-03 22:39:12 +04:00
|
|
|
status_t _UpdateBusyPartitions(KDiskDevice *device);
|
|
|
|
status_t _UpdateJobStatus(KDiskDeviceJob *job, uint32 status,
|
|
|
|
bool updateBusyPartitions);
|
|
|
|
|
2003-06-13 02:21:10 +04:00
|
|
|
status_t _Scan(const char *path);
|
|
|
|
status_t _ScanPartition(KPartition *partition);
|
2003-08-03 22:39:12 +04:00
|
|
|
// the manager must be locked and the device write locked
|
2003-06-13 02:21:10 +04:00
|
|
|
|
2003-07-02 20:29:33 +04:00
|
|
|
struct DeviceMap;
|
|
|
|
struct DiskSystemMap;
|
2003-07-30 04:18:16 +04:00
|
|
|
struct JobMap;
|
|
|
|
struct JobQueueVector;
|
2003-07-02 20:29:33 +04:00
|
|
|
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-07-30 04:18:16 +04:00
|
|
|
JobMap *fJobs;
|
|
|
|
JobQueueVector *fJobQueues;
|
|
|
|
KDiskDeviceJobFactory *fJobFactory;
|
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
|