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.
This commit is contained in:
Joey Hess 2015-10-02 16:29:29 -04:00
parent cdbce512bd
commit 06f1f03e7a
2 changed files with 7 additions and 3 deletions

View file

@ -13,23 +13,26 @@
# include <sys/mount.h> # include <sys/mount.h>
# define STATCALL statfs # define STATCALL statfs
# define STATSTRUCT statfs64 # define STATSTRUCT statfs64
# define BSIZE f_bsize
#else #else
#if defined (__FreeBSD__) #if defined (__FreeBSD__)
# include <sys/param.h> # include <sys/param.h>
# include <sys/mount.h> # include <sys/mount.h>
# define STATCALL statfs /* statfs64 not yet tested on a real FreeBSD machine */ # define STATCALL statfs /* statfs64 not yet tested on a real FreeBSD machine */
# define STATSTRUCT statfs # define STATSTRUCT statfs
# define BSIZE f_bsize
#else #else
#if defined __ANDROID__ #if defined __ANDROID__
# warning free space checking code not available for Android # warning free space checking code not available for Android
# define UNKNOWN # define UNKNOWN
#else #else
#if defined (__linux__) || defined (__FreeBSD_kernel__) #if defined (__linux__) || defined (__FreeBSD_kernel__) || (defined (__SVR4) && defined (__sun))
/* Linux or Debian kFreeBSD */ /* Linux or Debian kFreeBSD or Solaris */
/* This is a POSIX standard, so might also work elsewhere too. */ /* This is a POSIX standard, so might also work elsewhere too. */
# include <sys/statvfs.h> # include <sys/statvfs.h>
# define STATCALL statvfs # define STATCALL statvfs
# define STATSTRUCT statvfs # define STATSTRUCT statvfs
# define BSIZE f_frsize
#else #else
# warning free space checking code not available for this OS # warning free space checking code not available for this OS
# define UNKNOWN # define UNKNOWN
@ -65,7 +68,7 @@ unsigned long long int get(const char *path, int req) {
v = 0; v = 0;
} }
blocksize = buf.f_bsize; blocksize = buf.BSIZE;
return v * blocksize; return v * blocksize;
#endif #endif
} }

1
debian/changelog vendored
View file

@ -10,6 +10,7 @@ git-annex (5.20150931) UNRELEASED; urgency=medium
* reinject: Already verified content; this can now be disabled by * reinject: Already verified content; this can now be disabled by
setting annex.verify=false. setting annex.verify=false.
* Allow building with S3 disabled again. * Allow building with S3 disabled again.
* Ported disk free space checking code to work on Solaris.
-- Joey Hess <id@joeyh.name> Thu, 01 Oct 2015 12:42:56 -0400 -- Joey Hess <id@joeyh.name> Thu, 01 Oct 2015 12:42:56 -0400