du: remove stray whitespace in help text
[oweals/busybox.git] / coreutils / du.c
index 730d6d162eb4fccceedce4bdb08dcc79a7e83978..790ff0f8e0304b06db589396ca1979ad81dc16e7 100644 (file)
@@ -6,7 +6,7 @@
  * Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org>
  * Copyright (C) 2002  Edward Betts <edward@debian.org>
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
 /* BB_AUDIT SUSv3 compliant (unless default blocksize set to 1k) */
  * 4) Fixed busybox bug #1284 involving long overflow with human_readable.
  */
 
+//usage:#define du_trivial_usage
+//usage:       "[-aHLdclsx" IF_FEATURE_HUMAN_READABLE("hm") "k] [FILE]..."
+//usage:#define du_full_usage "\n\n"
+//usage:       "Summarize disk space used for each FILE and/or directory.\n"
+//usage:       "Disk space is printed in units of "
+//usage:       IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K("1024")
+//usage:       IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K("512")
+//usage:       " bytes.\n"
+//usage:     "\n       -a      Show file sizes too"
+//usage:     "\n       -L      Follow all symlinks"
+//usage:     "\n       -H      Follow symlinks on command line"
+//usage:     "\n       -d N    Limit output to directories (and files with -a) of depth < N"
+//usage:     "\n       -c      Show grand total"
+//usage:     "\n       -l      Count sizes many times if hard linked"
+//usage:     "\n       -s      Display only a total for each argument"
+//usage:     "\n       -x      Skip directories on different filesystems"
+//usage:       IF_FEATURE_HUMAN_READABLE(
+//usage:     "\n       -h      Sizes in human readable format (e.g., 1K 243M 2G)"
+//usage:     "\n       -m      Sizes in megabytes"
+//usage:       )
+//usage:     "\n       -k      Sizes in kilobytes"
+//usage:                       IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(" (default)")
+//usage:
+//usage:#define du_example_usage
+//usage:       "$ du\n"
+//usage:       "16      ./CVS\n"
+//usage:       "12      ./kernel-patches/CVS\n"
+//usage:       "80      ./kernel-patches\n"
+//usage:       "12      ./tests/CVS\n"
+//usage:       "36      ./tests\n"
+//usage:       "12      ./scripts/CVS\n"
+//usage:       "16      ./scripts\n"
+//usage:       "12      ./docs/CVS\n"
+//usage:       "104     ./docs\n"
+//usage:       "2417    .\n"
+
 #include "libbb.h"
 
 enum {
@@ -50,11 +86,12 @@ struct globals {
        int slink_depth;
        int du_depth;
        dev_t dir_dev;
-};
+} FIX_ALIASING;
 #define G (*(struct globals*)&bb_common_bufsiz1)
+#define INIT_G() do { } while (0)
 
 
-static void print(unsigned long size, const char *filename)
+static void print(unsigned long long size, const char *filename)
 {
        /* TODO - May not want to defer error checking here. */
 #if ENABLE_FEATURE_HUMAN_READABLE
@@ -68,15 +105,15 @@ static void print(unsigned long size, const char *filename)
                size++;
                size >>= 1;
        }
-       printf("%lu\t%s\n", size, filename);
+       printf("%llu\t%s\n", size, filename);
 #endif
 }
 
 /* tiny recursive du */
-static unsigned long du(const char *filename)
+static unsigned long long du(const char *filename)
 {
        struct stat statbuf;
-       unsigned long sum;
+       unsigned long long sum;
 
        if (lstat(filename, &statbuf) != 0) {
                bb_simple_perror_msg(filename);
@@ -153,10 +190,12 @@ static unsigned long du(const char *filename)
 int du_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int du_main(int argc UNUSED_PARAM, char **argv)
 {
-       unsigned long total;
+       unsigned long long total;
        int slink_depth_save;
        unsigned opt;
 
+       INIT_G();
+
 #if ENABLE_FEATURE_HUMAN_READABLE
        IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 1024;)
        IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 512;)