Lock while partitioning.
Otherwise we get really excited and trip over ourselves while
partitions are still being created.
Bug: 19993667
Change-Id: I034e56b3063a71d73f9311a945c05ea2ae255f7d
diff --git a/Disk.cpp b/Disk.cpp
index 04c43cf..51eeba8 100644
--- a/Disk.cpp
+++ b/Disk.cpp
@@ -223,6 +223,8 @@
}
status_t Disk::readPartitions() {
+ std::lock_guard<std::mutex> lock(mLock);
+
int8_t maxMinors = getMaxMinors();
if (maxMinors < 0) {
return -ENOTSUP;
@@ -311,6 +313,8 @@
}
status_t Disk::partitionPublic() {
+ std::lock_guard<std::mutex> lock(mLock);
+
// TODO: improve this code
destroyAllVolumes();
mJustPartitioned = true;
@@ -357,6 +361,8 @@
}
status_t Disk::partitionMixed(int8_t ratio) {
+ std::lock_guard<std::mutex> lock(mLock);
+
int res;
destroyAllVolumes();