* Copyright 2003-2008, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _DISK_DEVICE_ROSTER_H
#define _DISK_DEVICE_ROSTER_H
#include <image.h>
#include <DiskDeviceDefs.h>
#include <Messenger.h>
#include <SupportDefs.h>
class BDirectory;
class BDiskDevice;
class BDiskDeviceVisiting;
class BDiskDeviceVisitor;
class BDiskScannerPartitionAddOn;
class BDiskSystem;
class BPartition;
class BVolume;
namespace BPrivate {
class AddOnImage;
}
enum {
B_DEVICE_REQUEST_MOUNT_POINT = 0x0001,
B_DEVICE_REQUEST_MOUNTING = 0x0002,
B_DEVICE_REQUEST_PARTITION = 0x0004,
B_DEVICE_REQUEST_DEVICE = 0x0008,
B_DEVICE_REQUEST_DEVICE_LIST = 0x0010,
B_DEVICE_REQUEST_JOB_LIST = 0x0020,
B_DEVICE_REQUEST_JOB_SIMPLE_PROGRESS = 0x0040,
B_DEVICE_REQUEST_JOB_EXTRA_PROGRESS = 0x0080,
B_DEVICE_REQUEST_JOB_COMPLETE_PROGRESS = 0x00C0,
B_DEVICE_REQUEST_ALL = 0xffff,
};
enum {
B_DEVICE_UPDATE = 'DUPD'
};
enum {
B_DEVICE_MOUNT_POINT_MOVED,
B_DEVICE_PARTITION_MOUNTED,
B_DEVICE_PARTITION_UNMOUNTED,
B_DEVICE_PARTITION_INITIALIZED,
B_DEVICE_PARTITION_RESIZED,
B_DEVICE_PARTITION_MOVED,
B_DEVICE_PARTITION_CREATED,
B_DEVICE_PARTITION_DELETED,
B_DEVICE_PARTITION_DEFRAGMENTED,
B_DEVICE_PARTITION_REPAIRED,
B_DEVICE_MEDIA_CHANGED,
B_DEVICE_ADDED,
B_DEVICE_REMOVED,
B_DEVICE_JOB_SCHEDULED,
B_DEVICE_JOB_INITIATED,
B_DEVICE_JOB_CANCELED,
B_DEVICE_JOB_FINISHED,
B_DEVICE_JOB_SIMPLE_PROGRESS,
B_DEVICE_JOB_EXTRA_PROGRESS,
};
enum {
B_DEVICE_CAUSE_MEDIA_CHANGED,
B_DEVICE_CAUSE_FORMATTED,
B_DEVICE_CAUSE_PARTITIONED,
B_DEVICE_CAUSE_INITIALIZED,
B_DEVICE_CAUSE_UNKNOWN,
B_DEVICE_CAUSE_PARENT_CHANGED,
};
class BDiskDeviceRoster {
public:
BDiskDeviceRoster();
~BDiskDeviceRoster();
status_t GetNextDevice(BDiskDevice* device);
status_t RewindDevices();
status_t GetNextDiskSystem(BDiskSystem* system);
status_t RewindDiskSystems();
status_t GetDiskSystem(BDiskSystem* system, const char* name);
partition_id RegisterFileDevice(const char* filename);
status_t UnregisterFileDevice(const char* filename);
status_t UnregisterFileDevice(partition_id device);
bool VisitEachDevice(BDiskDeviceVisitor* visitor,
BDiskDevice* device = NULL);
bool VisitEachPartition(BDiskDeviceVisitor* visitor,
BDiskDevice* device = NULL,
BPartition** _partition = NULL);
bool VisitEachMountedPartition(
BDiskDeviceVisitor* visitor,
BDiskDevice* device = NULL,
BPartition** _partition = NULL);
bool VisitEachMountablePartition(
BDiskDeviceVisitor* visitor,
BDiskDevice* device = NULL,
BPartition** _partition = NULL);
status_t FindPartitionByVolume(const BVolume& volume,
BDiskDevice* device,
BPartition** _partition);
status_t FindPartitionByMountPoint(const char* mountPoint,
BDiskDevice* device,
BPartition** _partition);
status_t GetDeviceWithID(partition_id id,
BDiskDevice* device) const;
status_t GetPartitionWithID(partition_id id,
BDiskDevice* device,
BPartition** _partition) const;
status_t GetDeviceForPath(const char* filename,
BDiskDevice* device);
status_t GetPartitionForPath(const char* filename,
BDiskDevice* device, BPartition** _partition);
status_t GetFileDeviceForPath(const char* filename,
BDiskDevice* device);
status_t StartWatching(BMessenger target,
uint32 eventMask = B_DEVICE_REQUEST_ALL);
status_t StopWatching(BMessenger target);
private:
#if 0
status_t _GetObjectWithID(const char *fieldName, partition_id id,
BDiskDevice *device) const;
static status_t _GetNextAddOn(BDirectory **directory, int32 *index,
const char *subdir,
BPrivate::AddOnImage *image);
static status_t _GetNextAddOn(BDirectory *directory,
BPrivate::AddOnImage *image);
static status_t _GetNextAddOnDir(BPath *path, int32 *index,
const char *subdir);
static status_t _GetNextAddOnDir(BDirectory **directory, int32 *index,
const char *subdir);
static status_t _LoadPartitionAddOn(const char *partitioningSystem,
BPrivate::AddOnImage *image,
BDiskScannerPartitionAddOn **addOn);
#endif
private:
int32 fDeviceCookie;
int32 fDiskSystemCookie;
int32 fJobCookie;
};
#endif