From 29bd05321aabd720c2ef1e96f09f03eda2f15337 Mon Sep 17 00:00:00 2001 From: risner Date: Mon, 7 Feb 2022 12:22:50 -0500 Subject: [PATCH] Force macOS to use statfs. A macOS bug in libc statvfs(3) call truncates 64 bit elements (e.g. f_blocks) to 32 bits. --- ext/standard/filestat.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index 0d79bba461bea..e537f35829106 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -42,6 +42,16 @@ # include #endif +#if defined(__APPLE__) + /* + Apple statvfs has an interger overflow in libc copying to statvfs. + cvt_statfs_to_statvfs(struct statfs *from, struct statvfs *to) { + to->f_blocks = (fsblkcnt_t)from->f_blocks; + */ +# undef HAVE_SYS_STATVFS_H +# undef HAVE_STATVFS +#endif + #if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS) # include #elif defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)