nfs

package
v1.65.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2023 License: MIT Imports: 18 Imported by: 13

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

Constants

This section is empty.

Variables

View Source
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.

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",
	},
	Run: Run,
}

Command is the definition of the command

Functions

func AddFlags

func AddFlags(flagSet *pflag.FlagSet, Opt *Options)

AddFlags adds flags for the sftp

func NewBackendAuthHandler

func NewBackendAuthHandler(vfs *vfs.VFS) nfs.Handler

NewBackendAuthHandler creates a handler for the provided filesystem

func Run

func Run(command *cobra.Command, args []string)

Run the command

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

Change provides an interface for updating file attributes.

func (*BackendAuthHandler) FSStat

FSStat provides information about a filesystem.

func (*BackendAuthHandler) FromHandle

func (h *BackendAuthHandler) FromHandle([]byte) (billy.Filesystem, []string, error)

FromHandle handled by CachingHandler

func (*BackendAuthHandler) HandleLimit

func (h *BackendAuthHandler) HandleLimit() int

HandleLimit handled by cachingHandler

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) Chmod

func (f *FS) Chmod(name string, mode os.FileMode) error

Chmod changes the file modes

func (*FS) Chown

func (f *FS) Chown(name string, uid, gid int) error

Chown changes owner of the file

func (*FS) Chroot

func (f *FS) Chroot(path string) (billy.Filesystem, error)

Chroot is not supported in VFS

func (*FS) Chtimes

func (f *FS) Chtimes(name string, atime time.Time, mtime time.Time) error

Chtimes changes the acces time and modified time

func (*FS) Create

func (f *FS) Create(filename string) (billy.File, error)

Create implements creating new files

func (*FS) Join

func (f *FS) Join(elem ...string) string

Join joins path elements

func (*FS) Lchown

func (f *FS) Lchown(name string, uid, gid int) error

Lchown changes the owner of symlink

func (*FS) Lstat

func (f *FS) Lstat(filename string) (os.FileInfo, error)

Lstat gets the stats for symlink

func (*FS) MkdirAll

func (f *FS) MkdirAll(filename string, perm os.FileMode) error

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

func (*FS) Open

func (f *FS) Open(filename string) (billy.File, error)

Open opens a file

func (*FS) OpenFile

func (f *FS) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error)

OpenFile opens a file

func (*FS) ReadDir

func (f *FS) ReadDir(path string) (dir []os.FileInfo, err error)

ReadDir implements read dir

func (f *FS) Readlink(link string) (string, error)

Readlink is not supported

func (*FS) Remove

func (f *FS) Remove(filename string) error

Remove deletes a file

func (*FS) Rename

func (f *FS) Rename(oldpath, newpath string) error

Rename renames a file

func (*FS) Root

func (f *FS) Root() string

Root returns the root of a VFS

func (*FS) Stat

func (f *FS) Stat(filename string) (os.FileInfo, error)

Stat gets the file stat

func (f *FS) Symlink(target, link string) error

Symlink is not supported over NFS

func (*FS) TempFile

func (f *FS) TempFile(dir, prefix string) (billy.File, error)

TempFile is not implemented

type Options

type Options struct {
	ListenAddr string // Port to listen on
}

Options contains options for the NFS Server

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server contains everything to run the Server

func NewServer

func NewServer(ctx context.Context, vfs *vfs.VFS, opt *Options) (s *Server, err error)

NewServer creates a new server

func (*Server) Addr

func (s *Server) Addr() net.Addr

Addr returns the listening address of the server

func (*Server) Serve

func (s *Server) Serve() (err error)

Serve starts the server

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown stops the server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL