(svn r2101) statvfs() is availible on POSIX.1 conformant systems.
authortron
Mon, 28 Mar 2005 15:40:05 +0000
changeset 1597 cc09dbccddac
parent 1596 c1c439a2d5b2
child 1598 4425f756c19b
(svn r2101) statvfs() is availible on POSIX.1 conformant systems.
Also use a different field, which has a better chance of containing meaningful information, of the returned struct to determine the free space on the filesystem and fix a small bug introduced in r2100 (s/!=/==/)
unix.c
--- a/unix.c	Mon Mar 28 13:30:51 2005 +0000
+++ b/unix.c	Mon Mar 28 15:40:05 2005 +0000
@@ -12,7 +12,11 @@
 #include <pwd.h>
 #include <signal.h>
 
-#if defined(__linux__)
+#if (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) || defined(__linux__)
+	#define HAS_STATVFS
+#endif
+
+#ifdef HAS_STATVFS
 #include <sys/statvfs.h>
 #endif
 
@@ -312,12 +316,12 @@
 	uint32 free = 0;
 	*path = _fios_path[0] != '\0' ? _fios_path : "/";
 
-#if defined(__linux__)
+#ifdef HAS_STATVFS
 	{
 		struct statvfs s;
 
-		if (statvfs(*path, &s) != 0) {
-			free = ((uint64)s.f_bsize * s.f_bavail) >> 20;
+		if (statvfs(*path, &s) == 0) {
+			free = (uint64)s.f_frsize * s.f_bavail >> 20;
 		} else
 			return STR_4006_UNABLE_TO_READ_DRIVE;
 	}