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

Commit 3b01231a authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6538416 from 87ee2378 to rvc-release

Change-Id: I41b9df40048b0cc11eb7acae57aa7d1ca0cf9db9
parents 84090480 87ee2378
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -402,16 +402,17 @@ std::string ReadFstabFromDt() {
    return fstab_result;
}

// Identify path to fstab file. Lookup is based on pattern fstab.<hardware>,
// fstab.<hardware.platform> in folders /odm/etc, vendor/etc, or /.
// Identify path to fstab file. Lookup is based on pattern
// fstab.<fstab_suffix>, fstab.<hardware>, fstab.<hardware.platform> in
// folders /odm/etc, vendor/etc, or /.
std::string GetFstabPath() {
    for (const char* prop : {"hardware", "hardware.platform"}) {
        std::string hw;
    for (const char* prop : {"fstab_suffix", "hardware", "hardware.platform"}) {
        std::string suffix;

        if (!fs_mgr_get_boot_config(prop, &hw)) continue;
        if (!fs_mgr_get_boot_config(prop, &suffix)) continue;

        for (const char* prefix : {"/odm/etc/fstab.", "/vendor/etc/fstab.", "/fstab."}) {
            std::string fstab_path = prefix + hw;
            std::string fstab_path = prefix + suffix;
            if (access(fstab_path.c_str(), F_OK) == 0) {
                return fstab_path;
            }
+4 −1
Original line number Diff line number Diff line
@@ -547,13 +547,16 @@ provides the `aidl_lazy_test_1` interface.
  * `ref`: use the systemwide DE key
  * `per_boot_ref`: use the key freshly generated on each boot.

`mount_all <fstab> [ <path> ]\* [--<option>]`
`mount_all [ <fstab> ] [--<option>]`
> Calls fs\_mgr\_mount\_all on the given fs\_mgr-format fstab with optional
  options "early" and "late".
  With "--early" set, the init executable will skip mounting entries with
  "latemount" flag and triggering fs encryption state event. With "--late" set,
  init executable will only mount entries with "latemount" flag. By default,
  no option is set, and mount\_all will process all entries in the given fstab.
  If the fstab parameter is not specified, fstab.${ro.boot.fstab_suffix},
  fstab.${ro.hardware} or fstab.${ro.hardware.platform} will be scanned for
  under /odm/etc, /vendor/etc, or / at runtime, in that order.

`mount <type> <device> <dir> [ <flag>\* ] [<options>]`
> Attempt to mount the named device at the directory _dir_
+41 −36
Original line number Diff line number Diff line
@@ -518,21 +518,21 @@ static Result<void> do_mount(const BuiltinArguments& args) {

/* Imports .rc files from the specified paths. Default ones are applied if none is given.
 *
 * start_index: index of the first path in the args list
 * rc_paths: list of paths to rc files to import
 */
static void import_late(const std::vector<std::string>& args, size_t start_index, size_t end_index) {
static void import_late(const std::vector<std::string>& rc_paths) {
    auto& action_manager = ActionManager::GetInstance();
    auto& service_list = ServiceList::GetInstance();
    Parser parser = CreateParser(action_manager, service_list);
    if (end_index <= start_index) {
    if (rc_paths.empty()) {
        // Fallbacks for partitions on which early mount isn't enabled.
        for (const auto& path : late_import_paths) {
            parser.ParseConfig(path);
        }
        late_import_paths.clear();
    } else {
        for (size_t i = start_index; i < end_index; ++i) {
            parser.ParseConfig(args[i]);
        for (const auto& rc_path : rc_paths) {
            parser.ParseConfig(rc_path);
        }
    }

@@ -633,48 +633,44 @@ static Result<void> queue_fs_event(int code, bool userdata_remount) {

static int initial_mount_fstab_return_code = -1;

/* mount_all <fstab> [ <path> ]* [--<options>]*
/* <= Q: mount_all <fstab> [ <path> ]* [--<options>]*
 * >= R: mount_all [ <fstab> ] [--<options>]*
 *
 * This function might request a reboot, in which case it will
 * not return.
 */
static Result<void> do_mount_all(const BuiltinArguments& args) {
    std::size_t na = 0;
    bool import_rc = true;
    bool queue_event = true;
    int mount_mode = MOUNT_MODE_DEFAULT;
    const auto& fstab_file = args[1];
    std::size_t path_arg_end = args.size();
    const char* prop_post_fix = "default";
    auto mount_all = ParseMountAll(args.args);
    if (!mount_all.ok()) return mount_all.error();

    for (na = args.size() - 1; na > 1; --na) {
        if (args[na] == "--early") {
            path_arg_end = na;
            queue_event = false;
            mount_mode = MOUNT_MODE_EARLY;
    const char* prop_post_fix = "default";
    bool queue_event = true;
    if (mount_all->mode == MOUNT_MODE_EARLY) {
        prop_post_fix = "early";
        } else if (args[na] == "--late") {
            path_arg_end = na;
            import_rc = false;
            mount_mode = MOUNT_MODE_LATE;
        queue_event = false;
    } else if (mount_all->mode == MOUNT_MODE_LATE) {
        prop_post_fix = "late";
    }
    }

    std::string prop_name = "ro.boottime.init.mount_all."s + prop_post_fix;
    android::base::Timer t;

    Fstab fstab;
    if (!ReadFstabFromFile(fstab_file, &fstab)) {
    if (mount_all->fstab_path.empty()) {
        if (!ReadDefaultFstab(&fstab)) {
            return Error() << "Could not read default fstab";
        }
    } else {
        if (!ReadFstabFromFile(mount_all->fstab_path, &fstab)) {
            return Error() << "Could not read fstab";
        }
    }

    auto mount_fstab_return_code = fs_mgr_mount_all(&fstab, mount_mode);
    auto mount_fstab_return_code = fs_mgr_mount_all(&fstab, mount_all->mode);
    SetProperty(prop_name, std::to_string(t.duration().count()));

    if (import_rc && SelinuxGetVendorAndroidVersion() <= __ANDROID_API_Q__) {
        /* Paths of .rc files are specified at the 2nd argument and beyond */
        import_late(args.args, 2, path_arg_end);
    if (mount_all->import_rc) {
        import_late(mount_all->rc_paths);
    }

    if (queue_event) {
@@ -690,12 +686,21 @@ static Result<void> do_mount_all(const BuiltinArguments& args) {
    return {};
}

/* umount_all <fstab> */
/* umount_all [ <fstab> ] */
static Result<void> do_umount_all(const BuiltinArguments& args) {
    auto umount_all = ParseUmountAll(args.args);
    if (!umount_all.ok()) return umount_all.error();

    Fstab fstab;
    if (!ReadFstabFromFile(args[1], &fstab)) {
    if (umount_all->empty()) {
        if (!ReadDefaultFstab(&fstab)) {
            return Error() << "Could not read default fstab";
        }
    } else {
        if (!ReadFstabFromFile(*umount_all, &fstab)) {
            return Error() << "Could not read fstab";
        }
    }

    if (auto result = fs_mgr_umount_all(&fstab); result != 0) {
        return Error() << "umount_fstab() failed " << result;
@@ -1349,11 +1354,11 @@ const BuiltinFunctionMap& GetBuiltinFunctionMap() {
        // mount_all is currently too complex to run in vendor_init as it queues action triggers,
        // imports rc scripts, etc.  It should be simplified and run in vendor_init context.
        // mount and umount are run in the same context as mount_all for symmetry.
        {"mount_all",               {1,     kMax, {false,  do_mount_all}}},
        {"mount_all",               {0,     kMax, {false,  do_mount_all}}},
        {"mount",                   {3,     kMax, {false,  do_mount}}},
        {"perform_apex_config",     {0,     0,    {false,  do_perform_apex_config}}},
        {"umount",                  {1,     1,    {false,  do_umount}}},
        {"umount_all",              {1,     1,    {false,  do_umount_all}}},
        {"umount_all",              {0,     1,    {false,  do_umount_all}}},
        {"update_linker_config",    {0,     0,    {false,  do_update_linker_config}}},
        {"readahead",               {1,     2,    {true,   do_readahead}}},
        {"remount_userdata",        {0,     0,    {false,  do_remount_userdata}}},
+16 −0
Original line number Diff line number Diff line
@@ -123,6 +123,14 @@ Result<void> check_loglevel(const BuiltinArguments& args) {
    return {};
}

Result<void> check_mount_all(const BuiltinArguments& args) {
    auto options = ParseMountAll(args.args);
    if (!options.ok()) {
        return options.error();
    }
    return {};
}

Result<void> check_mkdir(const BuiltinArguments& args) {
    auto options = ParseMkdir(args.args);
    if (!options.ok()) {
@@ -204,6 +212,14 @@ Result<void> check_sysclktz(const BuiltinArguments& args) {
    return {};
}

Result<void> check_umount_all(const BuiltinArguments& args) {
    auto options = ParseUmountAll(args.args);
    if (!options.ok()) {
        return options.error();
    }
    return {};
}

Result<void> check_wait(const BuiltinArguments& args) {
    if (args.size() == 3 && !args[2].empty()) {
        double timeout_double;
+2 −0
Original line number Diff line number Diff line
@@ -32,11 +32,13 @@ Result<void> check_interface_stop(const BuiltinArguments& args);
Result<void> check_load_system_props(const BuiltinArguments& args);
Result<void> check_loglevel(const BuiltinArguments& args);
Result<void> check_mkdir(const BuiltinArguments& args);
Result<void> check_mount_all(const BuiltinArguments& args);
Result<void> check_restorecon(const BuiltinArguments& args);
Result<void> check_restorecon_recursive(const BuiltinArguments& args);
Result<void> check_setprop(const BuiltinArguments& args);
Result<void> check_setrlimit(const BuiltinArguments& args);
Result<void> check_sysclktz(const BuiltinArguments& args);
Result<void> check_umount_all(const BuiltinArguments& args);
Result<void> check_wait(const BuiltinArguments& args);
Result<void> check_wait_for_prop(const BuiltinArguments& args);

Loading