Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterMessageHandler(protocol uint32, proc uint32, handler HandleFunc) error
- func Serve(l net.Listener, handler Handler) error
- func WritePostOpAttrs(writer io.Writer, post *FileAttribute) error
- func WriteWcc(writer io.Writer, pre *FileCacheAttribute, post *FileAttribute) error
- type AuthError
- type AuthFlavor
- type AuthStat
- type DirOpArg
- type FSStat
- type FileAttribute
- type FileCacheAttribute
- type FileHandle
- type FileTime
- type FileType
- type HandleFunc
- type Handler
- type MountProcedure
- type MountRequest
- type MountResponse
- type MountStatus
- type NFSProcedure
- type NFSStatus
- type NFSStatusError
- type RPCError
- type RPCMismatchError
- type ResponseCode
- type ResponseCodeProcUnavailableError
- type ResponseCodeSystemError
- type Server
- type SetFileAttributes
- type StatusErrorWithBody
Constants ¶
const ( // FSInfoPropertyLink does the FS support hard links? FSInfoPropertyLink = 0x0001 // FSInfoPropertySymlink does the FS support soft links? FSInfoPropertySymlink = 0x0002 // FSInfoPropertyHomogeneous does the FS need PATHCONF calls for each file FSInfoPropertyHomogeneous = 0x0008 // FSInfoPropertyCanSetTime can the FS support setting access/mod times? FSInfoPropertyCanSetTime = 0x0010 )
const CheckRead = 1 << 15
CheckRead is a size where - if a request to read is larger than this, the server will stat the file to learn it's actual size before allocating a buffer to read into.
const FHSize = 64
FHSize is the maximum size of a FileHandle
const MNTNameLen = 255
MNTNameLen is the maximum size of a mount name
const MaxRead = 1 << 24
MaxRead is the advertised largest buffer the server is willing to read
const MntPathLen = 1024
MntPathLen is the maximum size of a mount path
const PathNameMax = 255
PathNameMax is the maximum length for a file name
Variables ¶
var ( // ErrInputInvalid is returned when input cannot be parsed ErrInputInvalid = errors.New("invalid input") // ErrAlreadySent is returned when writing a header/status multiple times ErrAlreadySent = errors.New("response already started") )
Functions ¶
func RegisterMessageHandler ¶
func RegisterMessageHandler(protocol uint32, proc uint32, handler HandleFunc) error
RegisterMessageHandler registers a handler for a specific XDR procedure.
func WritePostOpAttrs ¶
func WritePostOpAttrs(writer io.Writer, post *FileAttribute) error
WritePostOpAttrs writes the `post_op_attr` representation of a files attributes
func WriteWcc ¶
func WriteWcc(writer io.Writer, pre *FileCacheAttribute, post *FileAttribute) error
WriteWcc writes the `wcc_data` representation of an object.
Types ¶
type AuthError ¶
type AuthError struct {
AuthStat
}
AuthError is an RPCError
func (*AuthError) Code ¶
func (a *AuthError) Code() ResponseCode
Code for AuthErrors is ResponseCodeAuthError
func (*AuthError) MarshalBinary ¶
MarshalBinary sends the specific auth status
type AuthFlavor ¶
type AuthFlavor uint32
AuthFlavor is a form of authentication, per rfc1057 section 7.2
const ( AuthFlavorNull AuthFlavor = 0 AuthFlavorUnix AuthFlavor = 1 AuthFlavorShort AuthFlavor = 2 AuthFlavorDES AuthFlavor = 3 )
AuthFlavor Codes
type AuthStat ¶
type AuthStat uint32
AuthStat is an enumeration of why authentication ahs failed
const ( AuthStatOK AuthStat = iota AuthStatBadCred AuthStatRejectedCred AuthStatBadVerifier AuthStatRejectedVerfier AuthStatTooWeak AuthStatInvalidResponse AuthStatFailed AuthStatKerbGeneric AuthStatTimeExpire AuthStatTktFile AuthStatDecode AuthStatNetAddr AuthStatRPCGSSCredProblem AuthStatRPCGSSCTXProblem )
AuthStat Codes
type FSStat ¶
type FSStat struct { TotalSize uint64 FreeSize uint64 AvailableSize uint64 TotalFiles uint64 FreeFiles uint64 AvailableFiles uint64 // CacheHint is called "invarsec" in the nfs standard CacheHint time.Duration }
FSStat returns metadata about a file system
type FileAttribute ¶
type FileAttribute struct { Type FileType FileMode uint32 Nlink uint32 UID uint32 GID uint32 Filesize uint64 Used uint64 SpecData [2]uint32 FSID uint64 Fileid uint64 Atime, Mtime, Ctime FileTime }
FileAttribute holds metadata about a filesystem object
func ToFileAttribute ¶
func ToFileAttribute(info os.FileInfo) *FileAttribute
ToFileAttribute creates an NFS fattr3 struct from an OS.FileInfo
func (FileAttribute) AsCache ¶
func (f FileAttribute) AsCache() *FileCacheAttribute
AsCache provides the wcc view of the file attributes
func (*FileAttribute) Mode ¶
func (f *FileAttribute) Mode() os.FileMode
Mode provides the OS interpreted mode of the file attributes
type FileCacheAttribute ¶
FileCacheAttribute is the subset of FileAttribute used by wcc_attr
type FileTime ¶
FileTime is the NFS wire time format This is equivalent to go-nfs-client/nfs.NFS3Time
func (FileTime) EqualTimespec ¶
EqualTimespec returns if this time is equal to a local time spec
type FileType ¶
type FileType uint32
FileType represents a NFS File Type
type HandleFunc ¶
HandleFunc represents a handler for a specific protocol message.
type Handler ¶
type Handler interface { Mount(context.Context, net.Conn, MountRequest) (MountStatus, billy.Filesystem, []AuthFlavor) // Change can return 'nil' if filesystem is read-only Change(billy.Filesystem) billy.Change // Fill in information about a file system's free space. FSStat(context.Context, billy.Filesystem, *FSStat) error // represent file objects as opaque references // Can be safely implemented via helpers/cachinghandler. ToHandle(fs billy.Filesystem, path []string) []byte FromHandle(fh []byte) (billy.Filesystem, []string, error) // How many handles can be safely maintained by the handler. HandleLimit() int }
Handler represents the interface of the file system / vfs being exposed over NFS
type MountProcedure ¶
type MountProcedure uint32
MountProcedure is the valid RPC calls for the mount service.
const ( MountProcNull MountProcedure = iota MountProcMount MountProcDump MountProcUmnt MountProcUmntAll MountProcExport )
MountProcedure Codes
func (MountProcedure) String ¶
func (m MountProcedure) String() string
type MountRequest ¶
MountRequest contains the format of a client request to open a mount.
type MountResponse ¶
type MountResponse struct { rpc.Header FileHandle AuthFlavors []int }
MountResponse is the server's response with status `MountStatusOk`
type MountStatus ¶
type MountStatus uint32
MountStatus defines the response to the Mount Procedure
const ( MountStatusOk MountStatus = 0 MountStatusErrPerm MountStatus = 1 MountStatusErrNoEnt MountStatus = 2 MountStatusErrIO MountStatus = 5 MountStatusErrAcces MountStatus = 13 MountStatusErrNotDir MountStatus = 20 MountStatusErrInval MountStatus = 22 MountStatusErrNameTooLong MountStatus = 63 MountStatusErrNotSupp MountStatus = 10004 MountStatusErrServerFault MountStatus = 10006 )
MountStatus Codes
type NFSProcedure ¶
type NFSProcedure uint32
NFSProcedure is the valid RPC calls for the nfs service.
const ( NFSProcedureNull NFSProcedure = iota NFSProcedureGetAttr NFSProcedureSetAttr NFSProcedureLookup NFSProcedureAccess NFSProcedureReadlink NFSProcedureRead NFSProcedureWrite NFSProcedureCreate NFSProcedureMkDir NFSProcedureSymlink NFSProcedureMkNod NFSProcedureRemove NFSProcedureRmDir NFSProcedureRename NFSProcedureLink NFSProcedureReadDir NFSProcedureReadDirPlus NFSProcedureFSStat NFSProcedureFSInfo NFSProcedurePathConf NFSProcedureCommit )
NfsProcedure Codes
func (NFSProcedure) String ¶
func (n NFSProcedure) String() string
type NFSStatus ¶
type NFSStatus uint32
NFSStatus (nfsstat3) is a result code for nfs rpc calls
const ( NFSStatusOk NFSStatus = 0 NFSStatusPerm NFSStatus = 1 NFSStatusNoEnt NFSStatus = 2 NFSStatusIO NFSStatus = 5 NFSStatusNXIO NFSStatus = 6 NFSStatusAccess NFSStatus = 13 NFSStatusExist NFSStatus = 17 NFSStatusXDev NFSStatus = 18 NFSStatusNoDev NFSStatus = 19 NFSStatusNotDir NFSStatus = 20 NFSStatusIsDir NFSStatus = 21 NFSStatusInval NFSStatus = 22 NFSStatusFBig NFSStatus = 27 NFSStatusNoSPC NFSStatus = 28 NFSStatusROFS NFSStatus = 30 NFSStatusMlink NFSStatus = 31 NFSStatusNameTooLong NFSStatus = 63 NFSStatusNotEmpty NFSStatus = 66 NFSStatusDQuot NFSStatus = 69 NFSStatusStale NFSStatus = 70 NFSStatusRemote NFSStatus = 71 NFSStatusBadHandle NFSStatus = 10001 NFSStatusNotSync NFSStatus = 10002 NFSStatusBadCookie NFSStatus = 10003 NFSStatusNotSupp NFSStatus = 10004 NFSStatusTooSmall NFSStatus = 10005 NFSStatusServerFault NFSStatus = 10006 NFSStatusBadType NFSStatus = 10007 NFSStatusJukebox NFSStatus = 10008 )
NFSStatus codes
type NFSStatusError ¶
NFSStatusError represents an error at the NFS level.
func (*NFSStatusError) Code ¶
func (s *NFSStatusError) Code() ResponseCode
Code for NFS issues are successful RPC responses
func (*NFSStatusError) MarshalBinary ¶
func (s *NFSStatusError) MarshalBinary() (data []byte, err error)
MarshalBinary - The binary form of the code.
func (*NFSStatusError) Unwrap ¶
func (s *NFSStatusError) Unwrap() error
Unwrap unpacks wrapped errors
type RPCError ¶
type RPCError interface { // An RPCError is an `error` with this method Error() string // Code is the RPC Response code to send Code() ResponseCode // BinaryMarshaler is the on-wire representation of this error encoding.BinaryMarshaler }
RPCError provides the error interface for errors thrown by procedures to be transmitted over the XDR RPC channel
type RPCMismatchError ¶
RPCMismatchError is an RPCError
func (*RPCMismatchError) Code ¶
func (r *RPCMismatchError) Code() ResponseCode
Code for RPCMismatchError is ResponseCodeRPCMismatch
func (*RPCMismatchError) Error ¶
func (r *RPCMismatchError) Error() string
func (*RPCMismatchError) MarshalBinary ¶
func (r *RPCMismatchError) MarshalBinary() (data []byte, err error)
MarshalBinary sends the specific rpc mismatch range
type ResponseCode ¶
type ResponseCode uint32
ResponseCode is a combination of accept_stat and reject_stat.
const ( ResponseCodeSuccess ResponseCode = iota ResponseCodeGarbageArgs ResponseCodeSystemErr ResponseCodeRPCMismatch ResponseCodeAuthError )
ResponseCode Codes
type ResponseCodeProcUnavailableError ¶
type ResponseCodeProcUnavailableError struct { }
ResponseCodeProcUnavailableError is an RPCError
func (*ResponseCodeProcUnavailableError) Code ¶
func (r *ResponseCodeProcUnavailableError) Code() ResponseCode
Code for ResponseCodeProcUnavailableError
func (*ResponseCodeProcUnavailableError) Error ¶
func (r *ResponseCodeProcUnavailableError) Error() string
func (*ResponseCodeProcUnavailableError) MarshalBinary ¶
func (r *ResponseCodeProcUnavailableError) MarshalBinary() (data []byte, err error)
MarshalBinary - this error has no associated body
type ResponseCodeSystemError ¶
type ResponseCodeSystemError struct { }
ResponseCodeSystemError is an RPCError
func (*ResponseCodeSystemError) Code ¶
func (r *ResponseCodeSystemError) Code() ResponseCode
Code for ResponseCodeSystemError
func (*ResponseCodeSystemError) Error ¶
func (r *ResponseCodeSystemError) Error() string
func (*ResponseCodeSystemError) MarshalBinary ¶
func (r *ResponseCodeSystemError) MarshalBinary() (data []byte, err error)
MarshalBinary - this error has no associated body
type SetFileAttributes ¶
type SetFileAttributes struct { SetMode *uint32 SetUID *uint32 SetGID *uint32 SetSize *uint64 SetAtime *time.Time SetMtime *time.Time }
SetFileAttributes represents a command to update some metadata about a file.
func ReadSetFileAttributes ¶
func ReadSetFileAttributes(r io.Reader) (*SetFileAttributes, error)
ReadSetFileAttributes reads an sattr3 xdr stream into a go struct.
func (*SetFileAttributes) Apply ¶
func (s *SetFileAttributes) Apply(changer billy.Change, fs billy.Filesystem, file string) error
Apply uses a `Change` implementation to set defined attributes on a provided file.
type StatusErrorWithBody ¶
type StatusErrorWithBody struct { NFSStatusError Body []byte }
StatusErrorWithBody is an NFS error with a payload.
func (*StatusErrorWithBody) MarshalBinary ¶
func (s *StatusErrorWithBody) MarshalBinary() (data []byte, err error)
MarshalBinary provides the wire format of the error response
Source Files
¶
- conn.go
- errors.go
- file.go
- filesystem.go
- handler.go
- mount.go
- mountinterface.go
- nfs.go
- nfs_onaccess.go
- nfs_oncommit.go
- nfs_oncreate.go
- nfs_onfsinfo.go
- nfs_onfsstat.go
- nfs_ongetattr.go
- nfs_onlink.go
- nfs_onlookup.go
- nfs_onmkdir.go
- nfs_onmknod.go
- nfs_onpathconf.go
- nfs_onread.go
- nfs_onreaddir.go
- nfs_onreaddirplus.go
- nfs_onreadlink.go
- nfs_onremove.go
- nfs_onrename.go
- nfs_onrmdir.go
- nfs_onsetattr.go
- nfs_onsymlink.go
- nfs_onwrite.go
- nfsinterface.go
- server.go
- time.go