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

Commit afaa5fbc authored by Alistair Delva's avatar Alistair Delva
Browse files

Respect ro.boot.fstab_suffix in swapon_all

While mount_all and umount_all were updated to use ro.boot.fstab_suffix,
I neglected to update swapon_all. Trivially copied from umount_all.

Bug: 142424832
Change-Id: Icd706fe7a1fe16c687cd2811b0a3158d7d2e224e
parent 46f25dee
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -623,8 +623,11 @@ provides the `aidl_lazy_test_1` interface.
`stop <service>`
> Stop a service from running if it is currently running.

`swapon_all <fstab>`
`swapon_all [ <fstab> ]`
> Calls fs\_mgr\_swapon\_all on the given fstab file.
  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.

`symlink <target> <path>`
> Create a symbolic link at _path_ with the value _target_
+13 −3
Original line number Diff line number Diff line
@@ -708,10 +708,20 @@ static Result<void> do_umount_all(const BuiltinArguments& args) {
    return {};
}

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

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

    if (!fs_mgr_swapon_all(fstab)) {
@@ -1371,7 +1381,7 @@ const BuiltinFunctionMap& GetBuiltinFunctionMap() {
        {"setrlimit",               {3,     3,    {false,  do_setrlimit}}},
        {"start",                   {1,     1,    {false,  do_start}}},
        {"stop",                    {1,     1,    {false,  do_stop}}},
        {"swapon_all",              {1,     1,    {false,  do_swapon_all}}},
        {"swapon_all",              {0,     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}}},
+8 −0
Original line number Diff line number Diff line
@@ -202,6 +202,14 @@ Result<void> check_setrlimit(const BuiltinArguments& args) {
    return {};
}

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

Result<void> check_sysclktz(const BuiltinArguments& args) {
    ReturnIfAnyArgsEmpty();

+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ 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_swapon_all(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);
+13 −2
Original line number Diff line number Diff line
@@ -652,11 +652,22 @@ Result<std::pair<int, std::vector<std::string>>> ParseRestorecon(
    return std::pair(flag, paths);
}

Result<std::string> ParseUmountAll(const std::vector<std::string>& args) {
Result<std::string> ParseSwaponAll(const std::vector<std::string>& args) {
    if (args.size() <= 1) {
        if (SelinuxGetVendorAndroidVersion() <= __ANDROID_API_Q__) {
            return Error() << "swapon_all requires at least 1 argument";
        }
        return {};
    }
    return args[1];
}

Result<std::string> ParseUmountAll(const std::vector<std::string>& args) {
    if (args.size() <= 1) {
        if (SelinuxGetVendorAndroidVersion() <= __ANDROID_API_Q__) {
            return Error() << "umount_all requires at least 1 argument";
        }
        return {};
    }
    return args[1];
}
Loading