[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11406: Bug? df uses f_bsize instead of f_frsize to calculate file sy

From: Pádraig Brady
Subject: bug#11406: Bug? df uses f_bsize instead of f_frsize to calculate file system sizes
Date: Tue, 15 May 2012 11:10:05 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

On 05/14/2012 09:34 AM, Pádraig Brady wrote:
> On 05/12/2012 05:05 AM, Paul Eggert wrote:
>> On 05/11/2012 06:56 PM, Nikolaus Rath wrote:
>>> Yes, this works:
>> OK, thanks, I pushed that patch into gnulib, where
>> coreutils should eventually pick it up.
>>> I just noticed that the "stat" command is affected by this as well:
>> Ouch.  Perhaps Padraig can look at that one -- this
>> statvfs stuff is a bit of a rat's nest, alas.
>> One thought is that perhaps we should create a gnulib
>> module statvfs that works around the GNU/Linux bug?  Then other code
>> could simply call statvfs without worrying about this stuff.
> I'll have a look at this sometime this evening.

Yes this is messy. Note even though STAT_STATVFS is now true
since Paul's gnulib change, stat(1) wants access to the f_type member
which is not available in the statvfs structure.
However frsize is available in the statfs structure since kernel 2.6,
so we can use that where available.

Nikolaus, could you try the stat command again with the following?

If it works I'll submit to coreutils, with a NEWS update
also mentioning Paul's gnulib fix.


diff --git a/m4/stat-prog.m4 b/m4/stat-prog.m4
index 30bacb4..ff59a28 100644
--- a/m4/stat-prog.m4
+++ b/m4/stat-prog.m4
@@ -72,8 +72,8 @@ AC_INCLUDES_DEFAULT
          [Define to 1 if the f_fsid member of struct statvfs is an integer.])])
-    AC_CHECK_MEMBERS([struct statfs.f_namelen, struct statfs.f_type],,,
-      [$statfs_includes])
+    AC_CHECK_MEMBERS([struct statfs.f_namelen, struct statfs.f_type,
+                     struct statfs.f_frsize],,, [$statfs_includes])
     if test $ac_cv_header_OS_h != yes; then
diff --git a/src/stat.c b/src/stat.c
index c6747a6..d80c624 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 STATFS_FRSIZE(S) 0
+#   define STATFS_FRSIZE(S) ((S)->f_frsize)
+#  else
+#   define STATFS_FRSIZE(S) 0
+#  endif
 # endif

reply via email to

[Prev in Thread] Current Thread [Next in Thread]