Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c676cca4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes from topic "apex_earlymount_base"

* changes:
  Activate system APEXes early
  mount /apex during first_stage init
parents d458066b dcbaf9f4
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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();
@@ -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}}},
+4 −0
Original line number Diff line number Diff line
@@ -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
+17 −1
Original line number Diff line number Diff line
@@ -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();

@@ -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
@@ -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;
}

+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ namespace android {
namespace init {

bool SetupMountNamespaces();
bool SetupRuntimeBionic();
bool SwitchToDefaultMountNamespace();
bool SwitchToBootstrapMountNamespaceIfNeeded();

+2 −0
Original line number Diff line number Diff line
@@ -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