60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
|
package helpers
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"net"
|
||
|
|
||
|
"git.kmsign.ru/royalcat/tstor/pkg/ctxbilly"
|
||
|
nfs "git.kmsign.ru/royalcat/tstor/pkg/go-nfs"
|
||
|
)
|
||
|
|
||
|
// NewNullAuthHandler creates a handler for the provided filesystem
|
||
|
func NewNullAuthHandler(fs nfs.Filesystem) nfs.Handler {
|
||
|
return &NullAuthHandler{fs}
|
||
|
}
|
||
|
|
||
|
// NullAuthHandler returns a NFS backing that exposes a given file system in response to all mount requests.
|
||
|
type NullAuthHandler struct {
|
||
|
fs nfs.Filesystem
|
||
|
}
|
||
|
|
||
|
// Mount backs Mount RPC Requests, allowing for access control policies.
|
||
|
func (h *NullAuthHandler) Mount(ctx context.Context, conn net.Conn, req nfs.MountRequest) (status nfs.MountStatus, hndl nfs.Filesystem, auths []nfs.AuthFlavor) {
|
||
|
status = nfs.MountStatusOk
|
||
|
hndl = h.fs
|
||
|
auths = []nfs.AuthFlavor{nfs.AuthFlavorNull}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// Change provides an interface for updating file attributes.
|
||
|
func (h *NullAuthHandler) Change(fs nfs.Filesystem) nfs.Change {
|
||
|
if c, ok := h.fs.(ctxbilly.Change); ok {
|
||
|
return c
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// FSStat provides information about a filesystem.
|
||
|
func (h *NullAuthHandler) FSStat(ctx context.Context, f nfs.Filesystem, s *nfs.FSStat) error {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// ToHandle handled by CachingHandler
|
||
|
func (h *NullAuthHandler) ToHandle(f nfs.Filesystem, s []string) []byte {
|
||
|
return []byte{}
|
||
|
}
|
||
|
|
||
|
// FromHandle handled by CachingHandler
|
||
|
func (h *NullAuthHandler) FromHandle([]byte) (nfs.Filesystem, []string, error) {
|
||
|
return nil, []string{}, nil
|
||
|
}
|
||
|
|
||
|
func (c *NullAuthHandler) InvalidateHandle(nfs.Filesystem, []byte) error {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// HandleLImit handled by cachingHandler
|
||
|
func (h *NullAuthHandler) HandleLimit() int {
|
||
|
return -1
|
||
|
}
|