diff options
| author | 2016-11-11 00:32:02 +0000 | |
|---|---|---|
| committer | 2016-11-11 00:32:02 +0000 | |
| commit | a42d5770c72227b18c5e44bf415e5b8fc947f7a6 (patch) | |
| tree | 2752c93fe8303dd1ec59d59713aefcdd52fed480 | |
| parent | 48482468de0a02e40f3fc06ec7301f6275a53700 (diff) | |
| parent | 97d99600e9ba8c26a8d5fed07f104eafd9e8188e (diff) | |
Merge "In MountEmulatedStorage() don't create a mount namespace unless actually mounting." am: c0aacbe513 am: ae06fba67a am: b82970846b
am: 97d99600e9
Change-Id: Id8d0d78e01bd8e0e876fa4564eee67fe18937065
| -rw-r--r-- | core/jni/com_android_internal_os_Zygote.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index fc85b4bd3734..38078c12657d 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -319,12 +319,6 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode, bool force_mount_namespace) { // See storage config details at http://source.android.com/tech/storage/ - // Create a second private mount namespace for our process - if (unshare(CLONE_NEWNS) == -1) { - ALOGW("Failed to unshare(): %s", strerror(errno)); - return false; - } - String8 storageSource; if (mount_mode == MOUNT_EXTERNAL_DEFAULT) { storageSource = "/mnt/runtime/default"; @@ -336,6 +330,13 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode, // Sane default of no storage visible return true; } + + // Create a second private mount namespace for our process + if (unshare(CLONE_NEWNS) == -1) { + ALOGW("Failed to unshare(): %s", strerror(errno)); + return false; + } + if (TEMP_FAILURE_RETRY(mount(storageSource.string(), "/storage", NULL, MS_BIND | MS_REC | MS_SLAVE, NULL)) == -1) { ALOGW("Failed to mount %s to /storage: %s", storageSource.string(), strerror(errno)); |