Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion file.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"math"
"os"
"runtime"
"time"

"github.com/go-git/go-billy/v5"
Expand Down Expand Up @@ -133,6 +134,13 @@ func ToFileAttribute(info os.FileInfo, filePath string) *FileAttribute {
func tryStat(fs billy.Filesystem, path []string) *FileAttribute {
fullPath := fs.Join(path...)
attrs, err := fs.Lstat(fullPath)

// Programs frequently use Lstat to test for file existence.
// In this case, just return nil, without the Log.
if errors.Is(err, os.ErrNotExist) {
return nil
}

if err != nil || attrs == nil {
Log.Errorf("err loading attrs for %s: %v", fs.Join(path...), err)
return nil
Expand Down Expand Up @@ -249,7 +257,11 @@ func (s *SetFileAttributes) Apply(changer billy.Change, fs billy.Filesystem, fil
if curr.Mode()&os.ModeSymlink != 0 {
return &NFSStatusError{NFSStatusNotSupp, os.ErrInvalid}
}
fp, err := fs.OpenFile(file, os.O_WRONLY|os.O_EXCL, 0)
flags := os.O_WRONLY
if runtime.GOOS != "plan9" {
flags |= os.O_EXCL
}
fp, err := fs.OpenFile(file, flags, 0)
if errors.Is(err, os.ErrPermission) {
return &NFSStatusError{NFSStatusAccess, err}
} else if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions nfs_oncreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ func onCreate(ctx context.Context, w *response, userHandle Handler) error {
if err := xdr.Read(w.req.Body, &verf); err != nil {
return &NFSStatusError{NFSStatusInval, err}
}
Log.Errorf("failing create to indicate lack of support for 'exclusive' mode.")
// TODO: support 'exclusive' mode.
return &NFSStatusError{NFSStatusNotSupp, os.ErrPermission}
attrs = &SetFileAttributes{}
Log.Printf("%q: request for unimplemented 'exclusive' mode.", obj.Filename)
} else {
// invalid
return &NFSStatusError{NFSStatusNotSupp, os.ErrInvalid}
Expand Down
Loading