royalcat
bc4b39b1c1
Some checks failed
docker / build-docker (linux/amd64) (push) Successful in 2m36s
docker / build-docker (linux/386) (push) Successful in 2m45s
docker / build-docker (linux/arm/v7) (push) Has been cancelled
docker / build-docker (linux/arm64/v8) (push) Has been cancelled
docker / build-docker (linux/arm64) (push) Has been cancelled
52 lines
1.9 KiB
Go
52 lines
1.9 KiB
Go
package nfs
|
|
|
|
import (
|
|
"context"
|
|
"io/fs"
|
|
"net"
|
|
|
|
"git.kmsign.ru/royalcat/tstor/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
|
|
}
|