Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please revert this commit about statvfs #535

Open
aokblast opened this issue Sep 19, 2024 · 3 comments
Open

Please revert this commit about statvfs #535

aokblast opened this issue Sep 19, 2024 · 3 comments

Comments

@aokblast
Copy link

aokblast commented Sep 19, 2024

Hello, this commit indicates that BSD style system use f_bsize instead of f_frsize. But after I test on my FreeBSD and MacOS. It indicates the f_frsize is the correct result.

@aokblast
Copy link
Author

aokblast commented Sep 19, 2024

Ping, @sepherosa @bapt

@aokblast
Copy link
Author

aokblast commented Sep 19, 2024

Experiment:

❯ cat f_bsize.c
#include <sys/statvfs.h>
#include <stdio.h>

int main() {
	struct statvfs buf;
	statvfs("/", &buf);

	printf("%lf\n", (unsigned long long) buf.f_bsize * (unsigned long long)buf.f_bavail / (double)1000.0 / 1000 / 1000);
}

❯ cat f_frsize.c
#include <sys/statvfs.h>
#include <stdio.h>

int main() {
	struct statvfs buf;
	statvfs("/", &buf);

	printf("%lf\n", (unsigned long long) buf.f_frsize * (unsigned long long)buf.f_bavail / (double)1000.0 / 1000 / 1000);
}

MacOS:

❯ cc f_bsize.c -o f_bsize
❯ ./f_bsize
63521.527169
❯ cc f_frsize.c -o f_frsize
❯ ./f_frsize
248.129827
❯ df -H /
Filesystem        Size    Used   Avail Capacity iused ifree %iused  Mounted on
/dev/disk3s1s1    995G     10G    248G     4%    404k  2.4G    0%   /

FreeBSD:

blast@x470-freebsd ~/P/C/d> cc f_bsize.c -o f_bsize
blast@x470-freebsd ~/P/C/d> ./f_bsize
12250.145358
blast@x470-freebsd ~/P/C/d> cc f_frsize.c -o f_frsize
blast@x470-freebsd ~/P/C/d> ./f_frsize
47.852171
blast@x470-freebsd ~/P/C/d> df -H /
Filesystem            Size    Used   Avail Capacity  Mounted on
zroot/ROOT/default    175G    127G     48G    73%    /

OpenBSD:

openbsd-pve$ cc f_bsize.c -o f_bsize
openbsd-pve$ ./f_bsize
6.862389
openbsd-pve$ cc f_frsize.c -o f_frsize
openbsd-pve$ ./f_frsize
0.857799
openbsd-pve$ df -h /
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/sd0a      986M    118M    818M    13%    /

@bapt
Copy link
Contributor

bapt commented Sep 20, 2024

I have no idea about OpenBSD or MacOS, but I confirm for FreeBSD that I had to backout this change. https://cgit.freebsd.org/ports/tree/deskutils/i3status/files/patch-src_print__disk__info.c

@aokblast aokblast changed the title Please revoke this commit about statvfs Please revert this commit about statvfs Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants