Improved the test application: it now accepts a test disk image as first

parameter (else it falls back to the old behaviour, trying to open
/boot/home/tmp/test-file-device).
Also fixed the hackish busy loop to at least snooze() a bit (so that it
doesn't use all your CPU energy while debugging a partitioning module :-)).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4475 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2003-09-03 16:33:14 +00:00
parent 4f5bd2b685
commit 3f4524a309

View File

@ -9,6 +9,7 @@
#include <OS.h>
#include <KDiskDevice.h>
#include <KFileDiskDevice.h>
#include <KDiskDeviceManager.h>
#include <KDiskDeviceUtils.h>
@ -16,21 +17,30 @@ const char *kTestFileDevice = "/boot/home/tmp/test-file-device";
// main
int
main()
main(int argc, char **argv)
{
const char *testFileDevice = kTestFileDevice;
if (argc > 1)
testFileDevice = argv[1];
KDiskDeviceManager::CreateDefault();
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
manager->InitialDeviceScan();
partition_id id = manager->CreateFileDevice(kTestFileDevice);
partition_id id = manager->CreateFileDevice(testFileDevice);
if (id < B_OK)
printf("creating the file device failed: %s\n", strerror(id));
// wait for scanning jobs to finish
// (that's hopefully a hack :-))
for (;;) {
if (ManagerLocker locker = manager) {
if (manager->CountJobs() == 0)
break;
}
snooze(50000);
}
// print devices
for (int32 cookie = 0;
KDiskDevice *device = manager->RegisterNextDevice(&cookie); ) {