diff options
author | Ron Yorston <rmy@pobox.com> | 2021-08-13 13:44:13 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-08-13 13:44:13 +0100 |
commit | 04fd6cdcc6fc1f07938f7e2fa1a0d313a15617be (patch) | |
tree | 80de739eca88b41cd5c1c2bf43295c91cb4aaada | |
parent | 9ec4642e35e2f5dc625f0e704020d41e8674fe99 (diff) | |
download | busybox-w32-04fd6cdcc6fc1f07938f7e2fa1a0d313a15617be.tar.gz busybox-w32-04fd6cdcc6fc1f07938f7e2fa1a0d313a15617be.tar.bz2 busybox-w32-04fd6cdcc6fc1f07938f7e2fa1a0d313a15617be.zip |
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.
-rw-r--r-- | win32/mingw.c | 4 |
1 files changed, 3 insertions, 1 deletions
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) | |||
332 | mode_t fMode = S_IRUSR|S_IRGRP|S_IROTH; | 332 | mode_t fMode = S_IRUSR|S_IRGRP|S_IROTH; |
333 | if (attr & FILE_ATTRIBUTE_DIRECTORY) | 333 | if (attr & FILE_ATTRIBUTE_DIRECTORY) |
334 | fMode |= S_IFDIR|S_IXUSR|S_IXGRP|S_IXOTH; | 334 | fMode |= S_IFDIR|S_IXUSR|S_IXGRP|S_IXOTH; |
335 | else if (attr & FILE_ATTRIBUTE_DEVICE) | ||
336 | fMode |= S_IFCHR|S_IWOTH; | ||
335 | else | 337 | else |
336 | fMode |= S_IFREG; | 338 | fMode |= S_IFREG; |
337 | if (!(attr & FILE_ATTRIBUTE_READONLY)) | 339 | if (!(attr & FILE_ATTRIBUTE_READONLY)) |
338 | fMode |= S_IWUSR|S_IWGRP|(attr & FILE_ATTRIBUTE_DEVICE ? S_IWOTH : 0); | 340 | fMode |= S_IWUSR|S_IWGRP; |
339 | return fMode; | 341 | return fMode; |
340 | } | 342 | } |
341 | 343 | ||