Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/coreutils/du.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/coreutils/du.c
r2725 r3232 23 23 * 4) Fixed busybox bug #1284 involving long overflow with human_readable. 24 24 */ 25 26 //usage:#define du_trivial_usage 27 //usage: "[-aHLdclsx" IF_FEATURE_HUMAN_READABLE("hm") "k] [FILE]..." 28 //usage:#define du_full_usage "\n\n" 29 //usage: "Summarize disk space used for each FILE and/or directory\n" 30 //usage: "\n -a Show file sizes too" 31 //usage: "\n -L Follow all symlinks" 32 //usage: "\n -H Follow symlinks on command line" 33 //usage: "\n -d N Limit output to directories (and files with -a) of depth < N" 34 //usage: "\n -c Show grand total" 35 //usage: "\n -l Count sizes many times if hard linked" 36 //usage: "\n -s Display only a total for each argument" 37 //usage: "\n -x Skip directories on different filesystems" 38 //usage: IF_FEATURE_HUMAN_READABLE( 39 //usage: "\n -h Sizes in human readable format (e.g., 1K 243M 2G)" 40 //usage: "\n -m Sizes in megabytes" 41 //usage: ) 42 //usage: "\n -k Sizes in kilobytes" IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(" (default)") 43 //usage: IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K( 44 //usage: "\n Default unit is 512 bytes" 45 //usage: ) 46 //usage: 47 //usage:#define du_example_usage 48 //usage: "$ du\n" 49 //usage: "16 ./CVS\n" 50 //usage: "12 ./kernel-patches/CVS\n" 51 //usage: "80 ./kernel-patches\n" 52 //usage: "12 ./tests/CVS\n" 53 //usage: "36 ./tests\n" 54 //usage: "12 ./scripts/CVS\n" 55 //usage: "16 ./scripts\n" 56 //usage: "12 ./docs/CVS\n" 57 //usage: "104 ./docs\n" 58 //usage: "2417 .\n" 25 59 26 60 #include "libbb.h" … … 53 87 } FIX_ALIASING; 54 88 #define G (*(struct globals*)&bb_common_bufsiz1) 55 56 57 static void print(unsigned long size, const char *filename) 89 #define INIT_G() do { } while (0) 90 91 92 /* FIXME? coreutils' du rounds sizes up: 93 * for example, 1025k file is shown as "2" by du -m. 94 * We round to nearest. 95 */ 96 static void print(unsigned long long size, const char *filename) 58 97 { 59 98 /* TODO - May not want to defer error checking here. */ … … 69 108 size >>= 1; 70 109 } 71 printf("%l u\t%s\n", size, filename);110 printf("%llu\t%s\n", size, filename); 72 111 #endif 73 112 } 74 113 75 114 /* tiny recursive du */ 76 static unsigned long du(const char *filename)115 static unsigned long long du(const char *filename) 77 116 { 78 117 struct stat statbuf; 79 unsigned long sum;118 unsigned long long sum; 80 119 81 120 if (lstat(filename, &statbuf) != 0) { … … 154 193 int du_main(int argc UNUSED_PARAM, char **argv) 155 194 { 156 unsigned long total;195 unsigned long long total; 157 196 int slink_depth_save; 158 197 unsigned opt; 198 199 INIT_G(); 159 200 160 201 #if ENABLE_FEATURE_HUMAN_READABLE
Note:
See TracChangeset
for help on using the changeset viewer.