Implemented disk system iteration.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3905 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2003-07-08 23:29:21 +00:00
parent 0cb59d9c8c
commit 8bb7454636
2 changed files with 27 additions and 17 deletions
+2 -1
View File
@@ -163,7 +163,8 @@ private:
BDiskScannerPartitionAddOn **addOn); BDiskScannerPartitionAddOn **addOn);
#endif // 0 #endif // 0
private: private:
int32 fCookie; int32 fDeviceCookie;
int32 fDiskSystemCookie;
// BDirectory *fPartitionAddOnDir; // BDirectory *fPartitionAddOnDir;
// BDirectory *fFSAddOnDir; // BDirectory *fFSAddOnDir;
// int32 fPartitionAddOnDirIndex; // int32 fPartitionAddOnDirIndex;
+25 -16
View File
@@ -12,6 +12,7 @@
#include <DiskDevicePrivate.h> #include <DiskDevicePrivate.h>
#include <DiskDeviceRoster.h> #include <DiskDeviceRoster.h>
//#include <DiskScannerAddOn.h> //#include <DiskScannerAddOn.h>
#include <DiskSystem.h>
#include <Entry.h> #include <Entry.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#include <Message.h> #include <Message.h>
@@ -44,7 +45,8 @@ static const int32 kAddOnDirCount
The object is ready to be used after construction. The object is ready to be used after construction.
*/ */
BDiskDeviceRoster::BDiskDeviceRoster() BDiskDeviceRoster::BDiskDeviceRoster()
: fCookie(0)//, : fDeviceCookie(0),
fDiskSystemCookie(0)
// fPartitionAddOnDir(NULL), // fPartitionAddOnDir(NULL),
// fFSAddOnDir(NULL), // fFSAddOnDir(NULL),
// fPartitionAddOnDirIndex(0), // fPartitionAddOnDirIndex(0),
@@ -79,7 +81,8 @@ BDiskDeviceRoster::GetNextDevice(BDiskDevice *device)
if (!device) if (!device)
return B_BAD_VALUE; return B_BAD_VALUE;
size_t neededSize = 0; size_t neededSize = 0;
partition_id id = _kern_get_next_disk_device_id(&fCookie, &neededSize); partition_id id = _kern_get_next_disk_device_id(&fDeviceCookie,
&neededSize);
if (id < 0) if (id < 0)
return id; return id;
return device->_SetTo(id, neededSize); return device->_SetTo(id, neededSize);
@@ -92,7 +95,7 @@ BDiskDeviceRoster::GetNextDevice(BDiskDevice *device)
status_t status_t
BDiskDeviceRoster::RewindDevices() BDiskDeviceRoster::RewindDevices()
{ {
fCookie = 0; fDeviceCookie = 0;
return B_OK; return B_OK;
} }
@@ -100,16 +103,22 @@ BDiskDeviceRoster::RewindDevices()
status_t status_t
BDiskDeviceRoster::GetNextDiskSystem(BDiskSystem *system) BDiskDeviceRoster::GetNextDiskSystem(BDiskSystem *system)
{ {
// not implemented if (!system)
return B_ERROR; return B_BAD_VALUE;
user_disk_system_info info;
status_t error = _kern_get_next_disk_system_info(&fDiskSystemCookie,
&info);
if (error == B_OK)
error = system->_SetTo(&info);
return error;
} }
// RewindDiskSystems // RewindDiskSystems
status_t status_t
BDiskDeviceRoster::RewindDiskSystems() BDiskDeviceRoster::RewindDiskSystems()
{ {
// not implemented fDiskSystemCookie = 0;
return B_ERROR; return B_OK;
} }
// GetNextActiveJob // GetNextActiveJob
@@ -171,13 +180,13 @@ BDiskDeviceRoster::VisitEachDevice(BDiskDeviceVisitor *visitor,
{ {
bool terminatedEarly = false; bool terminatedEarly = false;
if (visitor) { if (visitor) {
int32 oldCookie = fCookie; int32 oldCookie = fDeviceCookie;
fCookie = 0; fDeviceCookie = 0;
BDiskDevice deviceOnStack; BDiskDevice deviceOnStack;
BDiskDevice *useDevice = (device ? device : &deviceOnStack); BDiskDevice *useDevice = (device ? device : &deviceOnStack);
while (!terminatedEarly && GetNextDevice(useDevice) == B_OK) while (!terminatedEarly && GetNextDevice(useDevice) == B_OK)
terminatedEarly = visitor->Visit(useDevice); terminatedEarly = visitor->Visit(useDevice);
fCookie = oldCookie; fDeviceCookie = oldCookie;
if (!terminatedEarly) if (!terminatedEarly)
useDevice->Unset(); useDevice->Unset();
} }
@@ -208,8 +217,8 @@ BDiskDeviceRoster::VisitEachPartition(BDiskDeviceVisitor *visitor,
{ {
bool terminatedEarly = false; bool terminatedEarly = false;
if (visitor) { if (visitor) {
int32 oldCookie = fCookie; int32 oldCookie = fDeviceCookie;
fCookie = 0; fDeviceCookie = 0;
BDiskDevice deviceOnStack; BDiskDevice deviceOnStack;
BDiskDevice *useDevice = (device ? device : &deviceOnStack); BDiskDevice *useDevice = (device ? device : &deviceOnStack);
BPartition *foundPartition = NULL; BPartition *foundPartition = NULL;
@@ -217,7 +226,7 @@ BDiskDeviceRoster::VisitEachPartition(BDiskDeviceVisitor *visitor,
foundPartition = useDevice->VisitEachDescendant(visitor); foundPartition = useDevice->VisitEachDescendant(visitor);
// TODO: That probably not correct. VisitEachDescendant() // TODO: That probably not correct. VisitEachDescendant()
// should also invoke Visit(BDiskDevice*). // should also invoke Visit(BDiskDevice*).
fCookie = oldCookie; fDeviceCookie = oldCookie;
if (!terminatedEarly) if (!terminatedEarly)
useDevice->Unset(); useDevice->Unset();
else if (device && partition) else if (device && partition)
@@ -243,12 +252,12 @@ BDiskDeviceRoster::VisitAll(BDiskDeviceVisitor *visitor)
{ {
bool terminatedEarly = false; bool terminatedEarly = false;
if (visitor) { if (visitor) {
int32 oldCookie = fCookie; int32 oldCookie = fDeviceCookie;
fCookie = 0; fDeviceCookie = 0;
BDiskDevice device; BDiskDevice device;
while (!terminatedEarly && GetNextDevice(&device) == B_OK) while (!terminatedEarly && GetNextDevice(&device) == B_OK)
terminatedEarly = device.VisitEachDescendant(visitor); terminatedEarly = device.VisitEachDescendant(visitor);
fCookie = oldCookie; fDeviceCookie = oldCookie;
} }
return terminatedEarly; return terminatedEarly;
} }