Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/coreutils/du.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/coreutils/du.c
r3232 r3621 59 59 60 60 #include "libbb.h" 61 #include "common_bufsiz.h" 61 62 62 63 enum { … … 76 77 struct globals { 77 78 #if ENABLE_FEATURE_HUMAN_READABLE 78 unsigned long disp_ hr;79 unsigned long disp_unit; 79 80 #else 80 81 unsigned disp_k; … … 86 87 dev_t dir_dev; 87 88 } FIX_ALIASING; 88 #define G (*(struct globals*)&bb_common_bufsiz1) 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 */ 89 #define G (*(struct globals*)bb_common_bufsiz1) 90 #define INIT_G() do { setup_common_bufsiz(); } while (0) 91 92 96 93 static void print(unsigned long long size, const char *filename) 97 94 { 98 95 /* TODO - May not want to defer error checking here. */ 99 96 #if ENABLE_FEATURE_HUMAN_READABLE 97 # if ENABLE_DESKTOP 98 /* ~30 bytes of code for extra comtat: 99 * coreutils' du rounds sizes up: 100 * for example, 1025k file is shown as "2" by du -m. 101 * We round to nearest if human-readable [too hard to fix], 102 * else (fixed scale such as -m), we round up. To that end, 103 * add yet another half of the unit before displaying: 104 */ 105 if (G.disp_unit) 106 size += (G.disp_unit-1) / (unsigned)(512 * 2); 107 # endif 100 108 printf("%s\t%s\n", 101 /* size x 512 / G.disp_hr, show one fractional, 102 * use suffixes if G.disp_hr == 0 */ 103 make_human_readable_str(size, 512, G.disp_hr), 109 /* size x 512 / G.disp_unit. 110 * If G.disp_unit == 0, show one fractional 111 * and use suffixes 112 */ 113 make_human_readable_str(size, 512, G.disp_unit), 104 114 filename); 105 115 #else … … 200 210 201 211 #if ENABLE_FEATURE_HUMAN_READABLE 202 IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_ hr= 1024;)203 IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_ hr= 512;)212 IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_unit = 1024;) 213 IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_unit = 512;) 204 214 if (getenv("POSIXLY_CORRECT")) /* TODO - a new libbb function? */ 205 G.disp_ hr= 512;215 G.disp_unit = 512; 206 216 #else 207 217 IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_k = 1;) … … 221 231 argv += optind; 222 232 if (opt & OPT_h_for_humans) { 223 G.disp_ hr= 0;233 G.disp_unit = 0; 224 234 } 225 235 if (opt & OPT_m_mbytes) { 226 G.disp_ hr= 1024*1024;236 G.disp_unit = 1024*1024; 227 237 } 228 238 if (opt & OPT_k_kbytes) { 229 G.disp_ hr= 1024;239 G.disp_unit = 1024; 230 240 } 231 241 #else
Note:
See TracChangeset
for help on using the changeset viewer.