bug-coreutils
[Top][All Lists]
Advanced

[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: Nikolaus Rath
Subject: bug#11406: Bug? df uses f_bsize instead of f_frsize to calculate file system sizes
Date: Fri, 04 May 2012 10:39:44 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.3) Gecko/20120329 Icedove/10.0.3

Hello,

>From statvfs(3):

           struct statvfs {
               unsigned long  f_bsize;    /* file system block size */
               unsigned long  f_frsize;   /* fragment size */
               fsblkcnt_t     f_blocks;   /* size of fs in f_frsize units */
               fsblkcnt_t     f_bfree;    /* # free blocks */
               fsblkcnt_t     f_bavail;   /* # free blocks for unprivileged 
users */
               ....
           }

So the size of a file system is f_blocks * f_frsize. For the
file system mounted at mnt, the values are

# python
>>> import os
>>> os.statvfs('mnt')
posix.statvfs_result(f_bsize=4, f_frsize=10485760, f_blocks=104857, 
f_bfree=104856, f_bavail=104856, f_files=1000000, f_ffree=999996, 
f_favail=999996, f_flag=4102, f_namemax=0)

So the file system size is 10485760 * 104857 = 1 TB. df, however, reports:

# df mnt
Filesystem                        1K-blocks  Used Available Use% Mounted on
local:///home/nikratio/tmp/bucket       410     1       410   1% 
/home/nikratio/tmp/mnt

# df --version
df (GNU coreutils) 8.13
[...]

This has apparently been calculated using f_bsize, since
f_bsize * f_blocks = 409k.


The same problem applies to f_bfree and f_bavail. I believe that in all cases, 
df should
use f_frsize rather than f_bsize to calculate the size in bytes.

Am I missing something?

Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C





reply via email to

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