diff options
author | 2015-10-02 16:29:29 -0400 | |
---|---|---|
committer | 2015-10-02 16:31:15 -0400 | |
commit | 18327a1de06e290d762c1e397ee3fc308059d770 (patch) | |
tree | 481b813c917e330e1ded6e89cbbb8cc35935e0da /Utility | |
parent | a4e008627b3f853d3d4de3d997a392bb489349a1 (diff) |
Ported disk free space checking code to work on Solaris.
On Solaris, using f_bsize provided a value that is apparently much larger
than the real block size. The solaris docs for statvfs say
f_bsize is the "preferred" file system block size, and I guess the
filesystem prefers larger blocks, but uses smaller ones or something.
The docs also say that f_frsize is the "fundamental" block size.
Switched to using f_frsize on Linux and kFreeBSD too, since I guess
f_bsize could in theory vary the same way there too. Assuming that Solaris
is not violating the posix spec, I guess the linux man page for statvfs
is not as well written and I misunderstood it.
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/libdiskfree.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Utility/libdiskfree.c b/Utility/libdiskfree.c index c2f8368f0..12d70e259 100644 --- a/Utility/libdiskfree.c +++ b/Utility/libdiskfree.c @@ -13,23 +13,26 @@ # include <sys/mount.h> # define STATCALL statfs # define STATSTRUCT statfs64 +# define BSIZE f_bsize #else #if defined (__FreeBSD__) # include <sys/param.h> # include <sys/mount.h> # define STATCALL statfs /* statfs64 not yet tested on a real FreeBSD machine */ # define STATSTRUCT statfs +# define BSIZE f_bsize #else #if defined __ANDROID__ # warning free space checking code not available for Android # define UNKNOWN #else -#if defined (__linux__) || defined (__FreeBSD_kernel__) -/* Linux or Debian kFreeBSD */ +#if defined (__linux__) || defined (__FreeBSD_kernel__) || (defined (__SVR4) && defined (__sun)) +/* Linux or Debian kFreeBSD or Solaris */ /* This is a POSIX standard, so might also work elsewhere too. */ # include <sys/statvfs.h> # define STATCALL statvfs # define STATSTRUCT statvfs +# define BSIZE f_frsize #else # warning free space checking code not available for this OS # define UNKNOWN @@ -65,7 +68,7 @@ unsigned long long int get(const char *path, int req) { v = 0; } - blocksize = buf.f_bsize; + blocksize = buf.BSIZE; return v * blocksize; #endif } |