aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-12-12 19:56:31 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2016-12-12 19:56:31 +0100
commite184a883567ee3fd735644416e4bd683f1894ac5 (patch)
tree7eae83fb609ecc41c44803e5969db5b1bb726f10 /coreutils
parent76de3257f7133a760c3d8908a99b850ea2d0f0b0 (diff)
downloadbusybox-e184a883567ee3fd735644416e4bd683f1894ac5.tar.gz
df: implement -B n<suff> and -B <suff> formats of -B option
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/df.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/coreutils/df.c b/coreutils/df.c
index fdcdae675..79e4c4670 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -129,8 +129,19 @@ int df_main(int argc UNUSED_PARAM, char **argv)
if (opt & OPT_MEGA)
df_disp_hr = 1024*1024;
- if (opt & OPT_BSIZE)
- df_disp_hr = xatoul_range(chp, 1, ULONG_MAX); /* disallow 0 */
+ if (opt & OPT_BSIZE) {
+ /* GNU coreutils 8.25 accepts "-BMiB" form too */
+ int i;
+ for (i = 0; kmg_i_suffixes[i].suffix[0]; i++) {
+ if (strcmp(kmg_i_suffixes[i].suffix, chp) == 0) {
+ df_disp_hr = kmg_i_suffixes[i].mult;
+ goto got_it;
+ }
+ }
+ /* Range used to disallow 0 */
+ df_disp_hr = xatoul_range_sfx(chp, 1, ULONG_MAX, kmg_i_suffixes);
+ got_it: ;
+ }
/* From the manpage of df from coreutils-6.10:
* Disk space is shown in 1K blocks by default, unless the environment
@@ -203,6 +214,11 @@ int df_main(int argc UNUSED_PARAM, char **argv)
bb_simple_perror_msg(mount_point);
goto set_error;
}
+ /* Some uclibc versions were seen to lose f_frsize
+ * (kernel does return it, but then uclibc does not copy it)
+ */
+ if (s.f_frsize == 0)
+ s.f_frsize = s.f_bsize;
if ((s.f_blocks > 0) || !mount_table || (opt & OPT_ALL)) {
if (opt & OPT_INODE) {