diff options
| author | 2019-08-15 16:50:23 +0100 | |
|---|---|---|
| committer | 2019-08-15 16:50:23 +0100 | |
| commit | a11d9101b03a061e72a4f6c15f94d84d36d8be11 (patch) | |
| tree | c8b224d50434d612a35b94c39f6f613edf82d450 | |
| parent | 1b90222214db9e9a9d71bb5dac3f1632358e1551 (diff) | |
Support Zygote mounting FUSE mount paths while forking
If the persist.sys.fuse flag is true, Zygote will mount
/mnt/user/<userid> on /storage. This will effectively provide
/storage/self/primary symlinked to /storage/emulated/<userid>
This will allow apps access FUSE instead of sdcardfs on /sdcard
If the persist.sys.fuse flag is false (the default). No behavior changes
Bug: 135341433
Test: m && device boots successfully && seems to work ok
Change-Id: If5ee53cc4c18e52481f670be001c581b7f520343
| -rw-r--r-- | core/jni/com_android_internal_os_Zygote.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 795f7abc579f..d5b875b85d7d 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -117,7 +117,9 @@ typedef const std::function<void(std::string)>& fail_fn_t; static pid_t gSystemServerPid = 0; +static constexpr const char* kPropFuse = "persist.sys.fuse"; static constexpr const char* kZygoteClassName = "com/android/internal/os/Zygote"; + static jclass gZygoteClass; static jmethodID gCallPostForkSystemServerHooks; static jmethodID gCallPostForkChildHooks; @@ -704,15 +706,24 @@ static void MountEmulatedStorage(uid_t uid, jint mount_mode, return; } - const std::string& storage_source = ExternalStorageViews[mount_mode]; - - BindMount(storage_source, "/storage", fail_fn); - - // Mount user-specific symlink helper into place - userid_t user_id = multiuser_get_user_id(uid); + const userid_t user_id = multiuser_get_user_id(uid); const std::string user_source = StringPrintf("/mnt/user/%d", user_id); + bool isFuse = GetBoolProperty(kPropFuse, false); + CreateDir(user_source, 0751, AID_ROOT, AID_ROOT, fail_fn); - BindMount(user_source, "/storage/self", fail_fn); + + if (isFuse) { + // TODO(b/135341433): Bind mount the appropriate storage view for the app given its permissions + // media and media_location permission access. This should prevent the kernel from incorrectly + // sharing a cache across permission buckets + BindMount(user_source, "/storage", fail_fn); + } else { + const std::string& storage_source = ExternalStorageViews[mount_mode]; + BindMount(storage_source, "/storage", fail_fn); + + // Mount user-specific symlink helper into place + BindMount(user_source, "/storage/self", fail_fn); + } } static bool NeedsNoRandomizeWorkaround() { |