diff options
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/df.c | 23 | ||||
| -rw-r--r-- | coreutils/du.c | 7 | ||||
| -rw-r--r-- | coreutils/ls.c | 4 |
3 files changed, 24 insertions, 10 deletions
diff --git a/coreutils/df.c b/coreutils/df.c index c37b18893..624ad94ba 100644 --- a/coreutils/df.c +++ b/coreutils/df.c | |||
| @@ -92,7 +92,10 @@ int df_main(int argc, char **argv) | |||
| 92 | if (disp_units_hdr == NULL) { | 92 | if (disp_units_hdr == NULL) { |
| 93 | #if ENABLE_FEATURE_HUMAN_READABLE | 93 | #if ENABLE_FEATURE_HUMAN_READABLE |
| 94 | disp_units_hdr = xasprintf("%s-blocks", | 94 | disp_units_hdr = xasprintf("%s-blocks", |
| 95 | make_human_readable_str(df_disp_hr, 0, !!(opt & OPT_POSIX))); | 95 | /* print df_disp_hr, show no fractionals, |
| 96 | * use suffixes if OPT_POSIX is set in opt */ | ||
| 97 | make_human_readable_str(df_disp_hr, 0, !!(opt & OPT_POSIX)) | ||
| 98 | ); | ||
| 96 | #else | 99 | #else |
| 97 | disp_units_hdr = xasprintf("%lu-blocks", df_disp_hr); | 100 | disp_units_hdr = xasprintf("%lu-blocks", df_disp_hr); |
| 98 | #endif | 101 | #endif |
| @@ -189,21 +192,27 @@ int df_main(int argc, char **argv) | |||
| 189 | 192 | ||
| 190 | #if ENABLE_FEATURE_HUMAN_READABLE | 193 | #if ENABLE_FEATURE_HUMAN_READABLE |
| 191 | printf(" %9s ", | 194 | printf(" %9s ", |
| 195 | /* f_blocks x f_bsize / df_disp_hr, show one fractional, | ||
| 196 | * use suffixes if df_disp_hr == 0 */ | ||
| 192 | make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr)); | 197 | make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr)); |
| 193 | 198 | ||
| 194 | printf(" %9s " + 1, | 199 | printf(" %9s " + 1, |
| 200 | /* EXPR x f_bsize / df_disp_hr, show one fractional, | ||
| 201 | * use suffixes if df_disp_hr == 0 */ | ||
| 195 | make_human_readable_str((s.f_blocks - s.f_bfree), | 202 | make_human_readable_str((s.f_blocks - s.f_bfree), |
| 196 | s.f_bsize, df_disp_hr)); | 203 | s.f_bsize, df_disp_hr)); |
| 197 | 204 | ||
| 198 | printf("%9s %3u%% %s\n", | 205 | printf("%9s %3u%% %s\n", |
| 199 | make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr), | 206 | /* f_bavail x f_bsize / df_disp_hr, show one fractional, |
| 200 | blocks_percent_used, mount_point); | 207 | * use suffixes if df_disp_hr == 0 */ |
| 208 | make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr), | ||
| 209 | blocks_percent_used, mount_point); | ||
| 201 | #else | 210 | #else |
| 202 | printf(" %9lu %9lu %9lu %3u%% %s\n", | 211 | printf(" %9lu %9lu %9lu %3u%% %s\n", |
| 203 | kscale(s.f_blocks, s.f_bsize), | 212 | kscale(s.f_blocks, s.f_bsize), |
| 204 | kscale(s.f_blocks - s.f_bfree, s.f_bsize), | 213 | kscale(s.f_blocks - s.f_bfree, s.f_bsize), |
| 205 | kscale(s.f_bavail, s.f_bsize), | 214 | kscale(s.f_bavail, s.f_bsize), |
| 206 | blocks_percent_used, mount_point); | 215 | blocks_percent_used, mount_point); |
| 207 | #endif | 216 | #endif |
| 208 | } | 217 | } |
| 209 | } | 218 | } |
diff --git a/coreutils/du.c b/coreutils/du.c index ec283f85e..730d6d162 100644 --- a/coreutils/du.c +++ b/coreutils/du.c | |||
| @@ -58,14 +58,17 @@ static void print(unsigned long size, const char *filename) | |||
| 58 | { | 58 | { |
| 59 | /* TODO - May not want to defer error checking here. */ | 59 | /* TODO - May not want to defer error checking here. */ |
| 60 | #if ENABLE_FEATURE_HUMAN_READABLE | 60 | #if ENABLE_FEATURE_HUMAN_READABLE |
| 61 | printf("%s\t%s\n", make_human_readable_str(size, 512, G.disp_hr), | 61 | printf("%s\t%s\n", |
| 62 | /* size x 512 / G.disp_hr, show one fractional, | ||
| 63 | * use suffixes if G.disp_hr == 0 */ | ||
| 64 | make_human_readable_str(size, 512, G.disp_hr), | ||
| 62 | filename); | 65 | filename); |
| 63 | #else | 66 | #else |
| 64 | if (G.disp_k) { | 67 | if (G.disp_k) { |
| 65 | size++; | 68 | size++; |
| 66 | size >>= 1; | 69 | size >>= 1; |
| 67 | } | 70 | } |
| 68 | printf("%ld\t%s\n", size, filename); | 71 | printf("%lu\t%s\n", size, filename); |
| 69 | #endif | 72 | #endif |
| 70 | } | 73 | } |
| 71 | 74 | ||
diff --git a/coreutils/ls.c b/coreutils/ls.c index a067aa36c..38cabcab6 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
| @@ -829,7 +829,9 @@ static NOINLINE unsigned list_single(const struct dnode *dn) | |||
| 829 | } else { | 829 | } else { |
| 830 | if (all_fmt & LS_DISP_HR) { | 830 | if (all_fmt & LS_DISP_HR) { |
| 831 | column += printf("%9s ", | 831 | column += printf("%9s ", |
| 832 | make_human_readable_str(dn->dstat.st_size, 1, 0)); | 832 | /* print st_size, show one fractional, use suffixes */ |
| 833 | make_human_readable_str(dn->dstat.st_size, 1, 0) | ||
| 834 | ); | ||
| 833 | } else { | 835 | } else { |
| 834 | column += printf("%9"OFF_FMT"u ", (off_t) dn->dstat.st_size); | 836 | column += printf("%9"OFF_FMT"u ", (off_t) dn->dstat.st_size); |
| 835 | } | 837 | } |
