diff options
author | Mike Frysinger <vapier@gentoo.org> | 2005-09-16 04:41:20 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2005-09-16 04:41:20 +0000 |
commit | 2d5e4f6b05bcd566a418aae5b12a7f0dfb2d8e44 (patch) | |
tree | 87ed61bc8fe60c5cf9ace7a542231f444aef242d | |
parent | 0ec71bf4b8a31ce6d49453a22a6244cc80e3122b (diff) | |
download | busybox-2d5e4f6b05bcd566a418aae5b12a7f0dfb2d8e44.tar.gz |
accept unlimited number of swap arguments like the real swap{on,off} and shrink do_em_all a little
-rw-r--r-- | util-linux/swaponoff.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c index 0080ff294..c624e74e3 100644 --- a/util-linux/swaponoff.c +++ b/util-linux/swaponoff.c @@ -38,10 +38,10 @@ static int swap_enable_disable(const char *device) if (status != 0) { bb_perror_msg("%s", device); - return EXIT_FAILURE; + return 1; } - return EXIT_SUCCESS; + return 0; } static int do_em_all(void) @@ -57,8 +57,7 @@ static int do_em_all(void) err = 0; while ((m = getmntent(f)) != NULL) if (strcmp(m->mnt_type, MNTTYPE_SWAP) == 0) - if (swap_enable_disable(m->mnt_fsname) == EXIT_FAILURE) - ++err; + err += swap_enable_disable(m->mnt_fsname); endmntent(f); @@ -69,13 +68,17 @@ static int do_em_all(void) extern int swap_on_off_main(int argc, char **argv) { - unsigned long opt = bb_getopt_ulflags(argc, argv, "a"); + int ret; - if (argc != 2) + if (argc == 1) bb_show_usage(); - if (opt & DO_ALL) + ret = bb_getopt_ulflags(argc, argv, "a"); + if (ret & DO_ALL) return do_em_all(); - return swap_enable_disable(argv[1]); + ret = 0; + while (*++argv) + ret += swap_enable_disable(*argv); + return ret; } |