Re: [hatari-devel] Re: GemDOS_DFree

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


Eero Tamminen schrieb:

You could clear the struct before getting its values, to avoid getting
bogus values for untouched members.
[...]
3.97 MiB blocksize seems rather unlikely, especially as that would
indicate that your disk has 45 TB free.  On Linux I got 4 KiB for both.

Even if I clear the struct beforehand, I still get on macOS:

f_blocks = 83758080
f_frsize = 4096
f_bfree = 11661429
f_bavail = 11661429
f_bsize = 4161536

df gives:

Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk3s1s1   320Gi   9.6Gi    44Gi    18%    404k  466M    0%   /

Hence, both the total size and the available size must be calculated by multiplying with "f_frsize" (and ignoring "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".

As they are blocks, using block size seems logical.

Then again, why should total size use a different unit ("f_frsize") than free/available space? Sadly, so far I could only find the NetBSD man page that makes this explicit: "The following are in units of f_frsize":

https://man.netbsd.org/statvfs.5


Any idea where the code for statfs() that fills those values is?

Probably from the kernel, which queries the values from the respective file system. I don't think we have access to the source code of every Apple software.

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/