vold: Ensure we cleanup secure containers on card removal.
Fixes bug: http://b/issue?id=2567572
Note: The framework will still likely restart since the system_server
is holding references to assets on the card which are mmaped, but
at least now storage will be available when a new card is re-inserted.
Change-Id: I4e195c0c666426b93da47198fa826a6f58d855a9
Signed-off-by: San Mehat <san@google.com>
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 10dbbb5..8a70c37 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -886,14 +886,7 @@
return -1;
}
- while(mActiveContainers->size()) {
- AsecIdCollection::iterator it = mActiveContainers->begin();
- SLOGI("Unmounting ASEC %s (dependant on %s)", *it, v->getMountpoint());
- if (unmountAsec(*it, force)) {
- SLOGE("Failed to unmount ASEC %s (%s)", *it, strerror(errno));
- return -1;
- }
- }
+ cleanupAsec(v, force);
return v->unmountVol(force);
}
@@ -942,3 +935,15 @@
return false;
}
+int VolumeManager::cleanupAsec(Volume *v, bool force) {
+ while(mActiveContainers->size()) {
+ AsecIdCollection::iterator it = mActiveContainers->begin();
+ SLOGI("Unmounting ASEC %s (dependant on %s)", *it, v->getMountpoint());
+ if (unmountAsec(*it, force)) {
+ SLOGE("Failed to unmount ASEC %s (%s)", *it, strerror(errno));
+ return -1;
+ }
+ }
+ return 0;
+}
+