summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2012-05-15 19:56:21 +0100
committerPádraig Brady <P@draigBrady.com>2012-05-16 00:21:25 +0100
commit0863f018f0fe970ffdb9cc2267a50c018d3944c5 (patch)
treea0441c7576c217600993f0660e6b5af4bb2a28ca /src
parent6124a3842dfa8484b52e067a8ab8105c3875a4f7 (diff)
downloadcoreutils-0863f018f0fe970ffdb9cc2267a50c018d3944c5.tar.xz
stat: report the correct block size for file system usage
struct statfs has the f_frsize member since Linux 2.6, so use that rather than f_bsize which can be different. Note the related df change mentioned in NEWS is handled in gnulib by using statvfs() rather than statfs() on Linux > 2.6.36 (where statvfs doesn't hang) and the same method as stat for Linux 2.6 kernels earlier than that. stat(1) doesn't use statvfs() on GNU/Linux as the f_type member isn't available there. Note the change to not use statvfs() on GNU/Linux was introduced in gnulib commit eda39b8 16-08-2003. * m4/stat-prog.m4 (cu_PREREQ_STAT_PROG): Check for the f_frsize member in the statfs structure. * src/stat.c: Use (struct statfs).f_frsize if available. * NEWS (Bug fixes): Mention this stat fix, and the related df fix coming in the next gnulib update. * THANKS.in: Add Nikolaus. Reported and Tested by Nikolaus Rath
Diffstat (limited to 'src')
-rw-r--r--src/stat.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/stat.c b/src/stat.c
index c6747a6b5..d80c62448 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -126,7 +126,11 @@ statfs (char const *filename, struct fs_info *buf)
# else
# define STRUCT_STATVFS struct statfs
# define STRUCT_STATXFS_F_FSID_IS_INTEGER STRUCT_STATFS_F_FSID_IS_INTEGER
-# define STATFS_FRSIZE(S) 0
+# if HAVE_STRUCT_STATFS_F_FRSIZE
+# define STATFS_FRSIZE(S) ((S)->f_frsize)
+# else
+# define STATFS_FRSIZE(S) 0
+# endif
# endif
#endif