From c56b733391a18435a14e663dae04feb8dec6e30e Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Tue, 5 Jul 2016 10:11:49 +0930 Subject: [PATCH] Fix free space measurement for OSX --- rhizome_store.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rhizome_store.c b/rhizome_store.c index 52092c04..0542af45 100644 --- a/rhizome_store.c +++ b/rhizome_store.c @@ -172,7 +172,17 @@ static uint64_t store_get_free_space() WARNF_perror("statvfs(%s)", store_path); return UINT64_MAX; } - return stats.f_bsize * stats.f_bfree; + uint64_t space = stats.f_frsize * stats.f_bavail; + if (IF_DEBUG(rhizome)){ + double pretty = space; + const char *suffix = " KMGT"; + while(pretty >= 1024 && suffix[1]){ + pretty = pretty / 1024; + suffix++; + } + DEBUGF(rhizome, "Found %.2f%cB of free space", pretty, *suffix); + } + return space; #else return UINT64_MAX; #endif