Skip to content

Commit 5128edb

Browse files
committed
cmd/go/internal/lockedfile: ignore errors if locks are not supported
Some file systems do not support file locking. Ignore lock errors in these environments. I used the already implemented IsNotSupported function. If the file system does not support locking on Windows, ERROR_INVALID_FUNCTION is returned. Edited isNotSupported to ignore this. References #37461
1 parent cc386bd commit 5128edb

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

src/cmd/go/internal/lockedfile/internal/filelock/filelock_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func unlock(f File) error {
5858

5959
func isNotSupported(err error) bool {
6060
switch err {
61-
case windows.ERROR_NOT_SUPPORTED, windows.ERROR_CALL_NOT_IMPLEMENTED, ErrNotSupported:
61+
case windows.ERROR_INVALID_FUNCTION, windows.ERROR_NOT_SUPPORTED, windows.ERROR_CALL_NOT_IMPLEMENTED, ErrNotSupported:
6262
return true
6363
default:
6464
return false

src/cmd/go/internal/lockedfile/lockedfile_filelock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func openFile(name string, flag int, perm fs.FileMode) (*os.File, error) {
3131
default:
3232
err = filelock.RLock(f)
3333
}
34-
if err != nil {
34+
if err != nil && !filelock.IsNotSupported(err) {
3535
f.Close()
3636
return nil, err
3737
}

src/internal/syscall/windows/syscall_windows.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func UTF16PtrToString(p *uint16) string {
3636
}
3737

3838
const (
39+
ERROR_INVALID_FUNCTION syscall.Errno = 1
3940
ERROR_SHARING_VIOLATION syscall.Errno = 32
4041
ERROR_LOCK_VIOLATION syscall.Errno = 33
4142
ERROR_NOT_SUPPORTED syscall.Errno = 50

0 commit comments

Comments
 (0)