diff options
author | Matt Kraai <kraai@debian.org> | 2000-12-06 15:55:23 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2000-12-06 15:55:23 +0000 |
commit | 92ed8a351908d60966fd9498574c9e6ace7bd5ab (patch) | |
tree | e02182bd51b722505acc3a0b571d25e147a2efca | |
parent | ab147f608d1215a9208e6d1fe93b6532a707dae4 (diff) | |
download | busybox-w32-92ed8a351908d60966fd9498574c9e6ace7bd5ab.tar.gz busybox-w32-92ed8a351908d60966fd9498574c9e6ace7bd5ab.tar.bz2 busybox-w32-92ed8a351908d60966fd9498574c9e6ace7bd5ab.zip |
Fix exit status on failure.
-rw-r--r-- | coreutils/df.c | 21 | ||||
-rw-r--r-- | coreutils/du.c | 11 | ||||
-rw-r--r-- | df.c | 21 | ||||
-rw-r--r-- | du.c | 11 | ||||
-rw-r--r-- | mount.c | 5 | ||||
-rw-r--r-- | umount.c | 2 | ||||
-rw-r--r-- | util-linux/mount.c | 5 | ||||
-rw-r--r-- | util-linux/umount.c | 2 |
8 files changed, 42 insertions, 36 deletions
diff --git a/coreutils/df.c b/coreutils/df.c index aefffc771..969a5b982 100644 --- a/coreutils/df.c +++ b/coreutils/df.c | |||
@@ -36,7 +36,7 @@ static int df(char *device, const char *mountPoint) | |||
36 | long blocks_percent_used; | 36 | long blocks_percent_used; |
37 | 37 | ||
38 | if (statfs(mountPoint, &s) != 0) { | 38 | if (statfs(mountPoint, &s) != 0) { |
39 | perror(mountPoint); | 39 | perrorMsg("%s", mountPoint); |
40 | return FALSE; | 40 | return FALSE; |
41 | } | 41 | } |
42 | 42 | ||
@@ -63,12 +63,13 @@ static int df(char *device, const char *mountPoint) | |||
63 | 63 | ||
64 | extern int df_main(int argc, char **argv) | 64 | extern int df_main(int argc, char **argv) |
65 | { | 65 | { |
66 | int status = EXIT_SUCCESS; | ||
67 | |||
66 | printf("%-20s %-14s %s %s %s %s\n", "Filesystem", | 68 | printf("%-20s %-14s %s %s %s %s\n", "Filesystem", |
67 | "1k-blocks", "Used", "Available", "Use%", "Mounted on"); | 69 | "1k-blocks", "Used", "Available", "Use%", "Mounted on"); |
68 | 70 | ||
69 | if (argc > 1) { | 71 | if (argc > 1) { |
70 | struct mntent *mountEntry; | 72 | struct mntent *mountEntry; |
71 | int status; | ||
72 | 73 | ||
73 | if (**(argv + 1) == '-') { | 74 | if (**(argv + 1) == '-') { |
74 | usage(df_usage); | 75 | usage(df_usage); |
@@ -76,32 +77,30 @@ extern int df_main(int argc, char **argv) | |||
76 | while (argc > 1) { | 77 | while (argc > 1) { |
77 | if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) { | 78 | if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) { |
78 | errorMsg("%s: can't find mount point.\n", argv[1]); | 79 | errorMsg("%s: can't find mount point.\n", argv[1]); |
79 | exit(FALSE); | 80 | status = EXIT_FAILURE; |
80 | } | 81 | } else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir)) |
81 | status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir); | 82 | status = EXIT_FAILURE; |
82 | if (status != TRUE) | ||
83 | return EXIT_FAILURE; | ||
84 | argc--; | 83 | argc--; |
85 | argv++; | 84 | argv++; |
86 | } | 85 | } |
87 | return EXIT_SUCCESS; | ||
88 | } else { | 86 | } else { |
89 | FILE *mountTable; | 87 | FILE *mountTable; |
90 | struct mntent *mountEntry; | 88 | struct mntent *mountEntry; |
91 | 89 | ||
92 | mountTable = setmntent(mtab_file, "r"); | 90 | mountTable = setmntent(mtab_file, "r"); |
93 | if (mountTable == 0) { | 91 | if (mountTable == 0) { |
94 | perror(mtab_file); | 92 | perrorMsg("%s", mtab_file); |
95 | return EXIT_FAILURE; | 93 | return EXIT_FAILURE; |
96 | } | 94 | } |
97 | 95 | ||
98 | while ((mountEntry = getmntent(mountTable))) { | 96 | while ((mountEntry = getmntent(mountTable))) { |
99 | df(mountEntry->mnt_fsname, mountEntry->mnt_dir); | 97 | if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir)) |
98 | status = EXIT_FAILURE; | ||
100 | } | 99 | } |
101 | endmntent(mountTable); | 100 | endmntent(mountTable); |
102 | } | 101 | } |
103 | 102 | ||
104 | return EXIT_FAILURE; | 103 | return status; |
105 | } | 104 | } |
106 | 105 | ||
107 | /* | 106 | /* |
diff --git a/coreutils/du.c b/coreutils/du.c index a0f1606fe..23bb141da 100644 --- a/coreutils/du.c +++ b/coreutils/du.c | |||
@@ -125,6 +125,7 @@ static long du(char *filename) | |||
125 | 125 | ||
126 | int du_main(int argc, char **argv) | 126 | int du_main(int argc, char **argv) |
127 | { | 127 | { |
128 | int status = EXIT_SUCCESS; | ||
128 | int i; | 129 | int i; |
129 | int c; | 130 | int c; |
130 | 131 | ||
@@ -147,12 +148,14 @@ int du_main(int argc, char **argv) | |||
147 | 148 | ||
148 | /* go through remaining args (if any) */ | 149 | /* go through remaining args (if any) */ |
149 | if (optind >= argc) { | 150 | if (optind >= argc) { |
150 | du("."); | 151 | if (du(".") == 0) |
152 | status = EXIT_FAILURE; | ||
151 | } else { | 153 | } else { |
152 | long sum; | 154 | long sum; |
153 | 155 | ||
154 | for (i=optind; i < argc; i++) { | 156 | for (i=optind; i < argc; i++) { |
155 | sum = du(argv[i]); | 157 | if (du(argv[i]) == 0) |
158 | status = EXIT_FAILURE; | ||
156 | if (sum && isDirectory(argv[i], FALSE, NULL)) { | 159 | if (sum && isDirectory(argv[i], FALSE, NULL)) { |
157 | print_normal(sum, argv[i]); | 160 | print_normal(sum, argv[i]); |
158 | } | 161 | } |
@@ -160,10 +163,10 @@ int du_main(int argc, char **argv) | |||
160 | } | 163 | } |
161 | } | 164 | } |
162 | 165 | ||
163 | return EXIT_SUCCESS; | 166 | return status; |
164 | } | 167 | } |
165 | 168 | ||
166 | /* $Id: du.c,v 1.26 2000/12/01 02:55:13 kraai Exp $ */ | 169 | /* $Id: du.c,v 1.27 2000/12/06 15:55:23 kraai Exp $ */ |
167 | /* | 170 | /* |
168 | Local Variables: | 171 | Local Variables: |
169 | c-file-style: "linux" | 172 | c-file-style: "linux" |
@@ -36,7 +36,7 @@ static int df(char *device, const char *mountPoint) | |||
36 | long blocks_percent_used; | 36 | long blocks_percent_used; |
37 | 37 | ||
38 | if (statfs(mountPoint, &s) != 0) { | 38 | if (statfs(mountPoint, &s) != 0) { |
39 | perror(mountPoint); | 39 | perrorMsg("%s", mountPoint); |
40 | return FALSE; | 40 | return FALSE; |
41 | } | 41 | } |
42 | 42 | ||
@@ -63,12 +63,13 @@ static int df(char *device, const char *mountPoint) | |||
63 | 63 | ||
64 | extern int df_main(int argc, char **argv) | 64 | extern int df_main(int argc, char **argv) |
65 | { | 65 | { |
66 | int status = EXIT_SUCCESS; | ||
67 | |||
66 | printf("%-20s %-14s %s %s %s %s\n", "Filesystem", | 68 | printf("%-20s %-14s %s %s %s %s\n", "Filesystem", |
67 | "1k-blocks", "Used", "Available", "Use%", "Mounted on"); | 69 | "1k-blocks", "Used", "Available", "Use%", "Mounted on"); |
68 | 70 | ||
69 | if (argc > 1) { | 71 | if (argc > 1) { |
70 | struct mntent *mountEntry; | 72 | struct mntent *mountEntry; |
71 | int status; | ||
72 | 73 | ||
73 | if (**(argv + 1) == '-') { | 74 | if (**(argv + 1) == '-') { |
74 | usage(df_usage); | 75 | usage(df_usage); |
@@ -76,32 +77,30 @@ extern int df_main(int argc, char **argv) | |||
76 | while (argc > 1) { | 77 | while (argc > 1) { |
77 | if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) { | 78 | if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) { |
78 | errorMsg("%s: can't find mount point.\n", argv[1]); | 79 | errorMsg("%s: can't find mount point.\n", argv[1]); |
79 | exit(FALSE); | 80 | status = EXIT_FAILURE; |
80 | } | 81 | } else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir)) |
81 | status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir); | 82 | status = EXIT_FAILURE; |
82 | if (status != TRUE) | ||
83 | return EXIT_FAILURE; | ||
84 | argc--; | 83 | argc--; |
85 | argv++; | 84 | argv++; |
86 | } | 85 | } |
87 | return EXIT_SUCCESS; | ||
88 | } else { | 86 | } else { |
89 | FILE *mountTable; | 87 | FILE *mountTable; |
90 | struct mntent *mountEntry; | 88 | struct mntent *mountEntry; |
91 | 89 | ||
92 | mountTable = setmntent(mtab_file, "r"); | 90 | mountTable = setmntent(mtab_file, "r"); |
93 | if (mountTable == 0) { | 91 | if (mountTable == 0) { |
94 | perror(mtab_file); | 92 | perrorMsg("%s", mtab_file); |
95 | return EXIT_FAILURE; | 93 | return EXIT_FAILURE; |
96 | } | 94 | } |
97 | 95 | ||
98 | while ((mountEntry = getmntent(mountTable))) { | 96 | while ((mountEntry = getmntent(mountTable))) { |
99 | df(mountEntry->mnt_fsname, mountEntry->mnt_dir); | 97 | if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir)) |
98 | status = EXIT_FAILURE; | ||
100 | } | 99 | } |
101 | endmntent(mountTable); | 100 | endmntent(mountTable); |
102 | } | 101 | } |
103 | 102 | ||
104 | return EXIT_FAILURE; | 103 | return status; |
105 | } | 104 | } |
106 | 105 | ||
107 | /* | 106 | /* |
@@ -125,6 +125,7 @@ static long du(char *filename) | |||
125 | 125 | ||
126 | int du_main(int argc, char **argv) | 126 | int du_main(int argc, char **argv) |
127 | { | 127 | { |
128 | int status = EXIT_SUCCESS; | ||
128 | int i; | 129 | int i; |
129 | int c; | 130 | int c; |
130 | 131 | ||
@@ -147,12 +148,14 @@ int du_main(int argc, char **argv) | |||
147 | 148 | ||
148 | /* go through remaining args (if any) */ | 149 | /* go through remaining args (if any) */ |
149 | if (optind >= argc) { | 150 | if (optind >= argc) { |
150 | du("."); | 151 | if (du(".") == 0) |
152 | status = EXIT_FAILURE; | ||
151 | } else { | 153 | } else { |
152 | long sum; | 154 | long sum; |
153 | 155 | ||
154 | for (i=optind; i < argc; i++) { | 156 | for (i=optind; i < argc; i++) { |
155 | sum = du(argv[i]); | 157 | if (du(argv[i]) == 0) |
158 | status = EXIT_FAILURE; | ||
156 | if (sum && isDirectory(argv[i], FALSE, NULL)) { | 159 | if (sum && isDirectory(argv[i], FALSE, NULL)) { |
157 | print_normal(sum, argv[i]); | 160 | print_normal(sum, argv[i]); |
158 | } | 161 | } |
@@ -160,10 +163,10 @@ int du_main(int argc, char **argv) | |||
160 | } | 163 | } |
161 | } | 164 | } |
162 | 165 | ||
163 | return EXIT_SUCCESS; | 166 | return status; |
164 | } | 167 | } |
165 | 168 | ||
166 | /* $Id: du.c,v 1.26 2000/12/01 02:55:13 kraai Exp $ */ | 169 | /* $Id: du.c,v 1.27 2000/12/06 15:55:23 kraai Exp $ */ |
167 | /* | 170 | /* |
168 | Local Variables: | 171 | Local Variables: |
169 | c-file-style: "linux" | 172 | c-file-style: "linux" |
@@ -493,8 +493,9 @@ singlemount: | |||
493 | } | 493 | } |
494 | } | 494 | } |
495 | #endif | 495 | #endif |
496 | rc = mount_one(device, directory, filesystemType, flags, | 496 | if (!mount_one(device, directory, filesystemType, flags, |
497 | string_flags, useMtab, fakeIt, extra_opts, TRUE); | 497 | string_flags, useMtab, fakeIt, extra_opts, TRUE)) |
498 | rc = EXIT_FAILURE; | ||
498 | 499 | ||
499 | if (all == FALSE) | 500 | if (all == FALSE) |
500 | break; | 501 | break; |
@@ -278,7 +278,7 @@ extern int umount_main(int argc, char **argv) | |||
278 | else | 278 | else |
279 | return EXIT_FAILURE; | 279 | return EXIT_FAILURE; |
280 | } | 280 | } |
281 | if (do_umount(*argv, useMtab) == 0) | 281 | if (do_umount(*argv, useMtab) == TRUE) |
282 | return EXIT_SUCCESS; | 282 | return EXIT_SUCCESS; |
283 | perror("umount"); | 283 | perror("umount"); |
284 | return EXIT_FAILURE; | 284 | return EXIT_FAILURE; |
diff --git a/util-linux/mount.c b/util-linux/mount.c index 34dbb5eee..ff8aef379 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -493,8 +493,9 @@ singlemount: | |||
493 | } | 493 | } |
494 | } | 494 | } |
495 | #endif | 495 | #endif |
496 | rc = mount_one(device, directory, filesystemType, flags, | 496 | if (!mount_one(device, directory, filesystemType, flags, |
497 | string_flags, useMtab, fakeIt, extra_opts, TRUE); | 497 | string_flags, useMtab, fakeIt, extra_opts, TRUE)) |
498 | rc = EXIT_FAILURE; | ||
498 | 499 | ||
499 | if (all == FALSE) | 500 | if (all == FALSE) |
500 | break; | 501 | break; |
diff --git a/util-linux/umount.c b/util-linux/umount.c index 5f3e59caf..eff080463 100644 --- a/util-linux/umount.c +++ b/util-linux/umount.c | |||
@@ -278,7 +278,7 @@ extern int umount_main(int argc, char **argv) | |||
278 | else | 278 | else |
279 | return EXIT_FAILURE; | 279 | return EXIT_FAILURE; |
280 | } | 280 | } |
281 | if (do_umount(*argv, useMtab) == 0) | 281 | if (do_umount(*argv, useMtab) == TRUE) |
282 | return EXIT_SUCCESS; | 282 | return EXIT_SUCCESS; |
283 | perror("umount"); | 283 | perror("umount"); |
284 | return EXIT_FAILURE; | 284 | return EXIT_FAILURE; |