diff options
author | tron <tron@openttd.org> | 2005-03-28 15:40:05 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-03-28 15:40:05 +0000 |
commit | 72dbefdebd551ae05b317f9b138e2a762fa5e2c5 (patch) | |
tree | 6c8f8ec541fb352845f1762a90367f8ed662f552 | |
parent | d643ca62717ed5636dcebfe9ba14e770891c8379 (diff) | |
download | openttd-72dbefdebd551ae05b317f9b138e2a762fa5e2c5.tar.xz |
(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/!=/==/)
-rw-r--r-- | unix.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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 @@ StringID FiosGetDescText(const char **path, uint32 *tot) 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; } |