aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox/0011-df-use-f_frsize-instead-of-f_bsize-for-correct-sizes.patch
blob: 519613a2d8222c72b911700318b1055d1b373fa1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
From 55df9f8c24c2ed9c03d5761b45f0916d4bcfc88b Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 23 Jun 2016 10:42:40 +0200
Subject: [PATCH 11/15] df: use f_frsize instead of f_bsize for correct sizes

Use the correct field f_frsize instead of f_bsize.

The statfs f_bsize is the "Optimal transfer block size" while the
f_frsize is the "Fragment size (since Linux 2.6)". On some FUSE
filesystems those may differ.

Fixes bug 9046

URL: https://bugs.busybox.net/show_bug.cgi?id=9046

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
 coreutils/df.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/coreutils/df.c b/coreutils/df.c
index d79c11a..06b2920 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -188,7 +188,7 @@ int df_main(int argc UNUSED_PARAM, char **argv)
 			if (opt & OPT_INODE) {
 				s.f_blocks = s.f_files;
 				s.f_bavail = s.f_bfree = s.f_ffree;
-				s.f_bsize = 1;
+				s.f_frsize = 1;
 
 				if (df_disp_hr)
 					df_disp_hr = 1;
@@ -246,26 +246,26 @@ int df_main(int argc UNUSED_PARAM, char **argv)
 
 #if ENABLE_FEATURE_HUMAN_READABLE
 			printf(" %9s ",
-				/* f_blocks x f_bsize / df_disp_hr, show one fractional,
+				/* f_blocks x f_frsize / df_disp_hr, show one fractional,
 				 * use suffixes if df_disp_hr == 0 */
-				make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
+				make_human_readable_str(s.f_blocks, s.f_frsize, df_disp_hr));
 
 			printf(" %9s " + 1,
-				/* EXPR x f_bsize / df_disp_hr, show one fractional,
+				/* EXPR x f_frsize / df_disp_hr, show one fractional,
 				 * use suffixes if df_disp_hr == 0 */
 				make_human_readable_str((s.f_blocks - s.f_bfree),
-						s.f_bsize, df_disp_hr));
+						s.f_frsize, df_disp_hr));
 
 			printf("%9s %3u%% %s\n",
-				/* f_bavail x f_bsize / df_disp_hr, show one fractional,
+				/* f_bavail x f_frsize / df_disp_hr, show one fractional,
 				 * use suffixes if df_disp_hr == 0 */
-				make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
+				make_human_readable_str(s.f_bavail, s.f_frsize, df_disp_hr),
 				blocks_percent_used, mount_point);
 #else
 			printf(" %9lu %9lu %9lu %3u%% %s\n",
-				kscale(s.f_blocks, s.f_bsize),
-				kscale(s.f_blocks - s.f_bfree, s.f_bsize),
-				kscale(s.f_bavail, s.f_bsize),
+				kscale(s.f_blocks, s.f_frsize),
+				kscale(s.f_blocks - s.f_bfree, s.f_frsize),
+				kscale(s.f_bavail, s.f_frsize),
 				blocks_percent_used, mount_point);
 #endif
 		}
-- 
2.9.1