Re: [hatari-devel] GemDOS_DFree

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Christian Zietz schrieb:

Then, the total file
system size is specified by POSIX to be "f_blocks*f_frsize". But it is
not clearly specified, whether the free blocks are given in units of
"f_frsize" or "f_bsize". Hatari uses different units for total and free
space: "Total = buf.f_blocks/1024 * buf.f_frsize" and "Free = Free/1024
* buf.f_bsize". But with the values above, this calculation gives more
free space than total space on macOS!

On FreeBSD, a BSD Unix like macOS, you can see that *both* the total size and the available size need to be calculated using "f_frsize" as unit of measurement to match "df" output:

1265411 * 4096 / 1024 = 5061644
299133 * 4096 / 1024 = 1196532

Thus, I would argue that Hatari is wrong using "f_bsize" to calculate available space, but correct using "f_frsize" to calculate total space.


root@freebsd:~ # uname -a
FreeBSD freebsd 14.3-RELEASE FreeBSD 14.3-RELEASE releng/14.3-n271432-8c9ce319fef7 GENERIC arm64

root@freebsd:~ # df
Filesystem      1K-blocks    Used   Avail Capacity  Mounted on
/dev/gpt/rootfs   5061644 3460184 1196532    74%    /
devfs                   1       0       1     0%    /dev
/dev/gpt/efiesp     32764     835   31928     3%    /boot/efi

root@freebsd:~ # /tmp/statvfs
sizeof(struct statvfs) = 88
sizeof(f_bfree) = 8
sizeof(f_bavail) = 8
statfs() = 0
f_blocks = 1265411
f_frsize = 4096
f_bfree = 400365
f_bavail = 299133
f_bsize = 32768


Regards
Christian
--
Christian Zietz  -  CHZ-Soft  -  czietz@xxxxxxx
WWW: https://www.chzsoft.de/
New GnuPG-Key-ID: 0x8708B34C827B159E



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/