[PATCH v2 0/1] MR7769: ntdll: correctly detect the NUL device under macOS
macOS doesn't have a way to detect this via the FIODTYPE ioctl(), so we have to resort to detecting the NUL device via major and minor version number. Fortunately, that hasn't changed since the inception of macOS. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55568 -- v2: ntdll: correctly detect the NUL device under macOS https://gitlab.winehq.org/wine/wine/-/merge_requests/7769
From: John Szakmeister <john(a)szakmeister.net> macOS doesn't have a way to detect this via the FIODTYPE ioctl(), so we have to resort to detecting the NUL device via major and minor device number. Fortunately, that hasn't changed since the inception of macOS. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55568 --- dlls/ntdll/unix/file.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index a475fcc3225..e64c0e51e52 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -6772,6 +6772,14 @@ NTSTATUS get_device_info( int fd, FILE_FS_DEVICE_INFORMATION *info ) break; } #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) +#if defined(__APPLE__) + /* /dev/null on has been 3, 2 since the start of OSX */ + if (major(st.st_rdev) == 3 && minor(st.st_rdev) == 2) + { + info->DeviceType = FILE_DEVICE_NULL; + } + else +#endif { int d_type; if (ioctl(fd, FIODTYPE, &d_type) == 0) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7769
This seems reasonable to me, but I think it would be cleaner to put it after the `switch` block, like: ``` switch (d_type) { ... } /* no special d_type for parallel ports */ #if defined(__APPLE__) /* /dev/null on has been 3, 2 since the start of OSX */ if (d_type == D_DISK && major(st.st_rdev) == 3 && minor(st.st_rdev) == 2) info->DeviceType = FILE_DEVICE_NULL; #endif ``` -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7769#note_100564
On Thu Apr 10 20:45:53 2025 +0000, Brendan Shanks wrote:
This seems reasonable to me, but I think it would be cleaner to put it after the `switch` block, like: ``` switch (d_type) { ... } /* no special d_type for parallel ports */ #if defined(__APPLE__) /* /dev/null on has been 3, 2 since the start of OSX */ if (d_type == D_DISK && major(st.st_rdev) == 3 && minor(st.st_rdev) == 2) info->DeviceType = FILE_DEVICE_NULL; #endif ``` I'll give it a go tomorrow and see what it looks like. I had it where it was to avoid the unnecessary call to ioctl() as we can fully make the decision about the type right then and there. But you have much more experience with Wine and what's more in line with what's preferred by the project, so I'm happy to defer to that experience. :-)
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/7769#note_100582
participants (3)
-
Brendan Shanks (@bshanks) -
John Szakmeister -
John Szakmeister (@jszakmeister)