From 0b66969ba03464bea45a12c978f51b59c4c200a9 Mon Sep 17 00:00:00 2001 From: Tri Vo Date: Tue, 10 Apr 2018 20:20:13 -0700 Subject: [PATCH] Add /mnt/vendor rw mount point for vendor partitions. Changes to init's behavior during early mount: 1. Mounting of tmpfs on /mnt is moved from init stage to early mount. 2. init creates /mnt/vendor used to mount vendor partitions. 3. If a device tree fstab entry for early mount specifies a mount point under /mnt/vendor e.g. /mnt/vendor/foo, init will create /mnt/vendor/foo mount point. Bug: 64905218 Test: change dt fstab entry to mount persist to /mnt/vendor/persist; mount point is created correctly, and partition is mounted in early mount. See go/pag/1069774 Test: device boots with /mnt/vendor and previous contents of /mnt present, and selinux label "mnt_vendor_file" is applied correctly. Test: cts-tradefed run commandAndExit cts --skip-all-system-status-check --primary-abi-only --skip-preconditions -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.PermissionsHostTest Change-Id: I3739130739eadf508355c7f2531366fcaed74175 Merged-In: I3739130739eadf508355c7f2531366fcaed74175 (cherry picked from commit b51147566461d411ad452df81d54dc800c554e06) --- init/init.cpp | 8 ++++++++ rootdir/init.rc | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/init/init.cpp b/init/init.cpp index 2f3b28ac5..40b7e8793 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -624,6 +624,14 @@ int main(int argc, char** argv) { mknod("/dev/random", S_IFCHR | 0666, makedev(1, 8)); mknod("/dev/urandom", S_IFCHR | 0666, makedev(1, 9)); + // Mount staging areas for devices managed by vold + // See storage config details at http://source.android.com/devices/storage/ + mount("tmpfs", "/mnt", "tmpfs", MS_NOEXEC | MS_NOSUID | MS_NODEV, + "mode=0755,uid=0,gid=1000"); + // /mnt/vendor is used to mount vendor-specific partitions that can not be + // part of the vendor partition, e.g. because they are mounted read-write. + mkdir("/mnt/vendor", 0755); + // Now that tmpfs is mounted on /dev and we have /dev/kmsg, we can actually // talk to the outside world... InitKernelLogging(argv); diff --git a/rootdir/init.rc b/rootdir/init.rc index 146257040..2d6414496 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -21,9 +21,6 @@ on early-init # Set the security context of /adb_keys if present. restorecon /adb_keys - # Shouldn't be necessary, but sdcard won't start without it. http://b/22568628. - mkdir /mnt 0775 root system - # Set the security context of /postinstall if present. restorecon /postinstall @@ -80,9 +77,6 @@ on init chmod 0664 /dev/stune/top-app/tasks chmod 0664 /dev/stune/rt/tasks - # Mount staging areas for devices managed by vold - # See storage config details at http://source.android.com/tech/storage/ - mount tmpfs tmpfs /mnt nodev noexec nosuid mode=0755,uid=0,gid=1000 restorecon_recursive /mnt mount configfs none /config nodev noexec nosuid