[PATCH 0/2] MR10625: mountmgr.sys, ntdll: Fall back to statfs if "important" free space is 0 on macOS.
CFURLCopyResourcePropertyForKey(kCFURLVolumeAvailableCapacityForImportantUsageKey) fails silently and returns 0 free bytes if the volume is not APFS. --- If the volume actually does have no free space, statfs will concur, and we should fall back to it. Thanks to Dean Greer for spotting this. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10625
From: Tim Clem <tclem@codeweavers.com> The CFURLCopyResourcePropertyForKey fails silently and returns 0 free bytes if the volume is not APFS. --- dlls/mountmgr.sys/unixlib.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dlls/mountmgr.sys/unixlib.c b/dlls/mountmgr.sys/unixlib.c index 2a5fd272db6..575a26e9a1c 100644 --- a/dlls/mountmgr.sys/unixlib.c +++ b/dlls/mountmgr.sys/unixlib.c @@ -328,6 +328,13 @@ static LONGLONG get_free_bytes_for_important_data(int fd) if (!(url = CFURLCreateFromFileSystemRepresentation( NULL, (UInt8 *)path, strlen( path ), false ))) goto done; if (!CFURLCopyResourcePropertyForKey( url, kCFURLVolumeAvailableCapacityForImportantUsageKey, &num, NULL )) goto done; CFNumberGetValue( num, kCFNumberLongLongType, &space ); + if (space == 0) + { + /* It's unlikely that a writeable disk has exactly 0 free bytes. This + * probably means the disk is read-only, or is not APFS. Fall back to + * statfs. */ + space = -1; + } done: free( path ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10625
From: Tim Clem <tclem@codeweavers.com> The CFURLCopyResourcePropertyForKey fails silently and returns 0 free bytes if the volume is not APFS. --- dlls/ntdll/unix/file.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index d413bbbc0ab..a215f72a55d 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -2190,6 +2190,13 @@ static LONGLONG get_free_bytes_for_important_data(int fd) if (!(url = CFURLCreateFromFileSystemRepresentation( NULL, (UInt8 *)path, strlen(path), false ))) goto done; if (!CFURLCopyResourcePropertyForKey( url, kCFURLVolumeAvailableCapacityForImportantUsageKey, &num, NULL )) goto done; CFNumberGetValue( num, kCFNumberLongLongType, &space ); + if (space == 0) + { + /* It's unlikely that a writeable disk has exactly 0 free bytes. This + * probably means the disk is read-only, or is not APFS. Fall back to + * statfs. */ + space = -1; + } done: free( path ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10625
This merge request was approved by Brendan Shanks. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10625
participants (3)
-
Brendan Shanks (@bshanks) -
Tim Clem -
Tim Clem (@tclem)