summaryrefslogtreecommitdiff
path: root/lib/util/fsusage.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-10-14 02:16:27 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-10-14 02:16:27 +0200
commitfd443f819e77ee811cbcd0eaea4073f5e7a8f145 (patch)
tree873eaf0578510192a98d4ce9ea2fb004cdf527e9 /lib/util/fsusage.c
parent4746f79d50d804b0e9d5d5cc0d4796dee54d052c (diff)
downloadsamba-fd443f819e77ee811cbcd0eaea4073f5e7a8f145.tar.gz
samba-fd443f819e77ee811cbcd0eaea4073f5e7a8f145.tar.bz2
samba-fd443f819e77ee811cbcd0eaea4073f5e7a8f145.zip
Use common fusage implementation.
Diffstat (limited to 'lib/util/fsusage.c')
-rw-r--r--lib/util/fsusage.c13
1 files changed, 9 insertions, 4 deletions
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);
+ }
}
/**