--- Begin Message ---
Subject: |
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
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#11406: Bug? df uses f_bsize instead of f_frsize to calculate file system sizes |
Date: |
Wed, 16 May 2012 00:50:52 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 |
On 05/15/2012 11:45 PM, Nikolaus Rath wrote:
> Yes, that works nicely.
>
> # src/stat -f ~/tmp/mnt
> File: "/home/nikratio/tmp/mnt"
> ID: 0 Namelen: 0 Type: fuseblk
> Block size: 8192 Fundamental block size: 4096
> Blocks: Total: 268435456 Free: 268435456 Available: 268435456
> Inodes: Total: 1000000 Free: 999997
>
> # /usr/bin/stat -f ~/tmp/mnt
> File: "/home/nikratio/tmp/mnt"
> ID: 0 Namelen: 0 Type: fuseblk
> Block size: 8192 Fundamental block size: 8192
> Blocks: Total: 268435456 Free: 268435456 Available: 268435456
> Inodes: Total: 1000000 Free: 999997
Pushed.
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commit;h=c25bdb
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commit;h=b1fac3
http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commit;h=0863f01
thanks again,
Pádraig.
--- End Message ---