Skip to content

Commit

Permalink
syscall: don't return EINVAL on zero Chmod mode on Windows
Browse files Browse the repository at this point in the history
Fixes #20858

Change-Id: I45c397795426aaa276b20f5cbeb80270c95b920c
Reviewed-on: https://go-review.googlesource.com/c/go/+/174320
Reviewed-by: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
bradfitz committed Apr 29, 2019
1 parent 6ee8324 commit 2b8cbc3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/os/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions src/syscall/syscall_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2b8cbc3

Please sign in to comment.