serve nfs: store billy FS in the Handler

This commit is contained in:
Nick Craig-Wood 2024-06-25 10:19:25 +01:00
parent cae22a7562
commit a697d27455

View File

@ -20,6 +20,7 @@ func NewHandler(vfs *vfs.VFS, opt *Options) nfs.Handler {
handler := &Handler{ handler := &Handler{
vfs: vfs, vfs: vfs,
opt: opt, opt: opt,
billyFS: &FS{vfs: vfs},
} }
handler.opt.HandleLimit = handler.opt.Limit() handler.opt.HandleLimit = handler.opt.Limit()
handler.cache = cacheHelper(handler, handler.HandleLimit()) handler.cache = cacheHelper(handler, handler.HandleLimit())
@ -30,15 +31,14 @@ func NewHandler(vfs *vfs.VFS, opt *Options) nfs.Handler {
type Handler struct { type Handler struct {
vfs *vfs.VFS vfs *vfs.VFS
opt *Options opt *Options
billyFS *FS
cache nfs.Handler cache nfs.Handler
} }
// Mount backs Mount RPC Requests, allowing for access control policies. // Mount backs Mount RPC Requests, allowing for access control policies.
func (h *Handler) Mount(ctx context.Context, conn net.Conn, req nfs.MountRequest) (status nfs.MountStatus, hndl billy.Filesystem, auths []nfs.AuthFlavor) { func (h *Handler) Mount(ctx context.Context, conn net.Conn, req nfs.MountRequest) (status nfs.MountStatus, hndl billy.Filesystem, auths []nfs.AuthFlavor) {
status = nfs.MountStatusOk
hndl = &FS{vfs: h.vfs}
auths = []nfs.AuthFlavor{nfs.AuthFlavorNull} auths = []nfs.AuthFlavor{nfs.AuthFlavorNull}
return return nfs.MountStatusOk, h.billyFS, auths
} }
// Change provides an interface for updating file attributes. // Change provides an interface for updating file attributes.