X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=df.c;h=8d6242c56c88cb08259eb28d71f5337b6692ded3;hb=62f987e95f497a21bc1455153dd156aa12718574;hp=331ef2d49d65a6d073fa69cd9e99bb85117e6abf;hpb=ec5bd90916b6e815a36c14ac04d1b78e3e487400;p=oweals%2Fbusybox.git diff --git a/df.c b/df.c index 331ef2d49..8d6242c56 100644 --- a/df.c +++ b/df.c @@ -2,7 +2,7 @@ /* * Mini df implementation for busybox * - * Copyright (C) 1999 by Lineo, inc. + * Copyright (C) 1999,2000 by Lineo, inc. * Written by Erik Andersen , * based on original code by (I think) Bruce Perens . * @@ -22,16 +22,11 @@ * */ -#include "internal.h" +#include "busybox.h" #include #include -#include #include -static const char df_usage[] = "df [filesystem ...]\n" - - "\n" "\tPrint the filesystem space used and space available.\n"; - extern const char mtab_file[]; /* Defined in utility.c */ static int df(char *device, const char *mountPoint) @@ -49,7 +44,6 @@ static int df(char *device, const char *mountPoint) blocks_used = s.f_blocks - s.f_bfree; blocks_percent_used = (long) (blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5); - /* Note that if /etc/fstab is missing, libc can't fix up /dev/root for us */ if (strcmp(device, "/dev/root") == 0) { /* Adjusts device to be the real root device, * or leaves device alone if it can't find it */ @@ -76,9 +70,12 @@ extern int df_main(int argc, char **argv) struct mntent *mountEntry; int status; + if (**(argv + 1) == '-') { + usage(df_usage); + } while (argc > 1) { if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) { - fprintf(stderr, "%s: can't find mount point.\n", argv[1]); + errorMsg("%s: can't find mount point.\n", argv[1]); exit(FALSE); } status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir); @@ -104,7 +101,7 @@ extern int df_main(int argc, char **argv) endmntent(mountTable); } - exit(TRUE); + return(TRUE); } /*