summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2012-08-09 11:28:37 -0700
committerKenny Root <kroot@google.com>2012-08-09 15:50:58 -0700
commit93ecb38daded7583a4a61f4f22519bb7a8a8c154 (patch)
treeb7764606ec9511b54a1adba75c491a92f31f24b0
parent912d0b07555eb691f0320530c4e0f6ab85521e95 (diff)
downloadsystem_vold-93ecb38daded7583a4a61f4f22519bb7a8a8c154.zip
system_vold-93ecb38daded7583a4a61f4f22519bb7a8a8c154.tar.gz
system_vold-93ecb38daded7583a4a61f4f22519bb7a8a8c154.tar.bz2
Only cleanup ASECs in external storage
Any ASEC or OBB files were unmounted when USB storage was set to UMS mode. This changes it so only ASEC files on external storage and OBB files mounted from external storage are unmounted. Bug: 6948035 Change-Id: I91bc09ee5b792970b0eef895f6886f3ffad00e8f
-rw-r--r--VolumeManager.cpp49
-rw-r--r--VolumeManager.h2
2 files changed, 38 insertions, 13 deletions
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 1c48932..0388010 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -985,6 +985,19 @@ int VolumeManager::mountAsec(const char *id, const char *key, int ownerUid) {
return 0;
}
+Volume* VolumeManager::getVolumeForFile(const char *fileName) {
+ VolumeCollection::iterator i;
+
+ for (i = mVolumes->begin(); i != mVolumes->end(); ++i) {
+ const char* mountPoint = (*i)->getMountpoint();
+ if (!strncmp(fileName, mountPoint, strlen(mountPoint))) {
+ return *i;
+ }
+ }
+
+ return NULL;
+}
+
/**
* Mounts an image file <code>img</code>.
*/
@@ -1113,7 +1126,7 @@ int VolumeManager::listMountedObbs(SocketClient* cli) {
}
// Create a string to compare against that has a trailing slash
- int loopDirLen = sizeof(Volume::LOOPDIR);
+ int loopDirLen = strlen(Volume::LOOPDIR);
char loopDir[loopDirLen + 2];
strcpy(loopDir, Volume::LOOPDIR);
loopDir[loopDirLen++] = '/';
@@ -1462,25 +1475,35 @@ bool VolumeManager::isMountpointMounted(const char *mp)
}
int VolumeManager::cleanupAsec(Volume *v, bool force) {
- while(mActiveContainers->size()) {
- AsecIdCollection::iterator it = mActiveContainers->begin();
+ int rc = unmountAllAsecsInDir(Volume::SEC_ASECDIR_EXT);
+
+ AsecIdCollection toUnmount;
+ // Find the remaining OBB files that are on external storage.
+ for (AsecIdCollection::iterator it = mActiveContainers->begin(); it != mActiveContainers->end();
+ ++it) {
ContainerData* cd = *it;
- SLOGI("Unmounting ASEC %s (dependant on %s)", cd->id, v->getMountpoint());
+
if (cd->type == ASEC) {
- if (unmountAsec(cd->id, force)) {
- SLOGE("Failed to unmount ASEC %s (%s)", cd->id, strerror(errno));
- return -1;
- }
+ // nothing
} else if (cd->type == OBB) {
- if (unmountObb(cd->id, force)) {
- SLOGE("Failed to unmount OBB %s (%s)", cd->id, strerror(errno));
- return -1;
+ if (v == getVolumeForFile(cd->id)) {
+ toUnmount.push_back(cd);
}
} else {
SLOGE("Unknown container type %d!", cd->type);
- return -1;
}
}
- return 0;
+
+ for (AsecIdCollection::iterator it = toUnmount.begin(); it != toUnmount.end(); ++it) {
+ ContainerData *cd = *it;
+ SLOGI("Unmounting ASEC %s (dependant on %s)", cd->id, v->getMountpoint());
+ if (unmountObb(cd->id, force)) {
+ SLOGE("Failed to unmount OBB %s (%s)", cd->id, strerror(errno));
+ rc = -1;
+ }
+ }
+
+ return rc;
+
}
diff --git a/VolumeManager.h b/VolumeManager.h
index 4399b76..198b5a9 100644
--- a/VolumeManager.h
+++ b/VolumeManager.h
@@ -117,6 +117,8 @@ public:
int unmountObb(const char *fileName, bool force);
int getObbMountPath(const char *id, char *buffer, int maxlen);
+ Volume* getVolumeForFile(const char *fileName);
+
/* Shared between ASEC and Loopback images */
int unmountLoopImage(const char *containerId, const char *loopId,
const char *fileName, const char *mountPoint, bool force);