aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2000-12-06 15:55:23 +0000
committerMatt Kraai <kraai@debian.org>2000-12-06 15:55:23 +0000
commit92ed8a351908d60966fd9498574c9e6ace7bd5ab (patch)
treee02182bd51b722505acc3a0b571d25e147a2efca
parentab147f608d1215a9208e6d1fe93b6532a707dae4 (diff)
downloadbusybox-92ed8a351908d60966fd9498574c9e6ace7bd5ab.tar.gz
Fix exit status on failure.
-rw-r--r--coreutils/df.c21
-rw-r--r--coreutils/du.c11
-rw-r--r--df.c21
-rw-r--r--du.c11
-rw-r--r--mount.c5
-rw-r--r--umount.c2
-rw-r--r--util-linux/mount.c5
-rw-r--r--util-linux/umount.c2
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)
long blocks_percent_used;
if (statfs(mountPoint, &s) != 0) {
- perror(mountPoint);
+ perrorMsg("%s", mountPoint);
return FALSE;
}
@@ -63,12 +63,13 @@ static int df(char *device, const char *mountPoint)
extern int df_main(int argc, char **argv)
{
+ int status = EXIT_SUCCESS;
+
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
"1k-blocks", "Used", "Available", "Use%", "Mounted on");
if (argc > 1) {
struct mntent *mountEntry;
- int status;
if (**(argv + 1) == '-') {
usage(df_usage);
@@ -76,32 +77,30 @@ extern int df_main(int argc, char **argv)
while (argc > 1) {
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
errorMsg("%s: can't find mount point.\n", argv[1]);
- exit(FALSE);
- }
- status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
- if (status != TRUE)
- return EXIT_FAILURE;
+ status = EXIT_FAILURE;
+ } else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
+ status = EXIT_FAILURE;
argc--;
argv++;
}
- return EXIT_SUCCESS;
} else {
FILE *mountTable;
struct mntent *mountEntry;
mountTable = setmntent(mtab_file, "r");
if (mountTable == 0) {
- perror(mtab_file);
+ perrorMsg("%s", mtab_file);
return EXIT_FAILURE;
}
while ((mountEntry = getmntent(mountTable))) {
- df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
+ if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
+ status = EXIT_FAILURE;
}
endmntent(mountTable);
}
- return EXIT_FAILURE;
+ return status;
}
/*
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)
int du_main(int argc, char **argv)
{
+ int status = EXIT_SUCCESS;
int i;
int c;
@@ -147,12 +148,14 @@ int du_main(int argc, char **argv)
/* go through remaining args (if any) */
if (optind >= argc) {
- du(".");
+ if (du(".") == 0)
+ status = EXIT_FAILURE;
} else {
long sum;
for (i=optind; i < argc; i++) {
- sum = du(argv[i]);
+ if (du(argv[i]) == 0)
+ status = EXIT_FAILURE;
if (sum && isDirectory(argv[i], FALSE, NULL)) {
print_normal(sum, argv[i]);
}
@@ -160,10 +163,10 @@ int du_main(int argc, char **argv)
}
}
- return EXIT_SUCCESS;
+ return status;
}
-/* $Id: du.c,v 1.26 2000/12/01 02:55:13 kraai Exp $ */
+/* $Id: du.c,v 1.27 2000/12/06 15:55:23 kraai Exp $ */
/*
Local Variables:
c-file-style: "linux"
diff --git a/df.c b/df.c
index aefffc771..969a5b982 100644
--- a/df.c
+++ b/df.c
@@ -36,7 +36,7 @@ static int df(char *device, const char *mountPoint)
long blocks_percent_used;
if (statfs(mountPoint, &s) != 0) {
- perror(mountPoint);
+ perrorMsg("%s", mountPoint);
return FALSE;
}
@@ -63,12 +63,13 @@ static int df(char *device, const char *mountPoint)
extern int df_main(int argc, char **argv)
{
+ int status = EXIT_SUCCESS;
+
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
"1k-blocks", "Used", "Available", "Use%", "Mounted on");
if (argc > 1) {
struct mntent *mountEntry;
- int status;
if (**(argv + 1) == '-') {
usage(df_usage);
@@ -76,32 +77,30 @@ extern int df_main(int argc, char **argv)
while (argc > 1) {
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
errorMsg("%s: can't find mount point.\n", argv[1]);
- exit(FALSE);
- }
- status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
- if (status != TRUE)
- return EXIT_FAILURE;
+ status = EXIT_FAILURE;
+ } else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
+ status = EXIT_FAILURE;
argc--;
argv++;
}
- return EXIT_SUCCESS;
} else {
FILE *mountTable;
struct mntent *mountEntry;
mountTable = setmntent(mtab_file, "r");
if (mountTable == 0) {
- perror(mtab_file);
+ perrorMsg("%s", mtab_file);
return EXIT_FAILURE;
}
while ((mountEntry = getmntent(mountTable))) {
- df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
+ if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
+ status = EXIT_FAILURE;
}
endmntent(mountTable);
}
- return EXIT_FAILURE;
+ return status;
}
/*
diff --git a/du.c b/du.c
index a0f1606fe..23bb141da 100644
--- a/du.c
+++ b/du.c
@@ -125,6 +125,7 @@ static long du(char *filename)
int du_main(int argc, char **argv)
{
+ int status = EXIT_SUCCESS;
int i;
int c;
@@ -147,12 +148,14 @@ int du_main(int argc, char **argv)
/* go through remaining args (if any) */
if (optind >= argc) {
- du(".");
+ if (du(".") == 0)
+ status = EXIT_FAILURE;
} else {
long sum;
for (i=optind; i < argc; i++) {
- sum = du(argv[i]);
+ if (du(argv[i]) == 0)
+ status = EXIT_FAILURE;
if (sum && isDirectory(argv[i], FALSE, NULL)) {
print_normal(sum, argv[i]);
}
@@ -160,10 +163,10 @@ int du_main(int argc, char **argv)
}
}
- return EXIT_SUCCESS;
+ return status;
}
-/* $Id: du.c,v 1.26 2000/12/01 02:55:13 kraai Exp $ */
+/* $Id: du.c,v 1.27 2000/12/06 15:55:23 kraai Exp $ */
/*
Local Variables:
c-file-style: "linux"
diff --git a/mount.c b/mount.c
index 34dbb5eee..ff8aef379 100644
--- a/mount.c
+++ b/mount.c
@@ -493,8 +493,9 @@ singlemount:
}
}
#endif
- rc = mount_one(device, directory, filesystemType, flags,
- string_flags, useMtab, fakeIt, extra_opts, TRUE);
+ if (!mount_one(device, directory, filesystemType, flags,
+ string_flags, useMtab, fakeIt, extra_opts, TRUE))
+ rc = EXIT_FAILURE;
if (all == FALSE)
break;
diff --git a/umount.c b/umount.c
index 5f3e59caf..eff080463 100644
--- a/umount.c
+++ b/umount.c
@@ -278,7 +278,7 @@ extern int umount_main(int argc, char **argv)
else
return EXIT_FAILURE;
}
- if (do_umount(*argv, useMtab) == 0)
+ if (do_umount(*argv, useMtab) == TRUE)
return EXIT_SUCCESS;
perror("umount");
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:
}
}
#endif
- rc = mount_one(device, directory, filesystemType, flags,
- string_flags, useMtab, fakeIt, extra_opts, TRUE);
+ if (!mount_one(device, directory, filesystemType, flags,
+ string_flags, useMtab, fakeIt, extra_opts, TRUE))
+ rc = EXIT_FAILURE;
if (all == FALSE)
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)
else
return EXIT_FAILURE;
}
- if (do_umount(*argv, useMtab) == 0)
+ if (do_umount(*argv, useMtab) == TRUE)
return EXIT_SUCCESS;
perror("umount");
return EXIT_FAILURE;