2008-05-10 15:44:00 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2003-2008, Haiku Inc.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2003-02-01 00:17:20 +03:00
|
|
|
#ifndef _DISK_DEVICE_ROSTER_H
|
|
|
|
#define _DISK_DEVICE_ROSTER_H
|
|
|
|
|
2003-02-23 02:50:14 +03:00
|
|
|
#include <image.h>
|
|
|
|
|
2003-07-07 03:11:10 +04:00
|
|
|
#include <DiskDeviceDefs.h>
|
2003-02-01 21:12:03 +03:00
|
|
|
#include <Messenger.h>
|
2003-02-01 00:17:20 +03:00
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
2003-02-23 02:50:14 +03:00
|
|
|
class BDirectory;
|
2003-02-01 00:17:20 +03:00
|
|
|
class BDiskDevice;
|
2004-11-01 18:25:37 +03:00
|
|
|
class BDiskDeviceVisiting;
|
2003-07-07 03:11:10 +04:00
|
|
|
class BDiskDeviceVisitor;
|
2003-02-23 02:50:14 +03:00
|
|
|
class BDiskScannerPartitionAddOn;
|
2003-05-29 01:46:11 +04:00
|
|
|
class BDiskSystem;
|
2003-02-01 00:17:20 +03:00
|
|
|
class BPartition;
|
2008-10-27 18:33:37 +03:00
|
|
|
class BVolume;
|
2003-02-01 00:17:20 +03:00
|
|
|
|
2003-02-23 02:50:14 +03:00
|
|
|
namespace BPrivate {
|
|
|
|
class AddOnImage;
|
|
|
|
}
|
|
|
|
|
2003-02-01 00:17:20 +03:00
|
|
|
// watchable events
|
|
|
|
enum {
|
2003-05-29 01:47:29 +04:00
|
|
|
// Basic masks
|
|
|
|
B_DEVICE_REQUEST_MOUNT_POINT = 0x0001, // mount point changes
|
|
|
|
B_DEVICE_REQUEST_MOUNTING = 0x0002, // mounting/unmounting
|
2008-10-14 01:51:43 +04:00
|
|
|
B_DEVICE_REQUEST_PARTITION = 0x0004, // partition changes
|
2003-05-29 01:47:29 +04:00
|
|
|
B_DEVICE_REQUEST_DEVICE = 0x0008, // device changes (media changes)
|
|
|
|
B_DEVICE_REQUEST_DEVICE_LIST = 0x0010, // device additions/removals
|
|
|
|
B_DEVICE_REQUEST_JOB_LIST = 0x0020, // job addition/initiation/cancellation/completion
|
|
|
|
B_DEVICE_REQUEST_JOB_SIMPLE_PROGRESS = 0x0040, // simple job progress (i.e. "% complete" only)
|
|
|
|
B_DEVICE_REQUEST_JOB_EXTRA_PROGRESS = 0x0080, // extra info on job progress (no "% complete" info)
|
|
|
|
|
|
|
|
// Combination masks
|
|
|
|
B_DEVICE_REQUEST_JOB_COMPLETE_PROGRESS = 0x00C0, // complete job progress info
|
|
|
|
B_DEVICE_REQUEST_ALL = 0xffff, // all events
|
2003-02-01 00:17:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// notification message "what" field
|
|
|
|
// TODO: move to app/AppDefs.h
|
|
|
|
enum {
|
|
|
|
B_DEVICE_UPDATE = 'DUPD'
|
|
|
|
};
|
|
|
|
|
|
|
|
// notification message "event" field values
|
|
|
|
enum {
|
|
|
|
B_DEVICE_MOUNT_POINT_MOVED, // mount point moved/renamed
|
|
|
|
B_DEVICE_PARTITION_MOUNTED, // partition mounted
|
|
|
|
B_DEVICE_PARTITION_UNMOUNTED, // partition unmounted
|
2003-05-29 01:46:11 +04:00
|
|
|
B_DEVICE_PARTITION_INITIALIZED, // partition initialized
|
|
|
|
B_DEVICE_PARTITION_RESIZED, // partition resized
|
|
|
|
B_DEVICE_PARTITION_MOVED, // partition moved
|
|
|
|
B_DEVICE_PARTITION_CREATED, // partition created
|
|
|
|
B_DEVICE_PARTITION_DELETED, // partition deleted
|
|
|
|
B_DEVICE_PARTITION_DEFRAGMENTED, // partition defragmented
|
|
|
|
B_DEVICE_PARTITION_REPAIRED, // partition repaired
|
2003-02-01 00:17:20 +03:00
|
|
|
B_DEVICE_MEDIA_CHANGED, // media changed
|
|
|
|
B_DEVICE_ADDED, // device added
|
2003-05-29 01:46:11 +04:00
|
|
|
B_DEVICE_REMOVED, // device removed
|
2003-05-29 01:47:29 +04:00
|
|
|
B_DEVICE_JOB_SCHEDULED, // job added
|
2003-05-29 01:46:11 +04:00
|
|
|
B_DEVICE_JOB_INITIATED, // job initiated
|
2003-05-29 01:47:29 +04:00
|
|
|
B_DEVICE_JOB_CANCELED, // job canceled
|
2003-05-29 01:46:11 +04:00
|
|
|
B_DEVICE_JOB_FINISHED, // job finished
|
2003-05-29 01:47:29 +04:00
|
|
|
B_DEVICE_JOB_SIMPLE_PROGRESS, // job percent complete progress
|
|
|
|
B_DEVICE_JOB_EXTRA_PROGRESS, // extended job progress info
|
2003-02-01 00:17:20 +03:00
|
|
|
};
|
|
|
|
|
2003-02-15 02:12:47 +03:00
|
|
|
// notification message "cause" field values
|
|
|
|
enum {
|
|
|
|
// helpful causes
|
|
|
|
B_DEVICE_CAUSE_MEDIA_CHANGED,
|
2003-05-29 01:46:11 +04:00
|
|
|
B_DEVICE_CAUSE_FORMATTED, // is this still applicable?
|
|
|
|
B_DEVICE_CAUSE_PARTITIONED, // is this still applicable?
|
|
|
|
B_DEVICE_CAUSE_INITIALIZED, // is this still applicable?
|
2003-02-15 02:12:47 +03:00
|
|
|
// unknown cause
|
|
|
|
B_DEVICE_CAUSE_UNKNOWN,
|
|
|
|
// for internal use only (e.g.: partition added, because device added)
|
|
|
|
B_DEVICE_CAUSE_PARENT_CHANGED,
|
|
|
|
};
|
|
|
|
|
2003-02-01 00:17:20 +03:00
|
|
|
class BDiskDeviceRoster {
|
|
|
|
public:
|
2008-05-10 15:44:00 +04:00
|
|
|
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);
|
|
|
|
// publishes: /dev/disk/virtual/files/<disk device ID>/raw
|
|
|
|
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);
|
|
|
|
|
2008-10-27 18:33:37 +03:00
|
|
|
status_t FindPartitionByVolume(BVolume* volume,
|
|
|
|
BDiskDevice* device,
|
|
|
|
BPartition** _partition);
|
|
|
|
status_t FindPartitionByMountPoint(const char* mountPoint,
|
|
|
|
BDiskDevice* device,
|
|
|
|
BPartition** _partition);
|
|
|
|
|
2008-05-10 15:44:00 +04:00
|
|
|
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);
|
2008-10-14 01:51:43 +04:00
|
|
|
status_t GetFileDeviceForPath(const char* filename,
|
|
|
|
BDiskDevice* device);
|
2008-05-10 15:44:00 +04:00
|
|
|
|
|
|
|
status_t StartWatching(BMessenger target,
|
|
|
|
uint32 eventMask = B_DEVICE_REQUEST_ALL);
|
|
|
|
status_t StopWatching(BMessenger target);
|
2003-02-01 00:17:20 +03:00
|
|
|
|
2003-02-09 02:34:47 +03:00
|
|
|
private:
|
2003-07-07 03:11:10 +04:00
|
|
|
#if 0
|
2003-06-10 03:02:16 +04:00
|
|
|
status_t _GetObjectWithID(const char *fieldName, partition_id id,
|
2003-02-09 02:34:47 +03:00
|
|
|
BDiskDevice *device) const;
|
|
|
|
|
2003-02-23 02:50:14 +03:00
|
|
|
// TODO: Introduce iterators instead of these functions.
|
|
|
|
|
2003-06-10 03:02:16 +04:00
|
|
|
static status_t _GetNextAddOn(BDirectory **directory, int32 *index,
|
2003-02-23 02:50:14 +03:00
|
|
|
const char *subdir,
|
|
|
|
BPrivate::AddOnImage *image);
|
|
|
|
static status_t _GetNextAddOn(BDirectory *directory,
|
|
|
|
BPrivate::AddOnImage *image);
|
2003-06-10 03:02:16 +04:00
|
|
|
static status_t _GetNextAddOnDir(BPath *path, int32 *index,
|
2003-02-23 02:50:14 +03:00
|
|
|
const char *subdir);
|
2003-06-10 03:02:16 +04:00
|
|
|
static status_t _GetNextAddOnDir(BDirectory **directory, int32 *index,
|
2003-02-23 02:50:14 +03:00
|
|
|
const char *subdir);
|
|
|
|
|
|
|
|
static status_t _LoadPartitionAddOn(const char *partitioningSystem,
|
|
|
|
BPrivate::AddOnImage *image,
|
|
|
|
BDiskScannerPartitionAddOn **addOn);
|
2003-07-07 03:11:10 +04:00
|
|
|
#endif // 0
|
2003-02-01 00:17:20 +03:00
|
|
|
private:
|
2008-05-10 15:44:00 +04:00
|
|
|
int32 fDeviceCookie;
|
|
|
|
int32 fDiskSystemCookie;
|
|
|
|
int32 fJobCookie;
|
2003-07-07 03:11:10 +04:00
|
|
|
// BDirectory *fPartitionAddOnDir;
|
|
|
|
// BDirectory *fFSAddOnDir;
|
|
|
|
// int32 fPartitionAddOnDirIndex;
|
|
|
|
// int32 fFSAddOnDirIndex;
|
2003-02-01 00:17:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _DISK_DEVICE_ROSTER_H
|