Otherwise we get really excited and trip over ourselves while
partitions are still being created.
Bug:
19993667
Change-Id: I034e56b3063a71d73f9311a945c05ea2ae255f7d
}
status_t Disk::readPartitions() {
+ std::lock_guard<std::mutex> lock(mLock);
+
int8_t maxMinors = getMaxMinors();
if (maxMinors < 0) {
return -ENOTSUP;
}
status_t Disk::partitionPublic() {
+ std::lock_guard<std::mutex> lock(mLock);
+
// TODO: improve this code
destroyAllVolumes();
mJustPartitioned = true;
}
status_t Disk::partitionMixed(int8_t ratio) {
+ std::lock_guard<std::mutex> lock(mLock);
+
int res;
destroyAllVolumes();
#include <utils/Errors.h>
+#include <mutex>
#include <vector>
namespace android {
int mFlags;
/* Flag indicating object is created */
bool mCreated;
+ /* Lock held while partitioning */
+ std::mutex mLock;
/* Flag that we just partitioned and should format all volumes */
bool mJustPartitioned;
break;
}
case NetlinkEvent::Action::kChange: {
+ LOG(DEBUG) << "Disk at " << major << ":" << minor << " changed";
for (auto disk : mDisks) {
if (disk->getDevice() == device) {
disk->readMetadata();