[php-src] Issue #8048: disk_*_space uses statvfs on macOS and it returns inaccruate results for some filesystems
| From: | risner | Date: | Mon, 07 Feb 2022 13:05:17 +0000 |
| Subject: | [php-src] Issue #8048: disk_*_space uses statvfs on macOS and it returns inaccruate results for some filesystems | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-239534@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8048
Comment Author: risner
Looking at macOS's Libc-1353.11.2, it does a conversion from statfs to statvfs in libc.
It is an integer overflow issue.
size x64 = 8; size x32 = 4
x64 = 60518056220; x32 = 388514076
For reliable results, on macOS the source should be statfs(2) instead of statvfs(3). I suspect this
is a good practice to do whenever statfs is also available. Linux my be the exception, I found a
number of statements regarding Linux doing statvfs correctly while researching this issue.
Code snip of the function:
/* Internal common conversion function */
static void
cvt_statfs_to_statvfs(struct statfs *from, struct statvfs *to)
{
to->f_bsize = from->f_iosize;
to->f_frsize = from->f_bsize;
to->f_blocks = (fsblkcnt_t)from->f_blocks;
to->f_bfree = (fsblkcnt_t)from->f_bfree;