From: Kern Sibbald Date: Sun, 12 Nov 2017 09:15:59 +0000 (+0100) Subject: Correct FS size calculation for FreeBSD, Solaris, and Windows X-Git-Tag: Release-9.0.6~53 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8cbc60e9fb6afedb28e7e02fa7d862a8a0b111b7;p=bacula%2Fbacula Correct FS size calculation for FreeBSD, Solaris, and Windows --- diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index 21a8f69db4..916357493b 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -1029,15 +1029,23 @@ void stack_trace() {} int fs_get_free_space(const char *path, int64_t *freeval, int64_t *totalval) { -#if !defined(HAVE_WIN32) && !defined(HAVE_SUN_OS) + +/* For Windows must have statvfs */ +#if defined(HAVE_WIN32) + #if !defined(HAVE_SYS_STATVFS_H) + *totalval = *freeval = 0; + return -1; + #endif +#endif + struct statvfs st; if (statvfs(path, &st) == 0) { - *freeval = (uint64_t)st.f_bsize * (uint64_t)st.f_bavail; + *freeval = (uint64_t)st.f_bavail * (uint64_t)st.f_frsize; *totalval = (uint64_t)st.f_blocks * (uint64_t)st.f_frsize; return 0; } -#endif + *totalval = *freeval = 0; return -1; }