[git commit] df: -k overrides block size to 1k even if $POSIXLY_CORRECT

Denys Vlasenko vda.linux at googlemail.com
Tue Jul 1 17:26:50 UTC 2025


commit: https://git.busybox.net/busybox/commit/?id=4b1f1da358e0cf18bd7c8265ea1a9121c2801a21
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
df_main                                             1060    1070     +10

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 coreutils/df.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/coreutils/df.c b/coreutils/df.c
index 03aa78148..fba23246f 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -155,6 +155,9 @@ int df_main(int argc UNUSED_PARAM, char **argv)
 			, &opt_t
 			IF_FEATURE_DF_FANCY(, &chp)
 	);
+	/* -k overrides $POSIXLY_CORRECT: */
+	if (opt & OPT_KILO)
+		df_disp_hr = 1024;
 	if (opt & OPT_MEGA)
 		df_disp_hr = 1024*1024;
 
@@ -185,8 +188,8 @@ int df_main(int argc UNUSED_PARAM, char **argv)
 	if (disp_units_hdr == NULL) {
 #if ENABLE_FEATURE_HUMAN_READABLE
 		disp_units_hdr = xasprintf("%s-blocks",
-			/* print df_disp_hr, show no fractionals,
-			 * use suffixes if OPT_POSIX is set in opt */
+			/* print df_disp_hr; show no fractionals;
+			 * if -P, unit=1 (print it in full, no KMG suffixes) */
 			make_human_readable_str(df_disp_hr, 0, !!(opt & OPT_POSIX))
 		);
 #else


More information about the busybox-cvs mailing list