summaryrefslogtreecommitdiff
path: root/init/builtins.cpp
diff options
context:
space:
mode:
authorAlistair Delva <adelva@google.com>2020-06-08 11:04:53 -0700
committerAlistair Delva <adelva@google.com>2020-06-08 23:41:40 +0000
commitde28a8651f560508ee978a644daa72d0b169169a (patch)
treee33ccb3b3c5aa813dffff43005d5398d5c29d9cb /init/builtins.cpp
parent6c6a36fb31f0026a35df084a641496e88cd112f9 (diff)
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 Merged-In: Icd706fe7a1fe16c687cd2811b0a3158d7d2e224e
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r--init/builtins.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp
index e918e12ae..0ac66f272 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -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}}},