Now prints out information on scanning jobs and waits for them to finish.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4143 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <DiskDevice.h>
|
#include <DiskDevice.h>
|
||||||
|
#include <DiskDeviceJob.h>
|
||||||
//#include <DiskDeviceList.h>
|
//#include <DiskDeviceList.h>
|
||||||
#include <DiskDeviceRoster.h>
|
#include <DiskDeviceRoster.h>
|
||||||
#include <DiskDeviceVisitor.h>
|
#include <DiskDeviceVisitor.h>
|
||||||
@@ -479,6 +480,33 @@ private:
|
|||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// wait_for_jobs
|
||||||
|
void
|
||||||
|
wait_for_jobs()
|
||||||
|
{
|
||||||
|
BDiskDeviceRoster roster;
|
||||||
|
bool activeJobs = false;
|
||||||
|
do {
|
||||||
|
if (activeJobs)
|
||||||
|
snooze(50000);
|
||||||
|
activeJobs = false;
|
||||||
|
printf("disk device jobs at time %lld\n", system_time());
|
||||||
|
roster.RewindActiveJobs();
|
||||||
|
BDiskDeviceJob job;
|
||||||
|
while (roster.GetNextActiveJob(&job) == B_OK) {
|
||||||
|
activeJobs = true;
|
||||||
|
printf(" job %ld:\n", job.ID());
|
||||||
|
printf(" type: %lu\n", job.Type());
|
||||||
|
printf(" description: `%s'\n", job.Description());
|
||||||
|
printf(" partition: %ld\n", job.PartitionID());
|
||||||
|
printf(" status: %lu\n", job.Status());
|
||||||
|
printf(" progress: %f\n", job.Progress());
|
||||||
|
}
|
||||||
|
if (!activeJobs)
|
||||||
|
printf(" none\n");
|
||||||
|
} while (activeJobs);
|
||||||
|
}
|
||||||
|
|
||||||
// main
|
// main
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
@@ -508,11 +536,17 @@ main()
|
|||||||
KDiskDeviceManager::CreateDefault();
|
KDiskDeviceManager::CreateDefault();
|
||||||
KDiskDeviceManager::Default()->InitialDeviceScan();
|
KDiskDeviceManager::Default()->InitialDeviceScan();
|
||||||
|
|
||||||
|
// wait till all (scan) jobs are done
|
||||||
|
wait_for_jobs();
|
||||||
// add a file device
|
// add a file device
|
||||||
BDiskDeviceRoster roster;
|
BDiskDeviceRoster roster;
|
||||||
partition_id id = roster.RegisterFileDevice(kTestFileDevice);
|
partition_id id = roster.RegisterFileDevice(kTestFileDevice);
|
||||||
if (id < B_OK)
|
if (id < B_OK)
|
||||||
printf("registering the file device failed: %s\n", strerror(id));
|
printf("registering the file device failed: %s\n", strerror(id));
|
||||||
|
else {
|
||||||
|
// wait till all (scan) jobs are done
|
||||||
|
wait_for_jobs();
|
||||||
|
}
|
||||||
// list all disk devices and partitions
|
// list all disk devices and partitions
|
||||||
DumpVisitor visitor;
|
DumpVisitor visitor;
|
||||||
roster.VisitAll(&visitor);
|
roster.VisitAll(&visitor);
|
||||||
|
|||||||
Reference in New Issue
Block a user