diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2022-01-08 22:59:49 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2022-01-08 22:59:49 +0100 |
commit | ff8fda848284e82d97299806b31c196651b372a5 (patch) | |
tree | 06a35dd78553d004563f9179a7034669f7938a8d | |
parent | 143356876b5712c28b8af61ea9144959a4dc6a5b (diff) | |
download | busybox-w32-ff8fda848284e82d97299806b31c196651b372a5.tar.gz busybox-w32-ff8fda848284e82d97299806b31c196651b372a5.tar.bz2 busybox-w32-ff8fda848284e82d97299806b31c196651b372a5.zip |
ls: implement ls -sh (human-readable allocated blocks)
function old new delta
display_single 979 1018 +39
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/ls.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index 48f5eb482..b69b80460 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -498,9 +498,16 @@ static NOINLINE unsigned display_single(const struct dnode *dn) | |||
498 | 498 | ||
499 | if (opt & OPT_i) /* show inode# */ | 499 | if (opt & OPT_i) /* show inode# */ |
500 | column += printf("%7llu ", (long long) dn->dn_ino); | 500 | column += printf("%7llu ", (long long) dn->dn_ino); |
501 | //TODO: -h should affect -s too: | 501 | if (opt & OPT_s) { /* show allocated blocks */ |
502 | if (opt & OPT_s) /* show allocated blocks */ | 502 | if (opt & OPT_h) { |
503 | column += printf("%6"OFF_FMT"u ", (off_t) (dn->dn_blocks >> 1)); | 503 | column += printf("%"HUMAN_READABLE_MAX_WIDTH_STR"s ", |
504 | /* print size, show one fractional, use suffixes */ | ||
505 | make_human_readable_str((off_t)dn->dn_blocks << 9, 1, 0) | ||
506 | ); | ||
507 | } else { | ||
508 | column += printf("%6"OFF_FMT"u ", (off_t)(dn->dn_blocks >> 1)); | ||
509 | } | ||
510 | } | ||
504 | if (opt & OPT_l) { | 511 | if (opt & OPT_l) { |
505 | /* long listing: show mode */ | 512 | /* long listing: show mode */ |
506 | char modestr[12]; | 513 | char modestr[12]; |