Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a42d5770 authored by Robert Sesek's avatar Robert Sesek Committed by android-build-merger
Browse files

Merge "In MountEmulatedStorage() don't create a mount namespace unless...

Merge "In MountEmulatedStorage() don't create a mount namespace unless actually mounting." am: c0aacbe5 am: ae06fba6 am: b8297084
am: 97d99600

Change-Id: Id8d0d78e01bd8e0e876fa4564eee67fe18937065
parents 48482468 97d99600
Loading
Loading
Loading
Loading
+7 −6
Original line number Original line Diff line number Diff line
@@ -319,12 +319,6 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode,
        bool force_mount_namespace) {
        bool force_mount_namespace) {
    // See storage config details at http://source.android.com/tech/storage/
    // 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;
    String8 storageSource;
    if (mount_mode == MOUNT_EXTERNAL_DEFAULT) {
    if (mount_mode == MOUNT_EXTERNAL_DEFAULT) {
        storageSource = "/mnt/runtime/default";
        storageSource = "/mnt/runtime/default";
@@ -336,6 +330,13 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode,
        // Sane default of no storage visible
        // Sane default of no storage visible
        return true;
        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",
    if (TEMP_FAILURE_RETRY(mount(storageSource.string(), "/storage",
            NULL, MS_BIND | MS_REC | MS_SLAVE, NULL)) == -1) {
            NULL, MS_BIND | MS_REC | MS_SLAVE, NULL)) == -1) {
        ALOGW("Failed to mount %s to /storage: %s", storageSource.string(), strerror(errno));
        ALOGW("Failed to mount %s to /storage: %s", storageSource.string(), strerror(errno));