From: Adrian Müller Date: Fri, 23 Jan 2026 11:12:18 +0000 (+0100) Subject: Improve get_free_diskspace to be able to handle huge disks (#9158) X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=6cb5872856e1f57aa648a027d7fc9b53397a0e5b;p=libi2ncommon Improve get_free_diskspace to be able to handle huge disks (#9158) A machine with a 20TB HDD failed the statvfs() call on /datastore due to an overflow in the statvfs call (verified via strace). We now use the 64 bit version "statvfs64" to fix the issue. The returned "long long" of I2n::get_free_diskspace() is already 64 bit, so it can handle sizes up to ~ 8.39 million TiB. --- diff --git a/src/filefunc.cpp b/src/filefunc.cpp index 49358ff..7dca442 100644 --- a/src/filefunc.cpp +++ b/src/filefunc.cpp @@ -994,11 +994,11 @@ bool remove_unlisted_files(const std::string &directory, **/ long long get_free_diskspace(const std::string& path) { - struct statvfs sf; + struct statvfs64 sf; int looplimit=10000; int ret; - while ( ((ret=statvfs(path.c_str(),&sf)) == -1) && (errno==EINTR) && looplimit > 0) + while ( ((ret=statvfs64(path.c_str(),&sf)) == -1) && (errno==EINTR) && looplimit > 0) looplimit--; if (ret==-1)