From 7fcdfb5fb881ca810dfc0a4fefa8c9dc2b8083d7 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 15 Jul 2003 01:23:47 +0000 Subject: [PATCH] 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 --- .../storage/disk_device/DiskDeviceTest.cpp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/tests/kits/storage/disk_device/DiskDeviceTest.cpp b/src/tests/kits/storage/disk_device/DiskDeviceTest.cpp index 0f1d8c624c..58854239c8 100644 --- a/src/tests/kits/storage/disk_device/DiskDeviceTest.cpp +++ b/src/tests/kits/storage/disk_device/DiskDeviceTest.cpp @@ -20,6 +20,8 @@ //#include #include +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();