btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / tests / system / kernel / disk_device_manager / DiskDeviceManagerTest.cpp
blob0b2134e45e039c7c46c378f0b25ee8ef2cf5fd56
1 //----------------------------------------------------------------------
2 // This software is part of the OpenBeOS distribution and is covered
3 // by the MIT License.
4 //---------------------------------------------------------------------
6 #include <stdio.h>
7 #include <string.h>
9 #include <OS.h>
11 #include <KDiskDevice.h>
12 #include <KFileDiskDevice.h>
13 #include <KDiskDeviceManager.h>
14 #include <KDiskDeviceUtils.h>
16 const char *kTestFileDevice = "/boot/home/tmp/test-file-device";
18 // main
19 int
20 main(int argc, char **argv)
22 const char *testFileDevice = kTestFileDevice;
24 if (argc > 1)
25 testFileDevice = argv[1];
27 KDiskDeviceManager::CreateDefault();
28 KDiskDeviceManager *manager = KDiskDeviceManager::Default();
29 manager->InitialDeviceScan();
30 partition_id id = manager->CreateFileDevice(testFileDevice);
31 if (id < B_OK)
32 printf("creating the file device failed: %s\n", strerror(id));
34 // wait for scanning jobs to finish
35 // (that's hopefully a hack :-))
36 for (;;) {
37 if (ManagerLocker locker = manager) {
38 if (manager->CountJobs() == 0)
39 break;
41 snooze(50000);
44 // print devices
45 for (int32 cookie = 0;
46 KDiskDevice *device = manager->RegisterNextDevice(&cookie); ) {
47 PartitionRegistrar _(device, true);
48 if (DeviceReadLocker locker = device) {
49 device->Dump();
50 printf("\n");
54 // error = manager->DeleteFileDevice(kTestFileDevice);
55 // if (error != B_OK)
56 // printf("deleting the file device failed: %s\n", strerror(error));
59 KDiskDeviceManager::DeleteDefault();
60 return 0;