Added IsBusy(bool) version, which optionally also checks the
descendants. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22831 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -52,6 +52,7 @@ public:
|
|||||||
|
|
||||||
void SetBusy(bool busy);
|
void SetBusy(bool busy);
|
||||||
bool IsBusy() const;
|
bool IsBusy() const;
|
||||||
|
bool IsBusy(bool includeDescendants);
|
||||||
bool CheckAndMarkBusy(bool includeDescendants);
|
bool CheckAndMarkBusy(bool includeDescendants);
|
||||||
void UnmarkBusy(bool includeDescendants);
|
void UnmarkBusy(bool includeDescendants);
|
||||||
|
|
||||||
|
|||||||
@@ -247,23 +247,32 @@ KPartition::IsBusy() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// IsBusy
|
||||||
|
bool
|
||||||
|
KPartition::IsBusy(bool includeDescendants)
|
||||||
|
{
|
||||||
|
if (!includeDescendants)
|
||||||
|
return IsBusy();
|
||||||
|
|
||||||
|
struct IsBusyVisitor : KPartitionVisitor {
|
||||||
|
virtual bool VisitPre(KPartition* partition)
|
||||||
|
{
|
||||||
|
return partition->IsBusy();
|
||||||
|
}
|
||||||
|
} checkVisitor;
|
||||||
|
|
||||||
|
return VisitEachDescendant(&checkVisitor) != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// CheckAndMarkBusy
|
// CheckAndMarkBusy
|
||||||
bool
|
bool
|
||||||
KPartition::CheckAndMarkBusy(bool includeDescendants)
|
KPartition::CheckAndMarkBusy(bool includeDescendants)
|
||||||
{
|
{
|
||||||
|
if (IsBusy(includeDescendants))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (includeDescendants) {
|
if (includeDescendants) {
|
||||||
// check
|
|
||||||
struct IsBusyVisitor : KPartitionVisitor {
|
|
||||||
virtual bool VisitPre(KPartition* partition)
|
|
||||||
{
|
|
||||||
return partition->IsBusy();
|
|
||||||
}
|
|
||||||
} checkVisitor;
|
|
||||||
|
|
||||||
if (VisitEachDescendant(&checkVisitor))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// mark busy
|
|
||||||
struct MarkBusyVisitor : KPartitionVisitor {
|
struct MarkBusyVisitor : KPartitionVisitor {
|
||||||
virtual bool VisitPre(KPartition* partition)
|
virtual bool VisitPre(KPartition* partition)
|
||||||
{
|
{
|
||||||
@@ -273,12 +282,8 @@ KPartition::CheckAndMarkBusy(bool includeDescendants)
|
|||||||
} markVisitor;
|
} markVisitor;
|
||||||
|
|
||||||
VisitEachDescendant(&markVisitor);
|
VisitEachDescendant(&markVisitor);
|
||||||
} else {
|
} else
|
||||||
if (IsBusy())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
SetBusy(true);
|
SetBusy(true);
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1014,65 +1019,78 @@ KPartition::ChangeCounter() const
|
|||||||
return fChangeCounter;
|
return fChangeCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// UninitializeContents
|
// UninitializeContents
|
||||||
status_t
|
status_t
|
||||||
KPartition::UninitializeContents(bool logChanges)
|
KPartition::UninitializeContents(bool logChanges)
|
||||||
{
|
{
|
||||||
if (DiskSystem()) {
|
if (DiskSystem()) {
|
||||||
uint32 flags = B_PARTITION_CHANGED_INITIALIZATION
|
uint32 flags = B_PARTITION_CHANGED_INITIALIZATION
|
||||||
| B_PARTITION_CHANGED_CONTENT_TYPE
|
| B_PARTITION_CHANGED_CONTENT_TYPE
|
||||||
| B_PARTITION_CHANGED_STATUS
|
| B_PARTITION_CHANGED_STATUS
|
||||||
| B_PARTITION_CHANGED_FLAGS;
|
| B_PARTITION_CHANGED_FLAGS;
|
||||||
|
|
||||||
// children
|
// children
|
||||||
if (CountChildren() > 0) {
|
if (CountChildren() > 0) {
|
||||||
if (!RemoveAllChildren())
|
if (!RemoveAllChildren())
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
flags |= B_PARTITION_CHANGED_CHILDREN;
|
flags |= B_PARTITION_CHANGED_CHILDREN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// volume
|
// volume
|
||||||
if (VolumeID() >= 0) {
|
if (VolumeID() >= 0) {
|
||||||
|
// TODO: Unmount?
|
||||||
SetVolumeID(-1);
|
SetVolumeID(-1);
|
||||||
flags |= B_PARTITION_CHANGED_VOLUME;
|
flags |= B_PARTITION_CHANGED_VOLUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
// content name
|
// content name
|
||||||
if (ContentName()) {
|
if (ContentName()) {
|
||||||
SetContentName(NULL);
|
SetContentName(NULL);
|
||||||
flags |= B_PARTITION_CHANGED_CONTENT_NAME;
|
flags |= B_PARTITION_CHANGED_CONTENT_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
// content parameters
|
// content parameters
|
||||||
if (ContentParameters()) {
|
if (ContentParameters()) {
|
||||||
SetContentParameters(NULL);
|
SetContentParameters(NULL);
|
||||||
flags |= B_PARTITION_CHANGED_CONTENT_PARAMETERS;
|
flags |= B_PARTITION_CHANGED_CONTENT_PARAMETERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// content size
|
// content size
|
||||||
if (ContentSize() > 0) {
|
if (ContentSize() > 0) {
|
||||||
SetContentSize(0);
|
SetContentSize(0);
|
||||||
flags |= B_PARTITION_CHANGED_CONTENT_SIZE;
|
flags |= B_PARTITION_CHANGED_CONTENT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// block size
|
// block size
|
||||||
if (Parent() && Parent()->BlockSize() != BlockSize()) {
|
if (Parent() && Parent()->BlockSize() != BlockSize()) {
|
||||||
SetBlockSize(Parent()->BlockSize());
|
SetBlockSize(Parent()->BlockSize());
|
||||||
flags |= B_PARTITION_CHANGED_BLOCK_SIZE;
|
flags |= B_PARTITION_CHANGED_BLOCK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// disk system
|
// disk system
|
||||||
DiskSystem()->FreeContentCookie(this);
|
DiskSystem()->FreeContentCookie(this);
|
||||||
SetDiskSystem(NULL);
|
SetDiskSystem(NULL);
|
||||||
|
|
||||||
// status
|
// status
|
||||||
SetStatus(B_PARTITION_UNINITIALIZED);
|
SetStatus(B_PARTITION_UNINITIALIZED);
|
||||||
|
|
||||||
// flags
|
// flags
|
||||||
ClearFlags(B_PARTITION_FILE_SYSTEM | B_PARTITION_PARTITIONING_SYSTEM);
|
ClearFlags(B_PARTITION_FILE_SYSTEM | B_PARTITION_PARTITIONING_SYSTEM);
|
||||||
if (!Device()->IsReadOnlyMedia())
|
if (!Device()->IsReadOnlyMedia())
|
||||||
ClearFlags(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
|
||||||
| B_PARTITION_CHANGED_CHECK
|
| B_PARTITION_CHANGED_CHECK | B_PARTITION_CHANGED_REPAIR);
|
||||||
| B_PARTITION_CHANGED_REPAIR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetAlgorithmData
|
// SetAlgorithmData
|
||||||
void
|
void
|
||||||
KPartition::SetAlgorithmData(uint32 data)
|
KPartition::SetAlgorithmData(uint32 data)
|
||||||
|
|||||||
Reference in New Issue
Block a user