From 1f954b12d5d6fba4e5d183980b18bdf4032aa905 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sun, 17 May 2015 20:49:41 +0200 Subject: cherry picked statfs fix --- pgfuse.c | 6 +++--- tests/testtypes.c | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pgfuse.c b/pgfuse.c index cbe937b..770dcf3 100644 --- a/pgfuse.c +++ b/pgfuse.c @@ -1096,7 +1096,7 @@ static int pgfuse_statfs( const char *path, struct statvfs *buf ) /* no restriction on the number of files storable, we could add some limits later */ - files_free = INT64_MAX; + files_total = INT64_MAX; files_used = psql_get_fs_files_used( conn ); if( files_used < 0 ) { @@ -1104,12 +1104,12 @@ static int pgfuse_statfs( const char *path, struct statvfs *buf ) return files_used; } - files_total = files_free + files_used; + files_free = files_total - files_used; files_avail = files_free; if( data->verbose ) { syslog( LOG_DEBUG, "Stats for '%s' are (%jd blocks total, %jd used, %jd free, " - "%jd files total, %jd files used, %jd files free, thread #%u", + "%"PRId64" inodes total, %"PRId64" inodes used, %"PRId64" inodes free, thread #%u", data->mountpoint, blocks_total, blocks_used, blocks_free, files_total, files_used, files_free, diff --git a/tests/testtypes.c b/tests/testtypes.c index 4ed880b..b3ad376 100644 --- a/tests/testtypes.c +++ b/tests/testtypes.c @@ -15,15 +15,21 @@ int main(void) { uint32_t uint32=0xffffFFFF; uint64_t uint64=0xFFFFFFFFFFFFFFFFLL; + int32_t int32=0x7fffffff; + int64_t int64=0x7fffFFFFffffFFFFLL; off_t offset=TYPE_MAX(off_t); /* Depends on _FILE_OFFSET_BITS */ size_t size=TYPE_MAX(size_t); /* Depends on int size */ printf("uint32_t max %20"PRIu32" %16"PRIx32"\n" "uint64_t max %20"PRIu64" %16"PRIx64"\n" + "int32_t max %20"PRId32" %16"PRIx32"\n" + "int64_t max %20"PRId64" %16"PRIx64"\n" "off_t max %20jd %16jx\n" /* try PRIdMAX if %jd unsupported */ "size_t max %20zu %16zx\n", uint32, uint32, uint64, uint64, + int32, int32, + int64, int64, (intmax_t)offset, (intmax_t)offset, size, size); -- cgit v1.2.3-54-g00ecf