summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-10-04 16:49:22 -0700
committerJeff Sharkey <jsharkey@android.com>2012-10-04 16:50:17 -0700
commit7a3c3d462ebd58bda0ceaba9c00c385d44c13d08 (patch)
tree10bd7aa77365e73dc176bf405ed6dc8128698c09
parentb77bc4696b19d9b1ef82810f8d5f671c963d1dc1 (diff)
downloadsystem_vold-7a3c3d462ebd58bda0ceaba9c00c385d44c13d08.zip
system_vold-7a3c3d462ebd58bda0ceaba9c00c385d44c13d08.tar.gz
system_vold-7a3c3d462ebd58bda0ceaba9c00c385d44c13d08.tar.bz2
Unmount in-place instead of using MS_MOVE.
To support multi-user emulated storage, we mount rootfs as MS_SHARED, which means we can't MS_MOVE existing mount points rooted in the shared subtree. Initial staging is still able to MS_MOVE, since it's rooted in a MS_PRIVATE tmpfs rooted at /mnt/secure. This change fixes unmounting by operating in-place instead of trying (and failing) to MS_MOVE back to staging. Bug: 7127564 Change-Id: I4783db4319b61c0915da39361cbc7e8f4943d094
-rw-r--r--Volume.cpp32
1 files changed, 10 insertions, 22 deletions
diff --git a/Volume.cpp b/Volume.cpp
index a71000e..0be2e81 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -608,41 +608,29 @@ int Volume::unmountVol(bool force, bool revert) {
usleep(1000 * 1000); // Give the framework some time to react
/*
- * First move the mountpoint back to our internal staging point
- * so nobody else can muck with it while we work.
+ * Remove the bindmount we were using to keep a reference to
+ * the previously obscured directory.
*/
- if (doMoveMount(getMountpoint(), SEC_STGDIR, force)) {
- SLOGE("Failed to move mount %s => %s (%s)", getMountpoint(), SEC_STGDIR, strerror(errno));
- setState(Volume::State_Mounted);
- return -1;
+ if (doUnmount(Volume::SEC_ASECDIR_EXT, force)) {
+ SLOGE("Failed to remove bindmount on %s (%s)", SEC_ASECDIR_EXT, strerror(errno));
+ goto fail_remount_tmpfs;
}
- protectFromAutorunStupidity();
-
/*
* 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));
+ char secure_dir[PATH_MAX];
+ snprintf(secure_dir, PATH_MAX, "%s/.android_secure", getMountpoint());
+ if (doUnmount(secure_dir, force)) {
+ SLOGE("Failed to unmount tmpfs on %s (%s)", secure_dir, strerror(errno));
goto fail_republish;
}
/*
- * 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;
- }
-
- /*
* Finally, unmount the actual block device from the staging dir
*/
- if (doUnmount(Volume::SEC_STGDIR, force)) {
+ if (doUnmount(getMountpoint(), force)) {
SLOGE("Failed to unmount %s (%s)", SEC_STGDIR, strerror(errno));
goto fail_recreate_bindmount;
}