Loading init/builtins.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -1119,13 +1119,21 @@ static Result<Success> do_parse_apex_configs(const BuiltinArguments& args) { } static Result<Success> do_setup_runtime_bionic(const BuiltinArguments& args) { if (SwitchToDefaultMountNamespace()) { if (SetupRuntimeBionic()) { return Success(); } else { return Error() << "Failed to setup runtime bionic"; } } static Result<Success> do_enter_default_mount_ns(const BuiltinArguments& args) { if (SwitchToDefaultMountNamespace()) { return Success(); } else { return Error() << "Failed to enter into default mount namespace"; } } // Builtin-function-map start const BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const { constexpr std::size_t kMax = std::numeric_limits<std::size_t>::max(); Loading Loading @@ -1177,6 +1185,7 @@ const BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const { {"start", {1, 1, {false, do_start}}}, {"stop", {1, 1, {false, do_stop}}}, {"swapon_all", {1, 1, {false, do_swapon_all}}}, {"enter_default_mount_ns", {0, 0, {false, do_enter_default_mount_ns}}}, {"symlink", {2, 2, {true, do_symlink}}}, {"sysclktz", {1, 1, {false, do_sysclktz}}}, {"trigger", {1, 1, {false, do_trigger}}}, Loading init/first_stage_init.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,10 @@ int FirstStageMain(int argc, char** argv) { // part of the product partition, e.g. because they are mounted read-write. CHECKCALL(mkdir("/mnt/product", 0755)); // /apex is used to mount APEXes CHECKCALL(mount("tmpfs", "/apex", "tmpfs", MS_NOEXEC | MS_NOSUID | MS_NODEV, "mode=0755,uid=0,gid=0")); #undef CHECKCALL // Now that tmpfs is mounted on /dev and we have /dev/kmsg, we can actually Loading init/mount_namespace.cpp +17 −1 Original line number Diff line number Diff line Loading @@ -172,6 +172,11 @@ bool SetupMountNamespaces() { kBionicLibsMountPointDir64)) return false; // /apex is also a private mountpoint to give different sets of APEXes for // the bootstrap and default mount namespaces. The processes running with // the bootstrap namespace get APEXes from the read-only partition. if (!(MakePrivate("/apex"))) return false; bootstrap_ns_fd.reset(OpenMountNamespace()); bootstrap_ns_id = GetMountNamespaceId(); Loading Loading @@ -227,6 +232,17 @@ bool SwitchToDefaultMountNamespace() { } } LOG(INFO) << "Switched to default mount namespace"; return true; } // TODO(jiyong): remove this when /system/lib/libc.so becomes // a symlink to /apex/com.android.runtime/lib/bionic/libc.so bool SetupRuntimeBionic() { if (IsRecoveryMode()) { // We don't have multiple namespaces in recovery mode return true; } // Bind-mount bionic from the runtime APEX since it is now available. Note // that in case of IsBionicUpdatable() == false, these mounts are over the // existing existing bind mounts for the bootstrap bionic, which effectively Loading @@ -238,7 +254,7 @@ bool SwitchToDefaultMountNamespace() { kBionicLibsMountPointDir64)) return false; LOG(INFO) << "Switched to default mount namespace"; LOG(INFO) << "Runtime bionic is set up"; return true; } Loading init/mount_namespace.h +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ namespace android { namespace init { bool SetupMountNamespaces(); bool SetupRuntimeBionic(); bool SwitchToDefaultMountNamespace(); bool SwitchToBootstrapMountNamespaceIfNeeded(); Loading init/selinux.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -459,6 +459,8 @@ void SelinuxRestoreContext() { selinux_android_restorecon("/dev/block", SELINUX_ANDROID_RESTORECON_RECURSE); selinux_android_restorecon("/dev/device-mapper", 0); selinux_android_restorecon("/apex", 0); } int SelinuxKlogCallback(int type, const char* fmt, ...) { Loading Loading
init/builtins.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -1119,13 +1119,21 @@ static Result<Success> do_parse_apex_configs(const BuiltinArguments& args) { } static Result<Success> do_setup_runtime_bionic(const BuiltinArguments& args) { if (SwitchToDefaultMountNamespace()) { if (SetupRuntimeBionic()) { return Success(); } else { return Error() << "Failed to setup runtime bionic"; } } static Result<Success> do_enter_default_mount_ns(const BuiltinArguments& args) { if (SwitchToDefaultMountNamespace()) { return Success(); } else { return Error() << "Failed to enter into default mount namespace"; } } // Builtin-function-map start const BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const { constexpr std::size_t kMax = std::numeric_limits<std::size_t>::max(); Loading Loading @@ -1177,6 +1185,7 @@ const BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const { {"start", {1, 1, {false, do_start}}}, {"stop", {1, 1, {false, do_stop}}}, {"swapon_all", {1, 1, {false, do_swapon_all}}}, {"enter_default_mount_ns", {0, 0, {false, do_enter_default_mount_ns}}}, {"symlink", {2, 2, {true, do_symlink}}}, {"sysclktz", {1, 1, {false, do_sysclktz}}}, {"trigger", {1, 1, {false, do_trigger}}}, Loading
init/first_stage_init.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,10 @@ int FirstStageMain(int argc, char** argv) { // part of the product partition, e.g. because they are mounted read-write. CHECKCALL(mkdir("/mnt/product", 0755)); // /apex is used to mount APEXes CHECKCALL(mount("tmpfs", "/apex", "tmpfs", MS_NOEXEC | MS_NOSUID | MS_NODEV, "mode=0755,uid=0,gid=0")); #undef CHECKCALL // Now that tmpfs is mounted on /dev and we have /dev/kmsg, we can actually Loading
init/mount_namespace.cpp +17 −1 Original line number Diff line number Diff line Loading @@ -172,6 +172,11 @@ bool SetupMountNamespaces() { kBionicLibsMountPointDir64)) return false; // /apex is also a private mountpoint to give different sets of APEXes for // the bootstrap and default mount namespaces. The processes running with // the bootstrap namespace get APEXes from the read-only partition. if (!(MakePrivate("/apex"))) return false; bootstrap_ns_fd.reset(OpenMountNamespace()); bootstrap_ns_id = GetMountNamespaceId(); Loading Loading @@ -227,6 +232,17 @@ bool SwitchToDefaultMountNamespace() { } } LOG(INFO) << "Switched to default mount namespace"; return true; } // TODO(jiyong): remove this when /system/lib/libc.so becomes // a symlink to /apex/com.android.runtime/lib/bionic/libc.so bool SetupRuntimeBionic() { if (IsRecoveryMode()) { // We don't have multiple namespaces in recovery mode return true; } // Bind-mount bionic from the runtime APEX since it is now available. Note // that in case of IsBionicUpdatable() == false, these mounts are over the // existing existing bind mounts for the bootstrap bionic, which effectively Loading @@ -238,7 +254,7 @@ bool SwitchToDefaultMountNamespace() { kBionicLibsMountPointDir64)) return false; LOG(INFO) << "Switched to default mount namespace"; LOG(INFO) << "Runtime bionic is set up"; return true; } Loading
init/mount_namespace.h +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ namespace android { namespace init { bool SetupMountNamespaces(); bool SetupRuntimeBionic(); bool SwitchToDefaultMountNamespace(); bool SwitchToBootstrapMountNamespaceIfNeeded(); Loading
init/selinux.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -459,6 +459,8 @@ void SelinuxRestoreContext() { selinux_android_restorecon("/dev/block", SELINUX_ANDROID_RESTORECON_RECURSE); selinux_android_restorecon("/dev/device-mapper", 0); selinux_android_restorecon("/apex", 0); } int SelinuxKlogCallback(int type, const char* fmt, ...) { Loading