diff options
author | vapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-09-13 02:29:39 +0000 |
---|---|---|
committer | vapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-09-13 02:29:39 +0000 |
commit | 8f5f300ebab513ef6caaa44a5b0808bbe57795bb (patch) | |
tree | 6b47c13d856c6314f964500279808eb3a750e499 | |
parent | 1e7461203f0fa021704370808423763e1c2ee199 (diff) | |
download | busybox-w32-8f5f300ebab513ef6caaa44a5b0808bbe57795bb.tar.gz busybox-w32-8f5f300ebab513ef6caaa44a5b0808bbe57795bb.tar.bz2 busybox-w32-8f5f300ebab513ef6caaa44a5b0808bbe57795bb.zip |
whitespace/syntax cleanups, dont mind me :p
git-svn-id: svn://busybox.net/trunk/busybox@11443 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | util-linux/swaponoff.c | 58 |
1 files changed, 22 insertions, 36 deletions
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c index 1e3fe5a43..0080ff294 100644 --- a/util-linux/swaponoff.c +++ b/util-linux/swaponoff.c | |||
@@ -4,20 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | 5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * Licensed under the GPL v2, see the file LICENSE in this tarball. |
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | 8 | */ |
22 | 9 | ||
23 | #include <stdio.h> | 10 | #include <stdio.h> |
@@ -36,16 +23,13 @@ static int swap_enable_disable(const char *device) | |||
36 | int status; | 23 | int status; |
37 | struct stat st; | 24 | struct stat st; |
38 | 25 | ||
39 | if (stat(device, &st) < 0) { | 26 | if (stat(device, &st) < 0) |
40 | bb_perror_msg_and_die("cannot stat %s", device); | 27 | bb_perror_msg_and_die("cannot stat %s", device); |
41 | } | ||
42 | 28 | ||
43 | /* test for holes */ | 29 | /* test for holes */ |
44 | if (S_ISREG(st.st_mode)) { | 30 | if (S_ISREG(st.st_mode)) |
45 | if (st.st_blocks * 512 < st.st_size) { | 31 | if (st.st_blocks * 512 < st.st_size) |
46 | bb_error_msg_and_die("swap file has holes"); | 32 | bb_error_msg_and_die("swap file has holes"); |
47 | } | ||
48 | } | ||
49 | 33 | ||
50 | if (bb_applet_name[5] == 'n') | 34 | if (bb_applet_name[5] == 'n') |
51 | status = swapon(device, 0); | 35 | status = swapon(device, 0); |
@@ -56,40 +40,42 @@ static int swap_enable_disable(const char *device) | |||
56 | bb_perror_msg("%s", device); | 40 | bb_perror_msg("%s", device); |
57 | return EXIT_FAILURE; | 41 | return EXIT_FAILURE; |
58 | } | 42 | } |
59 | /*printf("%s: %s\n", bb_applet_name, device);*/ | 43 | |
60 | return EXIT_SUCCESS; | 44 | return EXIT_SUCCESS; |
61 | } | 45 | } |
62 | 46 | ||
63 | static int do_em_all(void) | 47 | static int do_em_all(void) |
64 | { | 48 | { |
65 | struct mntent *m; | 49 | struct mntent *m; |
66 | FILE *f = setmntent("/etc/fstab", "r"); | 50 | FILE *f; |
67 | int err = 0; | 51 | int err; |
68 | 52 | ||
53 | f = setmntent("/etc/fstab", "r"); | ||
69 | if (f == NULL) | 54 | if (f == NULL) |
70 | bb_perror_msg_and_die("/etc/fstab"); | 55 | bb_perror_msg_and_die("/etc/fstab"); |
71 | while ((m = getmntent(f)) != NULL) { | 56 | |
72 | if (strcmp(m->mnt_type, MNTTYPE_SWAP)==0) { | 57 | err = 0; |
73 | if(swap_enable_disable(m->mnt_fsname) == EXIT_FAILURE) | 58 | while ((m = getmntent(f)) != NULL) |
74 | err++; | 59 | if (strcmp(m->mnt_type, MNTTYPE_SWAP) == 0) |
75 | } | 60 | if (swap_enable_disable(m->mnt_fsname) == EXIT_FAILURE) |
76 | } | 61 | ++err; |
62 | |||
77 | endmntent(f); | 63 | endmntent(f); |
64 | |||
78 | return err; | 65 | return err; |
79 | } | 66 | } |
80 | 67 | ||
81 | #define DO_ALL 1 | 68 | #define DO_ALL 0x01 |
82 | 69 | ||
83 | extern int swap_on_off_main(int argc, char **argv) | 70 | extern int swap_on_off_main(int argc, char **argv) |
84 | { | 71 | { |
85 | unsigned long opt = bb_getopt_ulflags (argc, argv, "a"); | 72 | unsigned long opt = bb_getopt_ulflags(argc, argv, "a"); |
86 | 73 | ||
87 | if (argc != 2) { | 74 | if (argc != 2) |
88 | bb_show_usage(); | 75 | bb_show_usage(); |
89 | } | 76 | |
90 | |||
91 | if (opt & DO_ALL) | 77 | if (opt & DO_ALL) |
92 | return do_em_all(); | 78 | return do_em_all(); |
93 | 79 | ||
94 | return swap_enable_disable(argv[1]); | 80 | return swap_enable_disable(argv[1]); |
95 | } | 81 | } |