small refactor*
This commit is contained in:
parent
b6b541e050
commit
24a4d30275
232 changed files with 2164 additions and 1906 deletions
server/pkg/go-nfs
55
server/pkg/go-nfs/nfs_onpathconf.go
Normal file
55
server/pkg/go-nfs/nfs_onpathconf.go
Normal file
|
@ -0,0 +1,55 @@
|
|||
package nfs
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
|
||||
"github.com/willscott/go-nfs-client/nfs/xdr"
|
||||
)
|
||||
|
||||
// PathNameMax is the maximum length for a file name
|
||||
const PathNameMax = 255
|
||||
|
||||
func onPathConf(ctx context.Context, w *response, userHandle Handler) error {
|
||||
roothandle, err := xdr.ReadOpaque(w.req.Body)
|
||||
if err != nil {
|
||||
return &NFSStatusError{NFSStatusInval, err}
|
||||
}
|
||||
fs, path, err := userHandle.FromHandle(ctx, roothandle)
|
||||
if err != nil {
|
||||
return &NFSStatusError{NFSStatusStale, err}
|
||||
}
|
||||
|
||||
writer := bytes.NewBuffer([]byte{})
|
||||
if err := xdr.Write(writer, uint32(NFSStatusOk)); err != nil {
|
||||
return &NFSStatusError{NFSStatusServerFault, err}
|
||||
}
|
||||
if err := WritePostOpAttrs(writer, tryStat(ctx, fs, path)); err != nil {
|
||||
return &NFSStatusError{NFSStatusServerFault, err}
|
||||
}
|
||||
|
||||
type PathConf struct {
|
||||
LinkMax uint32
|
||||
NameMax uint32
|
||||
NoTrunc uint32
|
||||
ChownRestricted uint32
|
||||
CaseInsensitive uint32
|
||||
CasePreserving uint32
|
||||
}
|
||||
|
||||
defaults := PathConf{
|
||||
LinkMax: 1,
|
||||
NameMax: PathNameMax,
|
||||
NoTrunc: 1,
|
||||
ChownRestricted: 0,
|
||||
CaseInsensitive: 0,
|
||||
CasePreserving: 1,
|
||||
}
|
||||
if err := xdr.Write(writer, defaults); err != nil {
|
||||
return &NFSStatusError{NFSStatusServerFault, err}
|
||||
}
|
||||
if err := w.Write(writer.Bytes()); err != nil {
|
||||
return &NFSStatusError{NFSStatusServerFault, err}
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue