Added registration of a file device and invocations of {Prepare,Cancel}Modifications(). Looks good so far.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3981 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b8ea76bfc3
commit
7fcdfb5fb8
@ -20,6 +20,8 @@
|
||||
//#include <ObjectList.h>
|
||||
#include <OS.h>
|
||||
|
||||
const char *kTestFileDevice = "/boot/home/tmp/test-file-device";
|
||||
|
||||
// DumpVisitor
|
||||
class DumpVisitor : public BDiskDeviceVisitor {
|
||||
public:
|
||||
@ -506,8 +508,12 @@ main()
|
||||
KDiskDeviceManager::CreateDefault();
|
||||
KDiskDeviceManager::Default()->InitialDeviceScan();
|
||||
|
||||
// list all disk devices and partitions
|
||||
// add a file device
|
||||
BDiskDeviceRoster roster;
|
||||
partition_id id = roster.RegisterFileDevice(kTestFileDevice);
|
||||
if (id < B_OK)
|
||||
printf("registering the file device failed: %s\n", strerror(id));
|
||||
// list all disk devices and partitions
|
||||
DumpVisitor visitor;
|
||||
roster.VisitAll(&visitor);
|
||||
// list disk systems
|
||||
@ -519,6 +525,21 @@ main()
|
||||
printf(" file system: %d (!%d)\n", diskSystem.IsFileSystem(),
|
||||
diskSystem.IsPartitioningSystem());
|
||||
}
|
||||
// get the file device
|
||||
BDiskDevice device;
|
||||
status_t error = roster.GetDeviceWithID(id, &device);
|
||||
if (error != B_OK)
|
||||
printf("Couldn't get device: %s\n", strerror(error));
|
||||
// prepare for modifications
|
||||
error = device.PrepareModifications();
|
||||
if (error != B_OK)
|
||||
printf("Preparing modifications failed: %s\n", strerror(error));
|
||||
// cancel modifications
|
||||
if (error == B_OK) {
|
||||
error = device.CancelModifications();
|
||||
if (error != B_OK)
|
||||
printf("Cancelling modifications failed: %s\n", strerror(error));
|
||||
}
|
||||
|
||||
// for userland testing only
|
||||
KDiskDeviceManager::DeleteDefault();
|
||||
|
Loading…
Reference in New Issue
Block a user