summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2013-10-18 01:46:43 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-10-18 01:46:43 +0000
commitbcdbd9ac0657a27ff9f7772e74c45ec1e2d460c7 (patch)
treee154243f38a5a86c9d49d55189540c2ea1f62369
parent10939ac7e8c9fd141f45f1d6d82c78d5f5f5319c (diff)
parent8c2c15b1c611708c85b3f1ba86b6db79c5c004d5 (diff)
downloadvold-bcdbd9ac0657a27ff9f7772e74c45ec1e2d460c7.tar.gz
Merge "Clean up ASEC unmounting on physical storage." into klp-dev
-rw-r--r--DirectVolume.cpp9
-rw-r--r--DirectVolume.h2
-rw-r--r--Volume.cpp5
-rw-r--r--VolumeManager.cpp35
4 files changed, 37 insertions, 14 deletions
diff --git a/DirectVolume.cpp b/DirectVolume.cpp
index 4e0d6210..960eef64 100644
--- a/DirectVolume.cpp
+++ b/DirectVolume.cpp
@@ -321,15 +321,16 @@ void DirectVolume::handlePartitionRemoved(const char *devpath, NetlinkEvent *evt
* Yikes, our mounted partition is going away!
*/
+ bool providesAsec = (getFlags() & VOL_PROVIDES_ASEC) != 0;
+ if (providesAsec && mVm->cleanupAsec(this, true)) {
+ SLOGE("Failed to cleanup ASEC - unmount will probably fail!");
+ }
+
snprintf(msg, sizeof(msg), "Volume %s %s bad removal (%d:%d)",
getLabel(), getFuseMountpoint(), 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, false)) {
SLOGE("Failed to unmount volume on bad removal (%s)",
strerror(errno));
diff --git a/DirectVolume.h b/DirectVolume.h
index 337c72dc..7be133f1 100644
--- a/DirectVolume.h
+++ b/DirectVolume.h
@@ -42,7 +42,6 @@ protected:
int mDiskNumParts;
unsigned int mPendingPartMap;
int mIsDecrypted;
- int mFlags;
public:
DirectVolume(VolumeManager *vm, const fstab_rec* rec, int flags);
@@ -65,7 +64,6 @@ protected:
int updateDeviceInfo(char *new_path, int new_major, int new_minor);
virtual void revertDeviceInfo(void);
int isDecrypted() { return mIsDecrypted; }
- int getFlags() { return mFlags; }
private:
void handleDiskAdded(const char *devpath, NetlinkEvent *evt);
diff --git a/Volume.cpp b/Volume.cpp
index cbec5d4e..21b66b1e 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -72,6 +72,7 @@ const char *Volume::SEC_ASECDIR_EXT = "/mnt/secure/asec";
* Path to internal storage where *only* root can access ASEC image files
*/
const char *Volume::SEC_ASECDIR_INT = "/data/app-asec";
+
/*
* Path to where secure containers are mounted
*/
@@ -480,6 +481,7 @@ int Volume::mountAsecExternal() {
}
if (fs_prepare_dir(secure_path, 0770, AID_MEDIA_RW, AID_MEDIA_RW) != 0) {
+ SLOGW("fs_prepare_dir failed: %s", strerror(errno));
return -1;
}
@@ -662,7 +664,7 @@ int Volume::extractMetadata(const char* devicePath) {
char line[1024];
char value[128];
if (fgets(line, sizeof(line), fp) != NULL) {
- ALOGD("blkid reported: %s", line);
+ ALOGD("blkid identified as %s", line);
char* start = strstr(line, "UUID=") + 5;
if (sscanf(start, "\"%127[^\"]\"", value) == 1) {
@@ -678,6 +680,7 @@ int Volume::extractMetadata(const char* devicePath) {
setUserLabel(NULL);
}
} else {
+ ALOGW("blkid failed to identify %s", devicePath);
res = -1;
}
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 950138c6..2a9cd20f 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -1549,28 +1549,49 @@ bool VolumeManager::isMountpointMounted(const char *mp)
}
int VolumeManager::cleanupAsec(Volume *v, bool force) {
- int rc = unmountAllAsecsInDir(Volume::SEC_ASECDIR_EXT);
+ int rc = 0;
+
+ char asecFileName[255];
+
+ AsecIdCollection removeAsec;
+ AsecIdCollection removeObb;
- 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;
if (cd->type == ASEC) {
- // nothing
+ if (findAsec(cd->id, asecFileName, sizeof(asecFileName))) {
+ SLOGE("Couldn't find ASEC %s; cleaning up", cd->id);
+ removeAsec.push_back(cd);
+ } else {
+ SLOGD("Found ASEC at path %s", asecFileName);
+ if (!strncmp(asecFileName, Volume::SEC_ASECDIR_EXT,
+ strlen(Volume::SEC_ASECDIR_EXT))) {
+ removeAsec.push_back(cd);
+ }
+ }
} else if (cd->type == OBB) {
if (v == getVolumeForFile(cd->id)) {
- toUnmount.push_back(cd);
+ removeObb.push_back(cd);
}
} else {
SLOGE("Unknown container type %d!", cd->type);
}
}
- for (AsecIdCollection::iterator it = toUnmount.begin(); it != toUnmount.end(); ++it) {
+ for (AsecIdCollection::iterator it = removeAsec.begin(); it != removeAsec.end(); ++it) {
+ ContainerData *cd = *it;
+ SLOGI("Unmounting ASEC %s (dependent on %s)", cd->id, v->getLabel());
+ if (unmountAsec(cd->id, force)) {
+ SLOGE("Failed to unmount ASEC %s (%s)", cd->id, strerror(errno));
+ rc = -1;
+ }
+ }
+
+ for (AsecIdCollection::iterator it = removeObb.begin(); it != removeObb.end(); ++it) {
ContainerData *cd = *it;
- SLOGI("Unmounting ASEC %s (dependant on %s)", cd->id, v->getFuseMountpoint());
+ SLOGI("Unmounting OBB %s (dependent on %s)", cd->id, v->getLabel());
if (unmountObb(cd->id, force)) {
SLOGE("Failed to unmount OBB %s (%s)", cd->id, strerror(errno));
rc = -1;