summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSan Mehat <san@google.com>2010-04-15 12:58:50 -0700
committerSan Mehat <san@google.com>2010-04-15 12:59:15 -0700
commit1a06edaf4db4e9c520624bcc06e0e13ee470d90e (patch)
tree274a062c49efd0f44af1943ed8b7ab51e8211be0
parent97ac40e4e6f3ed0bd5d6878d7d8d4a54fcaecb76 (diff)
downloadandroid_system_vold-1a06edaf4db4e9c520624bcc06e0e13ee470d90e.tar.gz
android_system_vold-1a06edaf4db4e9c520624bcc06e0e13ee470d90e.tar.bz2
android_system_vold-1a06edaf4db4e9c520624bcc06e0e13ee470d90e.zip
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>
-rw-r--r--DirectVolume.cpp5
-rw-r--r--VolumeManager.cpp21
-rw-r--r--VolumeManager.h3
3 files changed, 21 insertions, 8 deletions
diff --git a/DirectVolume.cpp b/DirectVolume.cpp
index c269303..1f9f084 100644
--- a/DirectVolume.cpp
+++ b/DirectVolume.cpp
@@ -284,6 +284,11 @@ void DirectVolume::handlePartitionRemoved(const char *devpath, NetlinkEvent *evt
getLabel(), getMountpoint(), major, minor);
mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeBadRemoval,
msg, false);
+
+ if (mVm->cleanupAsec(this, true)) {
+ SLOGE("Failed to cleanup ASEC - unmount will probably fail!");
+ }
+
if (Volume::unmountVol(true)) {
SLOGE("Failed to unmount volume on bad removal (%s)",
strerror(errno));
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 10dbbb5..8a70c37 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -886,14 +886,7 @@ int VolumeManager::unmountVolume(const char *label, bool force) {
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 @@ bool VolumeManager::isMountpointMounted(const char *mp)
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;
+}
+
diff --git a/VolumeManager.h b/VolumeManager.h
index a675646..2ec9eb3 100644
--- a/VolumeManager.h
+++ b/VolumeManager.h
@@ -71,6 +71,8 @@ public:
// XXX: This should be moved private once switch uevents are working
void notifyUmsConnected(bool connected);
+ // XXX: Post froyo this should be moved and cleaned up
+ int cleanupAsec(Volume *v, bool force);
void setBroadcaster(SocketListener *sl) { mBroadcaster = sl; }
SocketListener *getBroadcaster() { return mBroadcaster; }
@@ -78,6 +80,7 @@ public:
static VolumeManager *Instance();
static char *asecHash(const char *id, char *buffer, size_t len);
+
private:
VolumeManager();
Volume *lookupVolume(const char *label);