From fd443f819e77ee811cbcd0eaea4073f5e7a8f145 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 14 Oct 2008 02:16:27 +0200 Subject: Use common fusage implementation. --- lib/util/fsusage.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/util') diff --git a/lib/util/fsusage.c b/lib/util/fsusage.c index 30f9f9c795..e5f2678a9f 100644 --- a/lib/util/fsusage.c +++ b/lib/util/fsusage.c @@ -19,7 +19,7 @@ #include "includes.h" #include "system/filesys.h" - + /** * @file * @brief Utility functions for getting the amount of free disk space @@ -30,12 +30,17 @@ */ static uint64_t adjust_blocks(uint64_t blocks, uint64_t fromsize, uint64_t tosize) { - if (fromsize == tosize) /* e.g., from 512 to 512 */ + if (fromsize == tosize) { /* e.g., from 512 to 512 */ return blocks; - else if (fromsize > tosize) /* e.g., from 2048 to 512 */ + } else if (fromsize > tosize) { /* e.g., from 2048 to 512 */ return blocks * (fromsize / tosize); - else /* e.g., from 256 to 512 */ + } else { /* e.g., from 256 to 512 */ + /* Protect against broken filesystems... */ + if (fromsize == 0) { + fromsize = tosize; + } return (blocks + 1) / (tosize / fromsize); + } } /** -- cgit