]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
cope with a broken st_blocks stat result
authorAndrew Tridgell <tridge@samba.org>
Mon, 1 Apr 2002 09:31:01 +0000 (11:31 +0200)
committerAndrew Tridgell <tridge@samba.org>
Mon, 1 Apr 2002 09:31:01 +0000 (11:31 +0200)
util.c

diff --git a/util.c b/util.c
index a2131e1d64f0109d008334d2f6fbfe28fac36c1b..c50f726610b8a9968df3babf88c9064abe6f58e0 100644 (file)
--- a/util.c
+++ b/util.c
@@ -248,7 +248,12 @@ int lock_fd(int fd)
 /* return size on disk of a file */
 size_t file_size(struct stat *st)
 {
-       return st->st_blocks * 512;
+       size_t size = st->st_blocks * 512;
+       if (st->st_size > size) {
+               /* probably a broken stat() call ... */
+               size = (st->st_size + 1023) & ~1023;
+       }
+       return size;
 }