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.
From: John Szakmeister john@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 version 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)
I thought about possibly writing a test for macOS that would fail if the major/minor device number of `/dev/null` ever changed. Didn't know if the project would want something like that, and where to put it if it does. :-)