summaryrefslogtreecommitdiffstats
path: root/Volume.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Volume.cpp')
-rw-r--r--Volume.cpp42
1 files changed, 25 insertions, 17 deletions
diff --git a/Volume.cpp b/Volume.cpp
index 9c25985..6421e09 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -170,6 +170,11 @@ int Volume::handleBlockEvent(NetlinkEvent *evt) {
return -1;
}
+bool Volume::isPrimaryStorage() {
+ const char* externalStorage = getenv("EXTERNAL_STORAGE") ? : "/mnt/sdcard";
+ return !strcmp(getMountpoint(), externalStorage);
+}
+
void Volume::setState(int state) {
char msg[255];
int oldState = mState;
@@ -302,8 +307,7 @@ int Volume::mountVol() {
dev_t deviceNodes[4];
int n, i, rc = 0;
char errmsg[255];
- const char* externalStorage = getenv("EXTERNAL_STORAGE");
- bool primaryStorage = externalStorage && !strcmp(getMountpoint(), externalStorage);
+ bool primaryStorage = isPrimaryStorage();
char decrypt_state[PROPERTY_VALUE_MAX];
char crypto_state[PROPERTY_VALUE_MAX];
char encrypt_progress[PROPERTY_VALUE_MAX];
@@ -602,6 +606,7 @@ int Volume::doUnmount(const char *path, bool force) {
int Volume::unmountVol(bool force, bool revert) {
int i, rc;
+ const char* externalStorage = getenv("EXTERNAL_STORAGE");
if (getState() != Volume::State_Mounted) {
SLOGE("Volume %s unmount request when not mounted", getLabel());
@@ -624,24 +629,27 @@ int Volume::unmountVol(bool force, bool revert) {
protectFromAutorunStupidity();
- /*
- * Unmount the tmpfs which was obscuring the asec image directory
- * from non root users
- */
+ /* Undo createBindMounts(), which is only called for primary storage */
+ if (isPrimaryStorage()) {
+ /*
+ * Unmount the tmpfs which was obscuring the asec image directory
+ * from non root users
+ */
- if (doUnmount(Volume::SEC_STG_SECIMGDIR, force)) {
- SLOGE("Failed to unmount tmpfs on %s (%s)", SEC_STG_SECIMGDIR, strerror(errno));
- goto fail_republish;
- }
+ if (doUnmount(Volume::SEC_STG_SECIMGDIR, force)) {
+ SLOGE("Failed to unmount tmpfs on %s (%s)", SEC_STG_SECIMGDIR, strerror(errno));
+ goto fail_republish;
+ }
- /*
- * Remove the bindmount we were using to keep a reference to
- * the previously obscured directory.
- */
+ /*
+ * Remove the bindmount we were using to keep a reference to
+ * the previously obscured directory.
+ */
- if (doUnmount(Volume::SEC_ASECDIR_EXT, force)) {
- SLOGE("Failed to remove bindmount on %s (%s)", SEC_ASECDIR_EXT, strerror(errno));
- goto fail_remount_tmpfs;
+ if (doUnmount(Volume::SEC_ASECDIR_EXT, force)) {
+ SLOGE("Failed to remove bindmount on %s (%s)", SEC_ASECDIR_EXT, strerror(errno));
+ goto fail_remount_tmpfs;
+ }
}
/*