Re: DiskDevice API v2.1

Tyler Dauwalder <tyler-cyCl/[email protected]>
Newsgroups gmane.os.openbeos.storage
Message-ID <[email protected]>
> > > Okay, that seemed to be a stupid idea :)
> > > But we should make sure that the user can see which tasks still
> > > have
> > > to be carried out
> > We could add methods to BDiskDeviceRoster to provide support for
> > that.
> > The typical iteration methods (GetNextActiveJob(BDiskDeviceJob*),
> > RewindActiveJobs()) and watching support (StartWatchingJobs(),
> > StopWatchingJobs()). BDiskDeviceJob (or better name=3D3F) would 
> > feature
> > methods for returning general information about the job, as well as
> > its
> > current progress.
> 
> Sounds good.

I added:

// disk device job types
enum {
	B_DISK_DEVICE_JOB_CREATE,
	B_DISK_DEVICE_JOB_DELETE,
	B_DISK_DEVICE_JOB_INITIALIZE,
	B_DISK_DEVICE_JOB_RESIZE,
	B_DISK_DEVICE_JOB_MOVE,
	B_DISK_DEVICE_JOB_DEFRAGMENT,
	B_DISK_DEVICE_JOB_REPAIR,
}

class BDiskDeviceJob {
public:
	int32 ID() const;
	uint32 Type() const;	
	uint8 Progress() const;		// 0 to 100
	bool Finished() const;	
	const char *Description() const;
	
	BPartition* Partition() const;
private:
	int32 fPartitionID;
	int32 fJobID;
};

// 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 
	B_DEVICE_REQUEST_DEVICE			= 0x10,	// device changes (media changes)
	B_DEVICE_REQUEST_DEVICE_LIST	= 0x20,	// device additions/removals
	B_DEVICE_REQUEST_JOBS			= 0x40, // job addition/initiation/completion
	B_DEVICE_REQUEST_ALL			= 0xff,	// all events
};

// 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_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
	B_DEVICE_MEDIA_CHANGED,				// media changed
	B_DEVICE_ADDED,						// device added
	B_DEVICE_REMOVED,					// device removed
	B_DEVICE_JOB_ADDED,					// job added
	B_DEVICE_JOB_INITIATED,				// job initiated
	B_DEVICE_JOB_FINISHED,				// job finished
};

class BDiskDeviceRoster {
public:
	status_t GetNextActiveJob(BDiskDeviceJob *job);
	status_t RewindActiveJobs();
};

I added job watching in with the rest of the watching codes instead of 
adding a new set of functions for it (they also have their own filter). 
I also expanded B_DEVICE_PARTITION_CHANGED to be a specific code for 
each type of change (initialize, resize, move, defrag, repair), since 
we have specific functions for those everywhere else. And as you now 
see, I added defragging and repairing to the API, too. So there are 
also these additions:

class BPartition {
public:
	bool CanDefragment() const;
	status_t Defragment() const;
	
	bool CanRepair(bool checkOnly) const;
	status_t Repair(bool checkOnly) const;
};

class BDiskSystem {
public:
	bool SupportsDefragmenting(BPartition *partition) const;
	bool SupportsRepairing(BPartition *partition, bool checkOnly) const;
};

Sound okay?

-Tyler
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.