small refactor*
This commit is contained in:
parent
b6b541e050
commit
24a4d30275
232 changed files with 2164 additions and 1906 deletions
server/pkg/go-nfs
52
server/pkg/go-nfs/handler.go
Normal file
52
server/pkg/go-nfs/handler.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
package nfs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/fs"
|
||||
"net"
|
||||
|
||||
"git.kmsign.ru/royalcat/tstor/server/pkg/ctxbilly"
|
||||
)
|
||||
|
||||
// Handler represents the interface of the file system / vfs being exposed over NFS
|
||||
type Handler interface {
|
||||
// Required methods
|
||||
|
||||
Mount(context.Context, net.Conn, MountRequest) (MountStatus, Filesystem, []AuthFlavor)
|
||||
|
||||
// Change can return 'nil' if filesystem is read-only
|
||||
// If the returned value can be cast to `UnixChange`, mknod and link RPCs will be available.
|
||||
Change(Filesystem) Change
|
||||
|
||||
// Optional methods - generic helpers or trivial implementations can be sufficient depending on use case.
|
||||
|
||||
// Fill in information about a file system's free space.
|
||||
FSStat(context.Context, Filesystem, *FSStat) error
|
||||
|
||||
// represent file objects as opaque references
|
||||
// Can be safely implemented via helpers/cachinghandler.
|
||||
ToHandle(ctx context.Context, fs Filesystem, path []string) []byte
|
||||
FromHandle(ctx context.Context, fh []byte) (Filesystem, []string, error)
|
||||
InvalidateHandle(context.Context, Filesystem, []byte) error
|
||||
|
||||
// How many handles can be safely maintained by the handler.
|
||||
HandleLimit() int
|
||||
}
|
||||
|
||||
// UnixChange extends the billy `Change` interface with support for special files.
|
||||
type UnixChange interface {
|
||||
ctxbilly.Change
|
||||
Mknod(ctx context.Context, path string, mode uint32, major uint32, minor uint32) error
|
||||
Mkfifo(ctx context.Context, path string, mode uint32) error
|
||||
Socket(ctx context.Context, path string) error
|
||||
Link(ctx context.Context, path string, link string) error
|
||||
}
|
||||
|
||||
// CachingHandler represents the optional caching work that a user may wish to over-ride with
|
||||
// their own implementations, but which can be otherwise provided through defaults.
|
||||
type CachingHandler interface {
|
||||
VerifierFor(path string, contents []fs.FileInfo) uint64
|
||||
|
||||
// fs.FileInfo needs to be sorted by Name(), nil in case of a cache-miss
|
||||
DataForVerifier(path string, verifier uint64) []fs.FileInfo
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue