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 /util-linux | |
| parent | 0ec71bf4b8a31ce6d49453a22a6244cc80e3122b (diff) | |
| download | busybox-w32-2d5e4f6b05bcd566a418aae5b12a7f0dfb2d8e44.tar.gz busybox-w32-2d5e4f6b05bcd566a418aae5b12a7f0dfb2d8e44.tar.bz2 busybox-w32-2d5e4f6b05bcd566a418aae5b12a7f0dfb2d8e44.zip | |
accept unlimited number of swap arguments like the real swap{on,off} and shrink do_em_all a little
Diffstat (limited to 'util-linux')
| -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) | |||
| 38 | 38 | ||
| 39 | if (status != 0) { | 39 | if (status != 0) { |
| 40 | bb_perror_msg("%s", device); | 40 | bb_perror_msg("%s", device); |
| 41 | return EXIT_FAILURE; | 41 | return 1; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | return EXIT_SUCCESS; | 44 | return 0; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | static int do_em_all(void) | 47 | static int do_em_all(void) |
| @@ -57,8 +57,7 @@ static int do_em_all(void) | |||
| 57 | err = 0; | 57 | err = 0; |
| 58 | while ((m = getmntent(f)) != NULL) | 58 | while ((m = getmntent(f)) != NULL) |
| 59 | if (strcmp(m->mnt_type, MNTTYPE_SWAP) == 0) | 59 | if (strcmp(m->mnt_type, MNTTYPE_SWAP) == 0) |
| 60 | if (swap_enable_disable(m->mnt_fsname) == EXIT_FAILURE) | 60 | err += swap_enable_disable(m->mnt_fsname); |
| 61 | ++err; | ||
| 62 | 61 | ||
| 63 | endmntent(f); | 62 | endmntent(f); |
| 64 | 63 | ||
| @@ -69,13 +68,17 @@ static int do_em_all(void) | |||
| 69 | 68 | ||
| 70 | extern int swap_on_off_main(int argc, char **argv) | 69 | extern int swap_on_off_main(int argc, char **argv) |
| 71 | { | 70 | { |
| 72 | unsigned long opt = bb_getopt_ulflags(argc, argv, "a"); | 71 | int ret; |
| 73 | 72 | ||
| 74 | if (argc != 2) | 73 | if (argc == 1) |
| 75 | bb_show_usage(); | 74 | bb_show_usage(); |
| 76 | 75 | ||
| 77 | if (opt & DO_ALL) | 76 | ret = bb_getopt_ulflags(argc, argv, "a"); |
| 77 | if (ret & DO_ALL) | ||
| 78 | return do_em_all(); | 78 | return do_em_all(); |
| 79 | 79 | ||
| 80 | return swap_enable_disable(argv[1]); | 80 | ret = 0; |
| 81 | while (*++argv) | ||
| 82 | ret += swap_enable_disable(*argv); | ||
| 83 | return ret; | ||
| 81 | } | 84 | } |
