]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: don't return EINVAL on zero Chmod mode on Windows
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 29 Apr 2019 17:14:23 +0000 (17:14 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 29 Apr 2019 19:15:54 +0000 (19:15 +0000)
Fixes #20858

Change-Id: I45c397795426aaa276b20f5cbeb80270c95b920c
Reviewed-on: https://go-review.googlesource.com/c/go/+/174320
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/os/file.go
src/syscall/syscall_windows.go

index 86af707865d5b83e8c71086a65a5a0a17fd4b420..0863c70af4d3df6405d8eeaa51d9f71b496ce091 100644 (file)
@@ -490,11 +490,11 @@ func UserHomeDir() (string, error) {
 // On Unix, the mode's permission bits, ModeSetuid, ModeSetgid, and
 // ModeSticky are used.
 //
-// On Windows, the mode must be non-zero but otherwise only the 0200
-// bit (owner writable) of mode is used; it controls whether the
-// file's read-only attribute is set or cleared. attribute. The other
-// bits are currently unused. Use mode 0400 for a read-only file and
-// 0600 for a readable+writable file.
+// On Windows, only the 0200 bit (owner writable) of mode is used; it
+// controls whether the file's read-only attribute is set or cleared.
+// The other bits are currently unused. For compatibilty with Go 1.12
+// and earlier, use a non-zero mode. Use mode 0400 for a read-only
+// file and 0600 for a readable+writable file.
 //
 // On Plan 9, the mode's permission bits, ModeAppend, ModeExclusive,
 // and ModeTemporary are used.
index 22c9e50a4417816aae150a4b115cb3eb084feeec..6201b6475d71eea90af8cd62a7d42dae08880efa 100644 (file)
@@ -567,9 +567,6 @@ func Fsync(fd Handle) (err error) {
 }
 
 func Chmod(path string, mode uint32) (err error) {
-       if mode == 0 {
-               return EINVAL
-       }
        p, e := UTF16PtrFromString(path)
        if e != nil {
                return e