summaryrefslogtreecommitdiff
path: root/coreutils/df.c
diff options
context:
space:
mode:
authorMatt Kraai2000-12-06 15:55:23 +0000
committerMatt Kraai2000-12-06 15:55:23 +0000
commit92ed8a351908d60966fd9498574c9e6ace7bd5ab (patch)
treee02182bd51b722505acc3a0b571d25e147a2efca /coreutils/df.c
parentab147f608d1215a9208e6d1fe93b6532a707dae4 (diff)
downloadbusybox-92ed8a351908d60966fd9498574c9e6ace7bd5ab.zip
busybox-92ed8a351908d60966fd9498574c9e6ace7bd5ab.tar.gz
Fix exit status on failure.
Diffstat (limited to 'coreutils/df.c')
-rw-r--r--coreutils/df.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/coreutils/df.c b/coreutils/df.c
index aefffc7..969a5b9 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;
}
/*