The beginning of the DiskDevice API.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2609 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f971378f16
commit
d713d1d973
64
headers/private/storage/DiskDevice.h
Normal file
64
headers/private/storage/DiskDevice.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
// DiskDevice.h
|
||||||
|
|
||||||
|
#ifndef _DISK_DEVICE_H
|
||||||
|
#define _DISK_DEVICE_H
|
||||||
|
|
||||||
|
#include <DiskDeviceVisitor.h>
|
||||||
|
#include <ObjectList.h>
|
||||||
|
|
||||||
|
class BPartition;
|
||||||
|
class BSession;
|
||||||
|
|
||||||
|
class BDiskDevice {
|
||||||
|
public:
|
||||||
|
BDiskDevice();
|
||||||
|
~BDiskDevice();
|
||||||
|
|
||||||
|
int32 CountSessions() const;
|
||||||
|
BSession *SessionAt(int32 index) const;
|
||||||
|
|
||||||
|
int32 CountPartitions() const;
|
||||||
|
|
||||||
|
int32 BlockSize() const;
|
||||||
|
|
||||||
|
const char *DevicePath() const;
|
||||||
|
void GetName(BString *name, bool includeBusID = true,
|
||||||
|
bool includeLUN = false) const;
|
||||||
|
void GetName(char *name, bool includeBusID = true,
|
||||||
|
bool includeLUN = false) const;
|
||||||
|
|
||||||
|
bool IsReadOnly() const;
|
||||||
|
bool IsRemovable() const;
|
||||||
|
bool HasMedia() const;
|
||||||
|
bool IsFloppy() const;
|
||||||
|
uint8 Type() const; // cf. device_geometry::device_type
|
||||||
|
|
||||||
|
int32 UniqueID() const;
|
||||||
|
|
||||||
|
status_t Eject();
|
||||||
|
status_t LowLevelFormat(); // TODO: remove?
|
||||||
|
|
||||||
|
status_t Update(); // sync this object with reality
|
||||||
|
|
||||||
|
BSession *VisitEachSession(BDiskDeviceVisitor *visitor);
|
||||||
|
// return BSession* if terminated early
|
||||||
|
BPartition *VisitEachPartition(BDiskDeviceVisitor *visitor);
|
||||||
|
// return BPartition* if terminated early
|
||||||
|
bool Traverse(BDiskDeviceVisitor *visitor);
|
||||||
|
// return true if terminated early
|
||||||
|
|
||||||
|
private:
|
||||||
|
BDiskDevice(const BDiskDevice &);
|
||||||
|
BDiskDevice &operator=(const BDiskDevice &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BObjectList<Session *> fSessions;
|
||||||
|
int32 fUniqueID;
|
||||||
|
int32 fBlockSize;
|
||||||
|
char fPath[B_FILE_NAME_LENGTH];
|
||||||
|
bool fReadOnly;
|
||||||
|
bool fRemovable;
|
||||||
|
bool fIsFloppy;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _DISK_DEVICE_H
|
90
headers/private/storage/DiskDeviceRoster.h
Normal file
90
headers/private/storage/DiskDeviceRoster.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
// DiskDeviceRoster.h
|
||||||
|
|
||||||
|
#ifndef _DISK_DEVICE_ROSTER_H
|
||||||
|
#define _DISK_DEVICE_ROSTER_H
|
||||||
|
|
||||||
|
#include <DiskDeviceVisitor.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
class BDiskDevice;
|
||||||
|
class BPartition;
|
||||||
|
class BSession;
|
||||||
|
|
||||||
|
// watchable events
|
||||||
|
enum {
|
||||||
|
B_DEVICE_REQUEST_MOUNT_POINT = 0x01, // mount point changes
|
||||||
|
B_DEVICE_REQUEST_MOUNTING = 0x02, // mounting/unmounting
|
||||||
|
B_DEVICE_REQUEST_PARTITION = 0x04, // partition changes (initial.)
|
||||||
|
B_DEVICE_REQUEST_SESSION = 0x08, // session changes (partitioning)
|
||||||
|
B_DEVICE_REQUEST_DEVICE = 0x10, // device changes (media changes)
|
||||||
|
B_DEVICE_REQUEST_DEVICE_LIST = 0x20, // device additions/removals
|
||||||
|
B_DEVICE_REQUEST_ALL = 0xff, // all events
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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
|
||||||
|
B_DEVICE_PARTITION_CHANGED, // partition changed, e.g. initialized
|
||||||
|
// or resized
|
||||||
|
B_DEVICE_PARTITION_ADDED, // partition added
|
||||||
|
B_DEVICE_PARTITION_REMOVED, // partition removed
|
||||||
|
B_DEVICE_MEDIA_CHANGED, // media changed
|
||||||
|
B_DEVICE_ADDED, // device added
|
||||||
|
B_DEVICE_REMOVED // device removed
|
||||||
|
};
|
||||||
|
|
||||||
|
class BDiskDeviceRoster {
|
||||||
|
public:
|
||||||
|
BDiskDeviceRoster();
|
||||||
|
~BDiskDeviceRoster();
|
||||||
|
|
||||||
|
status_t GetNextDevice(BDiskDevice *device);
|
||||||
|
status_t Rewind();
|
||||||
|
|
||||||
|
bool VisitEachDevice(BDiskDeviceVisitor *visitor,
|
||||||
|
BDiskDevice *device = NULL);
|
||||||
|
// return true if terminated early
|
||||||
|
|
||||||
|
bool VisitEachPartition(BDiskDeviceVisitor *visitor,
|
||||||
|
BDiskDevice *device = NULL,
|
||||||
|
BPartition **partition = NULL);
|
||||||
|
// return true if terminated early
|
||||||
|
bool Traverse(BDiskDeviceVisitor *visitor);
|
||||||
|
// return true if terminated early
|
||||||
|
|
||||||
|
bool VisitEachMountedPartition(BDiskDeviceVisitor *visitor,
|
||||||
|
BDiskDevice *device = NULL,
|
||||||
|
BPartition **partition = NULL);
|
||||||
|
// return true if terminated early
|
||||||
|
bool VisitEachMountablePartition(BDiskDeviceVisitor *visitor,
|
||||||
|
BDiskDevice *device = NULL,
|
||||||
|
BPartition **partition = NULL);
|
||||||
|
// return true if terminated early
|
||||||
|
bool VisitEachInitializablePartition(BDiskDeviceVisitor *visitor,
|
||||||
|
BDiskDevice *device = NULL,
|
||||||
|
BPartition **partition = NULL);
|
||||||
|
// return true if terminated early
|
||||||
|
|
||||||
|
BDiskDevice *DeviceWithID(int32 id) const;
|
||||||
|
BSession *SessionWithID(int32 id, BDiskDevice *device) const;
|
||||||
|
// inits device to the device containing the session
|
||||||
|
BPartition *PartitionWithID(int32 id, BDiskDevice *device) const;
|
||||||
|
// inits device to the device containing the partition
|
||||||
|
|
||||||
|
status_t StartWatching(BMessenger target,
|
||||||
|
uint32 eventMask = B_DEVICE_REQUEST_ALL);
|
||||||
|
status_t StopWatching(BMessenger target);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32 fDeviceID; // iteration state
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _DISK_DEVICE_ROSTER_H
|
21
headers/private/storage/DiskDeviceVisitor.h
Normal file
21
headers/private/storage/DiskDeviceVisitor.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// DiskDeviceIteration.h
|
||||||
|
|
||||||
|
#ifndef _DISK_DEVICE_VISITOR_H
|
||||||
|
#define _DISK_DEVICE_VISITOR_H
|
||||||
|
|
||||||
|
class BDiskDevice;
|
||||||
|
class BPartition;
|
||||||
|
class BSession;
|
||||||
|
|
||||||
|
// BDiskDeviceVisitor
|
||||||
|
class BDiskDeviceVisitor {
|
||||||
|
BDiskDeviceVisitor();
|
||||||
|
virtual ~BDiskDeviceVisitor();
|
||||||
|
|
||||||
|
// return true to abort iteration
|
||||||
|
virtual bool Visit(BDiskDevice *device);
|
||||||
|
virtual bool Visit(BSession *device);
|
||||||
|
virtual bool Visit(BPartition *device);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif _DISK_DEVICE_VISITOR_H
|
79
headers/private/storage/Partition.h
Normal file
79
headers/private/storage/Partition.h
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// Partition.h
|
||||||
|
|
||||||
|
#ifndef _PARTITION_H
|
||||||
|
#define _PARTITION_H
|
||||||
|
|
||||||
|
#include <fs_device.h>
|
||||||
|
#include <Mime.h>
|
||||||
|
#include <ObjectList.h>
|
||||||
|
#include <Point.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
|
class BDiskDevice;
|
||||||
|
class BSession;
|
||||||
|
class BVolume;
|
||||||
|
|
||||||
|
class BPartition {
|
||||||
|
public:
|
||||||
|
BPartition();
|
||||||
|
~BPartition();
|
||||||
|
|
||||||
|
BSession *Session() const;
|
||||||
|
BDiskDevice *Device() const;
|
||||||
|
|
||||||
|
off_t Offset() const;
|
||||||
|
off_t Size() const;
|
||||||
|
int32 BlockSize() const;
|
||||||
|
int32 Index() const;
|
||||||
|
|
||||||
|
uint32 Flags() const;
|
||||||
|
bool IsHidden() const;
|
||||||
|
bool IsVirtual() const;
|
||||||
|
bool IsEmpty() const;
|
||||||
|
|
||||||
|
const char *Name() const;
|
||||||
|
const char *Type() const;
|
||||||
|
const char *FileSystemShortName() const;
|
||||||
|
const char *FileSystemLongName() const;
|
||||||
|
const char *VolumeName() const;
|
||||||
|
|
||||||
|
uint32 FileSystemFlags() const;
|
||||||
|
|
||||||
|
bool IsMounted() const;
|
||||||
|
|
||||||
|
int32 UniqueID() const;
|
||||||
|
|
||||||
|
status_t GetVolume(BVolume *volume) const;
|
||||||
|
|
||||||
|
status_t GetIcon(BBitmap *icon, icon_size which) const;
|
||||||
|
|
||||||
|
status_t Mount(uint32 mountflags = 0, const char *parameters = NULL);
|
||||||
|
status_t Unmount();
|
||||||
|
|
||||||
|
status_t GetInitializationParameters(const char *fileSystem,
|
||||||
|
BPoint dialogCenter,
|
||||||
|
BString *parameters,
|
||||||
|
bool *cancelled = NULL);
|
||||||
|
status_t Initialize(const char *fileSystem, const char *parameters);
|
||||||
|
status_t Initialize(const char *fileSystem = "bfs",
|
||||||
|
BPoint dialogCenter = BPoint(-1, -1),
|
||||||
|
bool *cancelled = NULL);
|
||||||
|
|
||||||
|
static status_t GetFileSystemList(BObjectList<BString*> *list);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BPartition(const BPartition &);
|
||||||
|
BPartition &operator=(const BPartition &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BSession *fSession;
|
||||||
|
// TODO: Also contains the device name, which we can get from Device() anyway.
|
||||||
|
// We could either remove it from extended_partition_info or list
|
||||||
|
// the individual fields here.
|
||||||
|
extended_partition_info fInfo;
|
||||||
|
int32 fUniqueID;
|
||||||
|
dev_t fVolumeID;
|
||||||
|
node_ref fMountPoint;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _PARTITION_H
|
64
headers/private/storage/Session.h
Normal file
64
headers/private/storage/Session.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
// Session.h
|
||||||
|
|
||||||
|
#ifndef _SESSION_H
|
||||||
|
#define _SESSION_H
|
||||||
|
|
||||||
|
#include <DiskDeviceVisitor.h>
|
||||||
|
#include <fs_device.h>
|
||||||
|
#include <ObjectList.h>
|
||||||
|
#include <Point.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
|
class BDiskDevice;
|
||||||
|
class BPartition;
|
||||||
|
|
||||||
|
extern const char *B_INTEL_PARTITION_STYLE;
|
||||||
|
|
||||||
|
class BSession {
|
||||||
|
public:
|
||||||
|
BSession();
|
||||||
|
~BSession();
|
||||||
|
|
||||||
|
BDiskDevice *Device() const;
|
||||||
|
|
||||||
|
off_t Offset() const;
|
||||||
|
off_t Size() const;
|
||||||
|
|
||||||
|
int32 CountPartitions() const;
|
||||||
|
BPartition *PartitionAt(int32 index) const;
|
||||||
|
|
||||||
|
int32 Index() const;
|
||||||
|
|
||||||
|
uint32 Flags() const;
|
||||||
|
bool IsAudio() const;
|
||||||
|
bool IsData() const;
|
||||||
|
bool IsVirtual() const;
|
||||||
|
|
||||||
|
const char *PartitionStyle() const;
|
||||||
|
|
||||||
|
int32 UniqueID() const;
|
||||||
|
|
||||||
|
BPartition *EachPartition(BDiskDeviceVisitor *visitor);
|
||||||
|
// return BPartition* if terminated early
|
||||||
|
|
||||||
|
status_t GetPartitioningParameters(const char *partitioningSystem,
|
||||||
|
BPoint dialogCenter,
|
||||||
|
BString *parameters,
|
||||||
|
bool *cancelled = NULL);
|
||||||
|
status_t Partition(const char *partitioningSystem, const char *parameters);
|
||||||
|
status_t Partition(const char *partitioningSystem,
|
||||||
|
BPoint dialogCenter = BPoint(-1, -1),
|
||||||
|
bool *cancelled = NULL);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BSession(const BSession &);
|
||||||
|
BSession &operator=(const BSession &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BDiskDevice *fDevice;
|
||||||
|
BObjectList<BPartition *> fPartitions;
|
||||||
|
int32 fUniqueID;
|
||||||
|
session_info fInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _SESSION_H
|
Loading…
x
Reference in New Issue
Block a user