OSDN Git Service

Fix sdcardfs permissions issue
authorChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 1 May 2020 13:52:11 +0000 (21:52 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Sat, 2 May 2020 14:32:13 +0000 (22:32 +0800)
Some applications encounter a file access error in /storage/emulated/0/
like

[E] System.UnauthorizedAccessException: Access to the path "/storage/emulated/0/Android/data/com.fgol.HungrySharkEvolution/files/test" is denied.

Michael pointed out the root cause is the init.rc of AOSP will set owner,
group and permissions of /config/sdcardfs before sdcardfs module is loaded.

Previously we don't always load sdcardfs module since it doesn't work in
some cases (e.g., /data is mounted on tmpfs). However, to fix the issue,
let sdcardfs always be loaded in early-init stage, and use the property
ro.sys.sdcardfs to decide whether to enable sdcardfs.

init.sh
init.x86.rc

diff --git a/init.sh b/init.sh
index d2c52ad..5d342e3 100644 (file)
--- a/init.sh
+++ b/init.sh
@@ -36,7 +36,7 @@ function init_misc()
 
        # enable sdcardfs if /data is not mounted on tmpfs or 9p
        mount | grep /data\ | grep -qE 'tmpfs|9p'
-       [ $? -ne 0 ] && modprobe sdcardfs
+       [ $? -eq 0 ] && set_prop_if_empty ro.sys.sdcardfs false
 
        # remove wl if it's not used
        local wifi
index 4bc545c..03727f3 100644 (file)
@@ -9,6 +9,8 @@ on early-init
     export EGL_LOG_LEVEL info
 #   export EGL_DRIVERS egl_dri2
 
+    exec u:r:init:s0 -- /sbin/modprobe sdcardfs
+
 on init
 
 on fs