On Wed, 16 Jun 2010, Jim Meyering wrote: > Miklos Szeredi wrote: > > On Wed, 16 Jun 2010, Jim Meyering wrote: > >> Miklos Szeredi wrote: > >> > On Thu, 03 Jun 2010, Miklos Szeredi wrote: > >> >> Hmm, actually "struct statfs" on linux does have f_frsize, only the > >> >> manpage doesn't document it. So correct thing would be to use that, > >> >> no? > >> > > >> > Here's a patch that allows df(1) to correctly calculate the disk usage > >> > and displays f_frsize in stat(1). > >> > >> Hi Miklos, > >> > >> [Cc'ing bug-gnulib, since all but src/stat.c are from gnulib] > >> > >> Thank you for the patch. > >> However, I'm not sure it's portable enough. > >> Do you know when the f_frsize member began to be useful? > > > > It was introduced in the linux-2.5 timeframe, so from linux-2.6.0 on > > it contains useful information. In 2.4.* and earlier it was part of > > the f_spare array and was zeroed out by the kernel. > > > > Checking f_spare value for zero and using f_bsize instead works fine > > for 2.4 and earlier kernels. > > That sounds sufficient. > Can you confirm that this works on a 2.4.x kernel?
Okay, after some unsuccessful attempts to run a current system with a 2.4 kernel (userspace bootup immediately fails with "FATAL: kernel too old" message) I turned to a virtualized environment. I compiled the patched coreutils under debian/sarge (linux-2.4.27, glibc-2.3.6). This glibc already has f_frsize and configure detects it. I then verified that df(1) and stat(1) work correctly on this system. Then took the binaries to a 2.6 kernel and glibc-2.10.1 and verified that they indeed take a differing f_frsize and f_bsize into account. Thanks, Miklos