Documentation ¶
Overview ¶
Package nfs implements a server to serve a VFS remote over NFSv3 protocol
There is no authentication available on this server and it is served on loopback interface by default.
This is primarily used for mounting a VFS remote in macOS, where FUSE-mounting mechanisms are usually not available.
Index ¶
- Variables
- func AddFlags(flagSet *pflag.FlagSet, Opt *Options)
- func NewBackendAuthHandler(vfs *vfs.VFS, opt *Options) nfs.Handler
- func Run(command *cobra.Command, args []string)
- type BackendAuthHandler
- func (h *BackendAuthHandler) Change(fs billy.Filesystem) billy.Change
- func (h *BackendAuthHandler) FSStat(ctx context.Context, f billy.Filesystem, s *nfs.FSStat) error
- func (h *BackendAuthHandler) FromHandle(b []byte) (billy.Filesystem, []string, error)
- func (h *BackendAuthHandler) HandleLimit() int
- func (h *BackendAuthHandler) InvalidateHandle(billy.Filesystem, []byte) error
- func (h *BackendAuthHandler) Mount(ctx context.Context, conn net.Conn, req nfs.MountRequest) (status nfs.MountStatus, hndl billy.Filesystem, auths []nfs.AuthFlavor)
- func (h *BackendAuthHandler) ToHandle(f billy.Filesystem, s []string) []byte
- type FS
- func (f *FS) Capabilities() billy.Capability
- func (f *FS) Chmod(name string, mode os.FileMode) error
- func (f *FS) Chown(name string, uid, gid int) error
- func (f *FS) Chroot(path string) (billy.Filesystem, error)
- func (f *FS) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (f *FS) Create(filename string) (billy.File, error)
- func (f *FS) Join(elem ...string) string
- func (f *FS) Lchown(name string, uid, gid int) error
- func (f *FS) Lstat(filename string) (os.FileInfo, error)
- func (f *FS) MkdirAll(filename string, perm os.FileMode) error
- func (f *FS) Open(filename string) (billy.File, error)
- func (f *FS) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error)
- func (f *FS) ReadDir(path string) (dir []os.FileInfo, err error)
- func (f *FS) Readlink(link string) (string, error)
- func (f *FS) Remove(filename string) error
- func (f *FS) Rename(oldpath, newpath string) error
- func (f *FS) Root() string
- func (f *FS) Stat(filename string) (os.FileInfo, error)
- func (f *FS) Symlink(target, link string) error
- func (f *FS) TempFile(dir, prefix string) (billy.File, error)
- type LogIntercepter
- func (l *LogIntercepter) Debug(args ...interface{})
- func (l *LogIntercepter) Debugf(format string, args ...interface{})
- func (l *LogIntercepter) Error(args ...interface{})
- func (l *LogIntercepter) Errorf(format string, args ...interface{})
- func (l *LogIntercepter) Fatal(args ...interface{})
- func (l *LogIntercepter) Fatalf(format string, args ...interface{})
- func (l *LogIntercepter) GetLevel() nfs.LogLevel
- func (l *LogIntercepter) Info(args ...interface{})
- func (l *LogIntercepter) Infof(format string, args ...interface{})
- func (l *LogIntercepter) Intercept(args ...interface{})
- func (l *LogIntercepter) Interceptf(format string, args ...interface{})
- func (l *LogIntercepter) Panic(args ...interface{})
- func (l *LogIntercepter) Panicf(format string, args ...interface{})
- func (l *LogIntercepter) ParseLevel(level string) (nfs.LogLevel, error)
- func (l *LogIntercepter) Print(args ...interface{})
- func (l *LogIntercepter) Printf(format string, args ...interface{})
- func (l *LogIntercepter) SetLevel(level nfs.LogLevel)
- func (l *LogIntercepter) Trace(args ...interface{})
- func (l *LogIntercepter) Tracef(format string, args ...interface{})
- func (l *LogIntercepter) Warn(args ...interface{})
- func (l *LogIntercepter) Warnf(format string, args ...interface{})
- type Options
- type Server
Constants ¶
This section is empty.
Variables ¶
var Command = &cobra.Command{ Use: "nfs remote:path", Short: `Serve the remote as an NFS mount`, Long: `Create an NFS server that serves the given remote over the network. The primary purpose for this command is to enable [mount command](/commands/rclone_mount/) on recent macOS versions where installing FUSE is very cumbersome. Since this is running on NFSv3, no authentication method is available. Any client will be able to access the data. To limit access, you can use serve NFS on loopback address and rely on secure tunnels (such as SSH). For this reason, by default, a random TCP port is chosen and loopback interface is used for the listening address; meaning that it is only available to the local machine. If you want other machines to access the NFS mount over local network, you need to specify the listening address and port using ` + "`--addr`" + ` flag. Modifying files through NFS protocol requires VFS caching. Usually you will need to specify ` + "`--vfs-cache-mode`" + ` in order to be able to write to the mountpoint (full is recommended). If you don't specify VFS cache mode, the mount will be read-only. Note also that ` + "`--nfs-cache-handle-limit`" + ` controls the maximum number of cached file handles stored by the caching handler. This should not be set too low or you may experience errors when trying to access files. The default is ` + "`1000000`" + `, but consider lowering this limit if the server's system resource usage causes problems. To serve NFS over the network use following command: rclone serve nfs remote: --addr 0.0.0.0:$PORT --vfs-cache-mode=full We specify a specific port that we can use in the mount command: To mount the server under Linux/macOS, use the following command: mount -oport=$PORT,mountport=$PORT $HOSTNAME: path/to/mountpoint Where ` + "`$PORT`" + ` is the same port number we used in the serve nfs command. This feature is only available on Unix platforms. ` + vfs.Help(), Annotations: map[string]string{ "versionIntroduced": "v1.65", "groups": "Filter", "status": "Experimental", }, Run: Run, }
Command is the definition of the command
var OnUnmountFunc func()
OnUnmountFunc registers a function to call when externally unmounted
Functions ¶
func NewBackendAuthHandler ¶
NewBackendAuthHandler creates a handler for the provided filesystem
Types ¶
type BackendAuthHandler ¶
type BackendAuthHandler struct {
// contains filtered or unexported fields
}
BackendAuthHandler returns a NFS backing that exposes a given file system in response to all mount requests.
func (*BackendAuthHandler) Change ¶
func (h *BackendAuthHandler) Change(fs billy.Filesystem) billy.Change
Change provides an interface for updating file attributes.
func (*BackendAuthHandler) FSStat ¶
func (h *BackendAuthHandler) FSStat(ctx context.Context, f billy.Filesystem, s *nfs.FSStat) error
FSStat provides information about a filesystem.
func (*BackendAuthHandler) FromHandle ¶
func (h *BackendAuthHandler) FromHandle(b []byte) (billy.Filesystem, []string, error)
FromHandle handled by CachingHandler
func (*BackendAuthHandler) HandleLimit ¶
func (h *BackendAuthHandler) HandleLimit() int
HandleLimit handled by cachingHandler
func (*BackendAuthHandler) InvalidateHandle ¶
func (h *BackendAuthHandler) InvalidateHandle(billy.Filesystem, []byte) error
InvalidateHandle is called on removes or renames
func (*BackendAuthHandler) Mount ¶
func (h *BackendAuthHandler) Mount(ctx context.Context, conn net.Conn, req nfs.MountRequest) (status nfs.MountStatus, hndl billy.Filesystem, auths []nfs.AuthFlavor)
Mount backs Mount RPC Requests, allowing for access control policies.
func (*BackendAuthHandler) ToHandle ¶
func (h *BackendAuthHandler) ToHandle(f billy.Filesystem, s []string) []byte
ToHandle handled by CachingHandler
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS is our wrapper around the VFS to properly support billy.Filesystem interface
func (*FS) Capabilities ¶
func (f *FS) Capabilities() billy.Capability
Capabilities exports the filesystem capabilities
func (*FS) Chroot ¶
func (f *FS) Chroot(path string) (billy.Filesystem, error)
Chroot is not supported in VFS
func (*FS) MkdirAll ¶
MkdirAll creates a directory and all the ones above it it does not redirect to VFS.MkDirAll because that one doesn't honor the permissions
type LogIntercepter ¶
type LogIntercepter struct {
Level nfs.LogLevel
}
LogIntercepter intercepts noisy go-nfs logs and reroutes them to DEBUG
func (*LogIntercepter) Debug ¶
func (l *LogIntercepter) Debug(args ...interface{})
Debug reroutes go-nfs Debug messages to Intercept
func (*LogIntercepter) Debugf ¶
func (l *LogIntercepter) Debugf(format string, args ...interface{})
Debugf reroutes go-nfs Debugf messages to Interceptf
func (*LogIntercepter) Error ¶
func (l *LogIntercepter) Error(args ...interface{})
Error reroutes go-nfs Error messages to Intercept
func (*LogIntercepter) Errorf ¶
func (l *LogIntercepter) Errorf(format string, args ...interface{})
Errorf reroutes go-nfs Errorf messages to Interceptf
func (*LogIntercepter) Fatal ¶
func (l *LogIntercepter) Fatal(args ...interface{})
Fatal reroutes go-nfs Fatal messages to Intercept
func (*LogIntercepter) Fatalf ¶
func (l *LogIntercepter) Fatalf(format string, args ...interface{})
Fatalf reroutes go-nfs Fatalf messages to Interceptf
func (*LogIntercepter) GetLevel ¶
func (l *LogIntercepter) GetLevel() nfs.LogLevel
GetLevel returns the nfs.LogLevel
func (*LogIntercepter) Info ¶
func (l *LogIntercepter) Info(args ...interface{})
Info reroutes go-nfs Info messages to Intercept
func (*LogIntercepter) Infof ¶
func (l *LogIntercepter) Infof(format string, args ...interface{})
Infof reroutes go-nfs Infof messages to Interceptf
func (*LogIntercepter) Intercept ¶
func (l *LogIntercepter) Intercept(args ...interface{})
Intercept intercepts go-nfs logs and calls fs.Debugf instead
func (*LogIntercepter) Interceptf ¶
func (l *LogIntercepter) Interceptf(format string, args ...interface{})
Interceptf intercepts go-nfs logs and calls fs.Debugf instead
func (*LogIntercepter) Panic ¶
func (l *LogIntercepter) Panic(args ...interface{})
Panic reroutes go-nfs Panic messages to Intercept
func (*LogIntercepter) Panicf ¶
func (l *LogIntercepter) Panicf(format string, args ...interface{})
Panicf reroutes go-nfs Panicf messages to Interceptf
func (*LogIntercepter) ParseLevel ¶
func (l *LogIntercepter) ParseLevel(level string) (nfs.LogLevel, error)
ParseLevel parses the nfs.LogLevel
func (*LogIntercepter) Print ¶
func (l *LogIntercepter) Print(args ...interface{})
Print reroutes go-nfs Print messages to Intercept
func (*LogIntercepter) Printf ¶
func (l *LogIntercepter) Printf(format string, args ...interface{})
Printf reroutes go-nfs Printf messages to Intercept
func (*LogIntercepter) SetLevel ¶
func (l *LogIntercepter) SetLevel(level nfs.LogLevel)
SetLevel sets the nfs.LogLevel
func (*LogIntercepter) Trace ¶
func (l *LogIntercepter) Trace(args ...interface{})
Trace reroutes go-nfs Trace messages to Intercept
func (*LogIntercepter) Tracef ¶
func (l *LogIntercepter) Tracef(format string, args ...interface{})
Tracef reroutes go-nfs Tracef messages to Interceptf
func (*LogIntercepter) Warn ¶
func (l *LogIntercepter) Warn(args ...interface{})
Warn reroutes go-nfs Warn messages to Intercept
func (*LogIntercepter) Warnf ¶
func (l *LogIntercepter) Warnf(format string, args ...interface{})
Warnf reroutes go-nfs Warnf messages to Interceptf
type Options ¶
type Options struct { ListenAddr string // Port to listen on HandleLimit int // max file handles cached by go-nfs CachingHandler }
Options contains options for the NFS Server