Prevent sharing or formatting of a vold managed volumes during encryption.
Mounting was already not allowed, but also unshare before starting
encryption, and don't allow sharing or formatting to be initiated
during encrytion.
Change-Id: Ida188d81f025739ba4dd90492b3e66088735991e
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index c1406a9..0f04a06 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -62,6 +62,7 @@
mSavedDirtyRatio = -1;
// set dirty ratio to 0 when UMS is active
mUmsDirtyRatio = 0;
+ mVolManagerDisabled = 0;
}
VolumeManager::~VolumeManager() {
@@ -168,6 +169,11 @@
return -1;
}
+ if (mVolManagerDisabled) {
+ errno = EBUSY;
+ return -1;
+ }
+
return v->formatVol();
}
@@ -940,6 +946,11 @@
return -1;
}
+ if (mVolManagerDisabled) {
+ errno = EBUSY;
+ return -1;
+ }
+
dev_t d = v->getShareDevice();
if ((MAJOR(d) == 0) && (MINOR(d) == 0)) {
// This volume does not support raw disk access
@@ -1030,8 +1041,10 @@
return 0;
}
-extern "C" int vold_unmountVol(const char *label) {
+extern "C" int vold_disableVol(const char *label) {
VolumeManager *vm = VolumeManager::Instance();
+ vm->disableVolumeManager();
+ vm->unshareVolume(label, "ums");
return vm->unmountVolume(label, true);
}