From 8cbc60e9fb6afedb28e7e02fa7d862a8a0b111b7 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 12 Nov 2017 10:15:59 +0100 Subject: [PATCH] Correct FS size calculation for FreeBSD, Solaris, and Windows --- bacula/src/lib/bsys.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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; } -- 2.39.5