disk device manager: check that partitions are unmounted before uninitializing.

when uninitializing a partition or a disk (removing the partition
table), check that all partitions from that table are unmounted, as they
are about to become invalid.

Fixes #8827.
This commit is contained in:
Adrien Destugues 2014-10-28 23:52:57 +01:00
parent 04dbe5b1c5
commit 4ed39e6a62
3 changed files with 17 additions and 1 deletions

View File

@ -85,6 +85,7 @@ public:
bool ContainsPartitioningSystem() const;
bool IsReadOnly() const;
bool IsMounted() const;
bool IsChildMounted();
bool IsDevice() const;

View File

@ -559,6 +559,20 @@ KPartition::IsMounted() const
}
bool
KPartition::IsChildMounted()
{
struct IsMountedVisitor : KPartitionVisitor {
virtual bool VisitPre(KPartition* partition)
{
return partition->IsMounted();
}
} checkVisitor;
return VisitEachDescendant(&checkVisitor) != NULL;
}
bool
KPartition::IsDevice() const
{

View File

@ -1249,7 +1249,8 @@ _user_uninitialize_partition(partition_id partitionID, int32* _changeCounter)
if (!partition->CheckAndMarkBusy(true))
return B_BUSY;
// TODO: We should also check, if any partition is mounted!
if (partition->IsMounted() || partition->IsChildMounted())
return B_BAD_DATA;
KDiskSystem* diskSystem = partition->DiskSystem();