1 //---------------------------------------------------------------------- 2 // This software is part of the Haiku distribution and is covered 3 // by the MIT License. 4 //--------------------------------------------------------------------- 5 6 #include <stdio.h> 7 #include <string.h> 8 9 #include <OS.h> 10 11 #include <KDiskDevice.h> 12 #include <KFileDiskDevice.h> 13 #include <KDiskDeviceManager.h> 14 #include <KDiskDeviceUtils.h> 15 16 const char *kTestFileDevice = "/boot/home/tmp/test-file-device"; 17 18 // main 19 int 20 main(int argc, char **argv) 21 { 22 const char *testFileDevice = kTestFileDevice; 23 24 if (argc > 1) 25 testFileDevice = argv[1]; 26 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)); 33 34 #if 0 35 // wait for scanning jobs to finish 36 // (that's hopefully a hack :-)) 37 for (;;) { 38 if (ManagerLocker locker = manager) { 39 if (manager->CountJobs() == 0) 40 break; 41 } 42 snooze(50000); 43 } 44 #endif 45 46 // print devices 47 for (int32 cookie = 0; 48 KDiskDevice *device = manager->RegisterNextDevice(&cookie); ) { 49 PartitionRegistrar _(device, true); 50 if (DeviceReadLocker locker = device) { 51 device->Dump(); 52 printf("\n"); 53 } 54 } 55 56 // error = manager->DeleteFileDevice(kTestFileDevice); 57 // if (error != B_OK) 58 // printf("deleting the file device failed: %s\n", strerror(error)); 59 60 61 KDiskDeviceManager::DeleteDefault(); 62 return 0; 63 } 64 65