Skip to content

Commit 57ef16b

Browse files
risnercmb69
authored andcommitted
Fix GH-8048: disk_*_space wrong for some filesystems on macOS
A macOS bug in libc statvfs(3) call truncates 64 bit elements (e.g. f_blocks) to 32 bits. Thus, we force macOS to use statfs. Closes GH-8056.
1 parent e6cf583 commit 57ef16b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2022, PHP 8.0.18
44

5+
- Standard:
6+
. Fixed bug GH-8048 (Force macOS to use statfs). (risner)
57

68
17 Mar 2022, PHP 8.0.17
79

ext/standard/filestat.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@
4242
# include <os2.h>
4343
#endif
4444

45+
#if defined(__APPLE__)
46+
/*
47+
Apple statvfs has an interger overflow in libc copying to statvfs.
48+
cvt_statfs_to_statvfs(struct statfs *from, struct statvfs *to) {
49+
to->f_blocks = (fsblkcnt_t)from->f_blocks;
50+
*/
51+
# undef HAVE_SYS_STATVFS_H
52+
# undef HAVE_STATVFS
53+
#endif
54+
4555
#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
4656
# include <sys/statvfs.h>
4757
#elif defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)

0 commit comments

Comments
 (0)