Add get_fs_size() support for BSDs
Add get_fs_size() for FreeBSD/DragonFlyBSD. The same code may
work on NetBSD/OpenBSD as it uses POSIX statvfs(2).
The following results verify df(1) (which also typically uses
statfs(2) or statvfs(2)) shows the same number given that df(1)
output is correct for the given filesystems.
--
# uname
FreeBSD
# cat ./test2.c
#include <stdio.h>
#include "os/os-freebsd.h"
int main(int argc, char *argv[]) {
printf("%s %llu\n", argv[1], get_fs_size(argv[1]));
return 0;
}
# clang -Wall -g ./test2.c -o test2
# ./test2 /
/
102783143936
# df -TH /
Filesystem Type Size Used Avail Capacity Mounted on
/dev/ada0p2 ufs 112G 9.5G 94G 9% /
^^^^^^^^^^^^ ^^^
112G - 9.5G bfree!=bavail
= 102.5G like it differs on ext[234]
--
# uname
DragonFly
# cat ./test2.c
#include <stdio.h>
#include "os/os-dragonfly.h"
int main(int argc, char *argv[]) {
printf("%s %llu\n", argv[1], get_fs_size(argv[1]));
return 0;
}
# gcc -Wall -g ./test2.c -o test2
# ./test2 /
/
450287370240
# df -TH /
Filesystem Type Size Used Avail Capacity Mounted on
ROOT hammer 480G 30G 450G 6% /