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:
@@ -20,6 +20,8 @@
|
|||||||
//#include <ObjectList.h>
|
//#include <ObjectList.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
|
const char *kTestFileDevice = "/boot/home/tmp/test-file-device";
|
||||||
|
|
||||||
// DumpVisitor
|
// DumpVisitor
|
||||||
class DumpVisitor : public BDiskDeviceVisitor {
|
class DumpVisitor : public BDiskDeviceVisitor {
|
||||||
public:
|
public:
|
||||||
@@ -506,8 +508,12 @@ main()
|
|||||||
KDiskDeviceManager::CreateDefault();
|
KDiskDeviceManager::CreateDefault();
|
||||||
KDiskDeviceManager::Default()->InitialDeviceScan();
|
KDiskDeviceManager::Default()->InitialDeviceScan();
|
||||||
|
|
||||||
// list all disk devices and partitions
|
// add a file device
|
||||||
BDiskDeviceRoster roster;
|
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;
|
DumpVisitor visitor;
|
||||||
roster.VisitAll(&visitor);
|
roster.VisitAll(&visitor);
|
||||||
// list disk systems
|
// list disk systems
|
||||||
@@ -519,6 +525,21 @@ main()
|
|||||||
printf(" file system: %d (!%d)\n", diskSystem.IsFileSystem(),
|
printf(" file system: %d (!%d)\n", diskSystem.IsFileSystem(),
|
||||||
diskSystem.IsPartitioningSystem());
|
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
|
// for userland testing only
|
||||||
KDiskDeviceManager::DeleteDefault();
|
KDiskDeviceManager::DeleteDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user