From 6a01faea47cac0bd2622b9a2c5f4fc030aa34abb Mon Sep 17 00:00:00 2001 From: Martijn Coenen Date: Fri, 13 Dec 2019 16:44:32 +0100 Subject: [PATCH] Give installers and apps with "full" access the pass_through view. This enables the /Android bind-mount to use the sdcardfs "default" view. Installers can't use that view because they require write access to the OBB directory. Bug: 146189163 Test: atest AdoptableHostTest Change-Id: I9a40f68af10189bfb03a86a1e814638d623c8a2e --- core/jni/com_android_internal_os_Zygote.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index f28c4221c6370..ff222993ac313 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -714,8 +714,16 @@ static void MountEmulatedStorage(uid_t uid, jint mount_mode, CreateDir(user_source, 0751, AID_ROOT, AID_ROOT, fail_fn); if (isFuse) { - BindMount(mount_mode == MOUNT_EXTERNAL_PASS_THROUGH ? pass_through_source : user_source, - "/storage", fail_fn); + if (mount_mode == MOUNT_EXTERNAL_PASS_THROUGH || mount_mode == + MOUNT_EXTERNAL_INSTALLER || mount_mode == MOUNT_EXTERNAL_FULL) { + // For now, MediaProvider, installers and "full" get the pass_through mount + // view, which is currently identical to the sdcardfs write view. + // + // TODO(b/146189163): scope down MOUNT_EXTERNAL_INSTALLER + BindMount(pass_through_source, "/storage", fail_fn); + } else { + BindMount(user_source, "/storage", fail_fn); + } } else { const std::string& storage_source = ExternalStorageViews[mount_mode]; BindMount(storage_source, "/storage", fail_fn);