Skip to content

Commit d13ecda

Browse files
committed
Truncate: do not use O_EXCL on Plan 9
Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
1 parent b5724fd commit d13ecda

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

file.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io"
77
"math"
88
"os"
9+
"runtime"
910
"time"
1011

1112
"github.com/go-git/go-billy/v5"
@@ -249,7 +250,11 @@ func (s *SetFileAttributes) Apply(changer billy.Change, fs billy.Filesystem, fil
249250
if curr.Mode()&os.ModeSymlink != 0 {
250251
return &NFSStatusError{NFSStatusNotSupp, os.ErrInvalid}
251252
}
252-
fp, err := fs.OpenFile(file, os.O_WRONLY|os.O_EXCL, 0)
253+
flags := os.O_WRONLY
254+
if runtime.GOOS != "plan9" {
255+
flags |= os.O_EXCL
256+
}
257+
fp, err := fs.OpenFile(file, flags, 0)
253258
if errors.Is(err, os.ErrPermission) {
254259
return &NFSStatusError{NFSStatusAccess, err}
255260
} else if err != nil {

0 commit comments

Comments
 (0)