diff --git a/log/levels.go b/log/levels.go index c1bf9ee..edd288d 100644 --- a/log/levels.go +++ b/log/levels.go @@ -13,15 +13,13 @@ const ( NOTSET = 8 ) -var ( - idx = map[int]string{ - CRITICAL: "critical", - ERROR: "error", - WARNING: "warning", - INFO: "info", - DEBUG: "debug", - } -) +var idx = map[int]string{ + CRITICAL: "critical", + ERROR: "error", + WARNING: "warning", + INFO: "info", + DEBUG: "debug", +} func GetLevelName(lev int) string { if name, found := idx[lev]; found { diff --git a/nfs/implv3/access.go b/nfs/implv3/access.go index ab6d2b0..c3f6b3d 100644 --- a/nfs/implv3/access.go +++ b/nfs/implv3/access.go @@ -85,7 +85,7 @@ func Access(h *nfs.RPCMsgCall, ctx nfs.RPCContext) (int, error) { AttributesFollow: true, Attributes: &nfs.FileAttrs{ Type: nfs.FTYPE_NF3DIR, - Mode: uint32(0777), + Mode: uint32(0o777), Size: 0, Used: 0, ATime: nfs.MakeNfsTime(now), diff --git a/nfs/implv3/fsinfo.go b/nfs/implv3/fsinfo.go index 0c4b4f4..9cb367b 100644 --- a/nfs/implv3/fsinfo.go +++ b/nfs/implv3/fsinfo.go @@ -78,7 +78,7 @@ func FsInfo(h *nfs.RPCMsgCall, ctx nfs.RPCContext) (int, error) { AttributesFollow: true, Attributes: &nfs.FileAttrs{ Type: nfs.FTYPE_NF3DIR, - Mode: uint32(0755), + Mode: uint32(0o755), Size: 1 << 63, Used: 0, ATime: nfs.MakeNfsTime(now), diff --git a/nfs/implv3/fsstat.go b/nfs/implv3/fsstat.go index c3a2ae4..a779947 100644 --- a/nfs/implv3/fsstat.go +++ b/nfs/implv3/fsstat.go @@ -79,7 +79,7 @@ func FsStat(h *nfs.RPCMsgCall, ctx nfs.RPCContext) (int, error) { AttributesFollow: true, Attributes: &nfs.FileAttrs{ Type: nfs.FTYPE_NF3DIR, - Mode: uint32(0755), + Mode: uint32(0o755), Size: capacity, Used: 0, ATime: nfs.MakeNfsTime(now), diff --git a/nfs/implv3/getattr.go b/nfs/implv3/getattr.go index bfbb51b..1b92a38 100644 --- a/nfs/implv3/getattr.go +++ b/nfs/implv3/getattr.go @@ -108,7 +108,7 @@ func GetAttr(h *nfs.RPCMsgCall, ctx nfs.RPCContext) (int, error) { attr := nfs.FileAttrs{ Type: ftype, - Mode: uint32(0755), + Mode: uint32(0o755), Size: uint64(fi.Size()), Used: uint64(fi.Size()), Rdev: nfs.SpecData{}, diff --git a/nfs/implv3/pathconf.go b/nfs/implv3/pathconf.go index f96b77f..b685d89 100644 --- a/nfs/implv3/pathconf.go +++ b/nfs/implv3/pathconf.go @@ -76,7 +76,7 @@ func PathConf(h *nfs.RPCMsgCall, ctx nfs.RPCContext) (int, error) { AttributesFollow: true, Attributes: &nfs.FileAttrs{ Type: nfs.FTYPE_NF3DIR, - Mode: uint32(0755), + Mode: uint32(0o755), Size: 1 << 63, Used: 0, ATime: nfs.MakeNfsTime(now), diff --git a/nfs/implv3/utils.go b/nfs/implv3/utils.go index 0d2969c..56280ff 100644 --- a/nfs/implv3/utils.go +++ b/nfs/implv3/utils.go @@ -3,10 +3,11 @@ package implv3 import ( "crypto/md5" "encoding/binary" - "github.com/smallfz/libnfs-go/nfs" "os" "path" "time" + + "github.com/smallfz/libnfs-go/nfs" ) func getFileId(name string) uint64 { diff --git a/nfs/implv4/attrs_test.go b/nfs/implv4/attrs_test.go index a4ed79d..7b95def 100644 --- a/nfs/implv4/attrs_test.go +++ b/nfs/implv4/attrs_test.go @@ -2,8 +2,9 @@ package implv4 import ( "encoding/json" - "github.com/smallfz/libnfs-go/log" "testing" + + "github.com/smallfz/libnfs-go/log" ) func TestFAttr4Decoding(t *testing.T) { diff --git a/nfs/implv4/commit.go b/nfs/implv4/commit.go index 82651a2..260c463 100644 --- a/nfs/implv4/commit.go +++ b/nfs/implv4/commit.go @@ -6,7 +6,6 @@ import ( ) func commit(x nfs.RPCContext, args *nfs.COMMIT4args) (*nfs.COMMIT4res, error) { - vfs := x.GetFS() fh := x.Stat().CurrentHandle() pathName, err := vfs.ResolveHandle(fh) diff --git a/nfs/implv4/remove.go b/nfs/implv4/remove.go index 328a970..ecefcc0 100644 --- a/nfs/implv4/remove.go +++ b/nfs/implv4/remove.go @@ -25,6 +25,7 @@ func remove(x nfs.RPCContext, args *nfs.REMOVE4args) (*nfs.REMOVE4res, error) { fi, err := vfs.Stat(pathName) if err != nil { log.Warnf(" remove: vfs.Stat(%s): %v", pathName, err) + return &nfs.REMOVE4res{Status: nfs.NFS4ERR_PERM}, nil } if fi.IsDir() && fi.NumLinks() > 2 { diff --git a/server/mux_v3.go b/server/mux_v3.go index 896bd23..dedf1b6 100644 --- a/server/mux_v3.go +++ b/server/mux_v3.go @@ -17,6 +17,8 @@ type Mux struct { stat nfs.StatService } +var _ nfs.RPCContext = (*Mux)(nil) + func (x *Mux) Reader() *xdr.Reader { return x.reader } diff --git a/server/mux_v4.go b/server/mux_v4.go index d874331..2978dc9 100644 --- a/server/mux_v4.go +++ b/server/mux_v4.go @@ -17,6 +17,8 @@ type Muxv4 struct { stat nfs.StatService } +var _ nfs.RPCContext = (*Muxv4)(nil) + func (x *Muxv4) Reader() *xdr.Reader { return x.reader }