]> Cypherpunks repositories - gostls13.git/commit
os: remove special casing of NUL in Windows file operations
authorDamien Neil <dneil@google.com>
Wed, 9 Nov 2022 00:10:47 +0000 (16:10 -0800)
committerDamien Neil <dneil@google.com>
Wed, 9 Nov 2022 22:06:14 +0000 (22:06 +0000)
commit61c57575cd01940d06a327ce61b8923bf4a7553a
treeb13d8850009e863fdd26564a9f1d5a59ed4c501d
parentbe9d78c9c5905fbc10d8cd6a4714dd4ad1c91674
os: remove special casing of NUL in Windows file operations

Some file operations, notably Stat and Mkdir, special cased their
behavior when operating on a file named "NUL" (case-insensitive).
This check failed to account for the many other names of the NUL
device, as well as other non-NUL device files: "./nul", "//./nul",
"nul.txt" (on some Windows versions), "con", etc.

Remove the special case.

os.Mkdir("NUL") now returns no error. This is consonant with the
operating system's behavior: CreateDirectory("NUL") succeeds, as
does "MKDIR NUL" on the command line.

os.Stat("NUL") now follows the existing path for FILE_TYPE_CHAR devices,
returning a FileInfo which correctly reports the file as being a
character device.

os.Stat and os.File.Stat have common elements of their logic unified.

For #24482.
For #24556.
For #56217.

Change-Id: I7e70f45901127c9961166dd6dbfe0c4a10b4ab64
Reviewed-on: https://go-review.googlesource.com/c/go/+/448897
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
src/os/file.go
src/os/os_test.go
src/os/os_windows_test.go
src/os/stat_windows.go
src/os/types_windows.go