* Added VisitEachDescendant().
* Added {Add,Clear}Flags() which are more comfortable than SetFlags() in
most cases.
* On construction the `busy' and `descendant busy' flags are set.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4220 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -16,6 +16,7 @@ class UserDataWriter;
|
|||||||
|
|
||||||
class KDiskDevice;
|
class KDiskDevice;
|
||||||
class KDiskSystem;
|
class KDiskSystem;
|
||||||
|
class KPartitionVisitor;
|
||||||
class KPhysicalPartition;
|
class KPhysicalPartition;
|
||||||
class KShadowPartition;
|
class KShadowPartition;
|
||||||
|
|
||||||
@@ -70,6 +71,8 @@ public:
|
|||||||
uint32 Status() const;
|
uint32 Status() const;
|
||||||
|
|
||||||
void SetFlags(uint32 flags); // comprises the ones below
|
void SetFlags(uint32 flags); // comprises the ones below
|
||||||
|
void AddFlags(uint32 flags);
|
||||||
|
void ClearFlags(uint32 flags);
|
||||||
uint32 Flags() const;
|
uint32 Flags() const;
|
||||||
bool ContainsFileSystem() const;
|
bool ContainsFileSystem() const;
|
||||||
bool ContainsPartitioningSystem() const;
|
bool ContainsPartitioningSystem() const;
|
||||||
@@ -132,6 +135,8 @@ public:
|
|||||||
int32 CountChildren() const;
|
int32 CountChildren() const;
|
||||||
int32 CountDescendants() const;
|
int32 CountDescendants() const;
|
||||||
|
|
||||||
|
KPartition *VisitEachDescendant(KPartitionVisitor *visitor);
|
||||||
|
|
||||||
// Shadow Partition
|
// Shadow Partition
|
||||||
|
|
||||||
virtual status_t CreateShadowPartition(); // creates a complete tree
|
virtual status_t CreateShadowPartition(); // creates a complete tree
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "KDiskDeviceUtils.h"
|
#include "KDiskDeviceUtils.h"
|
||||||
#include "KDiskSystem.h"
|
#include "KDiskSystem.h"
|
||||||
#include "KPartition.h"
|
#include "KPartition.h"
|
||||||
|
#include "KPartitionVisitor.h"
|
||||||
#include "UserDataWriter.h"
|
#include "UserDataWriter.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -46,7 +47,7 @@ KPartition::KPartition(partition_id id)
|
|||||||
fPartitionData.child_count = 0;
|
fPartitionData.child_count = 0;
|
||||||
fPartitionData.index = -1;
|
fPartitionData.index = -1;
|
||||||
fPartitionData.status = B_PARTITION_UNRECOGNIZED;
|
fPartitionData.status = B_PARTITION_UNRECOGNIZED;
|
||||||
fPartitionData.flags = 0;
|
fPartitionData.flags = B_PARTITION_BUSY | B_PARTITION_DESCENDANT_BUSY;
|
||||||
fPartitionData.volume = -1;
|
fPartitionData.volume = -1;
|
||||||
fPartitionData.name = NULL;
|
fPartitionData.name = NULL;
|
||||||
fPartitionData.content_name = NULL;
|
fPartitionData.content_name = NULL;
|
||||||
@@ -199,9 +200,9 @@ void
|
|||||||
KPartition::SetBusy(bool busy)
|
KPartition::SetBusy(bool busy)
|
||||||
{
|
{
|
||||||
if (busy)
|
if (busy)
|
||||||
fPartitionData.flags |= B_PARTITION_BUSY;
|
SetFlags(B_PARTITION_BUSY);
|
||||||
else
|
else
|
||||||
fPartitionData.flags &= ~(uint32)B_PARTITION_BUSY;
|
ClearFlags(B_PARTITION_BUSY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsBusy
|
// IsBusy
|
||||||
@@ -216,9 +217,9 @@ void
|
|||||||
KPartition::SetDescendantBusy(bool busy)
|
KPartition::SetDescendantBusy(bool busy)
|
||||||
{
|
{
|
||||||
if (busy)
|
if (busy)
|
||||||
fPartitionData.flags |= B_PARTITION_DESCENDANT_BUSY;
|
SetFlags(B_PARTITION_DESCENDANT_BUSY);
|
||||||
else
|
else
|
||||||
fPartitionData.flags &= ~(uint32)B_PARTITION_DESCENDANT_BUSY;
|
ClearFlags(B_PARTITION_DESCENDANT_BUSY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsDescendantBusy
|
// IsDescendantBusy
|
||||||
@@ -319,6 +320,20 @@ KPartition::SetFlags(uint32 flags)
|
|||||||
fPartitionData.flags = flags;
|
fPartitionData.flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddFlags
|
||||||
|
void
|
||||||
|
KPartition::AddFlags(uint32 flags)
|
||||||
|
{
|
||||||
|
fPartitionData.flags |= flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearFlags
|
||||||
|
void
|
||||||
|
KPartition::ClearFlags(uint32 flags)
|
||||||
|
{
|
||||||
|
fPartitionData.flags &= ~flags;
|
||||||
|
}
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
uint32
|
uint32
|
||||||
KPartition::Flags() const
|
KPartition::Flags() const
|
||||||
@@ -476,9 +491,9 @@ KPartition::SetVolumeID(dev_t volumeID)
|
|||||||
{
|
{
|
||||||
fPartitionData.volume = volumeID;
|
fPartitionData.volume = volumeID;
|
||||||
if (VolumeID() >= 0)
|
if (VolumeID() >= 0)
|
||||||
SetFlags(Flags() | B_PARTITION_MOUNTED);
|
AddFlags(B_PARTITION_MOUNTED);
|
||||||
else
|
else
|
||||||
SetFlags(Flags() & ~(uint32)B_PARTITION_MOUNTED);
|
ClearFlags(B_PARTITION_MOUNTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// VolumeID
|
// VolumeID
|
||||||
@@ -538,7 +553,7 @@ KPartition::SetDevice(KDiskDevice *device)
|
|||||||
{
|
{
|
||||||
fDevice = device;
|
fDevice = device;
|
||||||
if (fDevice && fDevice->IsReadOnlyMedia())
|
if (fDevice && fDevice->IsReadOnlyMedia())
|
||||||
SetFlags(Flags() | B_PARTITION_READ_ONLY);
|
AddFlags(B_PARTITION_READ_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Device
|
// Device
|
||||||
@@ -666,6 +681,23 @@ KPartition::CountDescendants() const
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VisitEachDescendant
|
||||||
|
KPartition *
|
||||||
|
KPartition::VisitEachDescendant(KPartitionVisitor *visitor)
|
||||||
|
{
|
||||||
|
if (!visitor)
|
||||||
|
return NULL;
|
||||||
|
if (visitor->VisitPre(this))
|
||||||
|
return this;
|
||||||
|
for (int32 i = 0; KPartition *child = ChildAt(i); i++) {
|
||||||
|
if (KPartition *result = child->VisitEachDescendant(visitor))
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (visitor->VisitPost(this))
|
||||||
|
return this;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// CreateShadowPartition
|
// CreateShadowPartition
|
||||||
status_t
|
status_t
|
||||||
KPartition::CreateShadowPartition()
|
KPartition::CreateShadowPartition()
|
||||||
@@ -699,9 +731,9 @@ KPartition::SetDiskSystem(KDiskSystem *diskSystem)
|
|||||||
if (fDiskSystem) {
|
if (fDiskSystem) {
|
||||||
fPartitionData.content_type = fDiskSystem->PrettyName();
|
fPartitionData.content_type = fDiskSystem->PrettyName();
|
||||||
if (fDiskSystem->IsFileSystem())
|
if (fDiskSystem->IsFileSystem())
|
||||||
SetFlags(Flags() | B_PARTITION_FILE_SYSTEM);
|
AddFlags(B_PARTITION_FILE_SYSTEM);
|
||||||
else
|
else
|
||||||
SetFlags(Flags() | B_PARTITION_PARTITIONING_SYSTEM);
|
AddFlags(B_PARTITION_PARTITIONING_SYSTEM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -826,10 +858,9 @@ KPartition::UninitializeContents(bool logChanges)
|
|||||||
// status
|
// status
|
||||||
SetStatus(B_PARTITION_UNINITIALIZED);
|
SetStatus(B_PARTITION_UNINITIALIZED);
|
||||||
// flags
|
// flags
|
||||||
SetFlags(Flags() & ~uint32(B_PARTITION_FILE_SYSTEM
|
ClearFlags(B_PARTITION_FILE_SYSTEM | B_PARTITION_PARTITIONING_SYSTEM);
|
||||||
| B_PARTITION_PARTITIONING_SYSTEM));
|
|
||||||
if (!Device()->IsReadOnlyMedia())
|
if (!Device()->IsReadOnlyMedia())
|
||||||
SetFlags(Flags() & ~(uint32)B_PARTITION_READ_ONLY);
|
ClearFlags(B_PARTITION_READ_ONLY);
|
||||||
// log changes
|
// log changes
|
||||||
if (logChanges) {
|
if (logChanges) {
|
||||||
Changed(flags, B_PARTITION_CHANGED_DEFRAGMENTATION
|
Changed(flags, B_PARTITION_CHANGED_DEFRAGMENTATION
|
||||||
|
|||||||
Reference in New Issue
Block a user