From 04fd6cdcc6fc1f07938f7e2fa1a0d313a15617be Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 13 Aug 2021 13:44:13 +0100 Subject: win32: treat devices as character special files Commit 15fcbd19c (win32: special case for devices files in stat(2)) added special treatment in stat(2) for device files. As a result of this change device files appeared to be regular files which broke the use of /dev/null with noclobber in the shell. Device files now appear as character special files (as they do on Unix). GitHub issue #225. --- win32/mingw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/win32/mingw.c b/win32/mingw.c index c592b8d2c..74f738927 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -332,10 +332,12 @@ static inline mode_t file_attr_to_st_mode(DWORD attr) mode_t fMode = S_IRUSR|S_IRGRP|S_IROTH; if (attr & FILE_ATTRIBUTE_DIRECTORY) fMode |= S_IFDIR|S_IXUSR|S_IXGRP|S_IXOTH; + else if (attr & FILE_ATTRIBUTE_DEVICE) + fMode |= S_IFCHR|S_IWOTH; else fMode |= S_IFREG; if (!(attr & FILE_ATTRIBUTE_READONLY)) - fMode |= S_IWUSR|S_IWGRP|(attr & FILE_ATTRIBUTE_DEVICE ? S_IWOTH : 0); + fMode |= S_IWUSR|S_IWGRP; return fMode; } -- cgit v1.2.3-55-g6feb