Documentation
¶
Overview ¶
Package fskitwire is the protocol between motte-vfsd and the Swift module of the FSKit transport: the frame codec, the requests and answers, and the error names. It is the one definition; the daemon, the Go test client and the fixtures of testdata/fskit use it.
Index ¶
- Constants
- Variables
- func EntryCost(name int, attrs bool) int
- func ReadFrame(r io.Reader) (header, body []byte, err error)
- func SocketName(workspace string) string
- func WriteFrame(w io.Writer, header, body []byte) error
- type Answer
- type Attr
- type AttrAnswer
- type Code
- type DirEntry
- type ErrAnswer
- type HelloAnswer
- type NamesAnswer
- type NodeAnswer
- type ReadDirAnswer
- type Request
- type SetAttrAnswer
- type TargetAnswer
- type Time
- type WriteAnswer
Constants ¶
const ( Proto = 1 // MaxFrame is the size of a whole frame, the four bytes of total included. MaxFrame = 9 << 20 MaxBody = 8 << 20 )
const ( OpHello = "hello" OpActivate = "activate" OpLookup = "lookup" OpGetAttr = "getattr" OpSetAttr = "setattr" OpReadDir = "readdir" OpCreate = "create" OpSymlink = "symlink" OpReadLink = "readlink" OpRename = "rename" OpRemove = "remove" OpRead = "read" OpWrite = "write" OpXattrGet = "xattr_get" OpXattrSet = "xattr_set" OpXattrList = "xattr_list" OpOpen = "open" OpClose = "close" OpSync = "sync" OpForget = "forget" OpMounted = "mounted" OpUnmounted = "unmounted" OpDeactivate = "deactivate" )
const ( TypeFile = "file" TypeDir = "dir" TypeSymlink = "symlink" TypeSocket = "socket" )
const ( EntryBase = 24 AttrCost = 128 )
Variables ¶
var ( ErrFrameTooLarge = errors.New("fskitwire: frame over 9 MiB") ErrBodyTooLarge = errors.New("fskitwire: body over 8 MiB") ErrMalformed = errors.New("fskitwire: malformed frame") )
var Codes = []Code{ENOENT, EEXIST, ENOTDIR, EISDIR, ENOTEMPTY, EINVAL, EACCES, EPERM, EROFS, EFBIG, ENOSPC, ENAMETOOLONG, ENOTSUP, ENODATA, EIO, EBUSY, ESTALE, EBADCOOKIE}
var Ops = []string{OpHello, OpActivate, OpLookup, OpGetAttr, OpSetAttr, OpReadDir, OpCreate, OpSymlink, OpReadLink, OpRename, OpRemove, OpRead, OpWrite, OpXattrGet, OpXattrSet, OpXattrList, OpOpen, OpClose, OpSync, OpForget, OpMounted, OpUnmounted, OpDeactivate}
Functions ¶
func ReadFrame ¶
ReadFrame reads one frame. A frame over the limit is refused after four bytes, and the stream is no longer in step. A body over the limit is read whole and refused with its header, so the stream stays in step.
func SocketName ¶
SocketName is the name of the socket file of a workspace in the group container directory. The path of a unix socket is at most 103 bytes on macOS, so the name is a hash of the workspace.
Types ¶
type Attr ¶
type Attr struct {
Ino *uint64 `json:"ino,omitempty"`
Type *string `json:"type,omitempty"`
Mode *uint32 `json:"mode,omitempty"`
Nlink *uint32 `json:"nlink,omitempty"`
UID *uint32 `json:"uid,omitempty"`
GID *uint32 `json:"gid,omitempty"`
Size *uint64 `json:"size,omitempty"`
Alloc *uint64 `json:"alloc,omitempty"`
Atime *Time `json:"atime,omitempty"`
Mtime *Time `json:"mtime,omitempty"`
Ctime *Time `json:"ctime,omitempty"`
Btime *Time `json:"btime,omitempty"`
Flags *uint32 `json:"flags,omitempty"`
Parent *uint64 `json:"parent,omitempty"`
}
type AttrAnswer ¶
type Code ¶
type Code string
Code is the err of an answer. The list is closed.
const ( ENOENT Code = "ENOENT" EEXIST Code = "EEXIST" ENOTDIR Code = "ENOTDIR" EISDIR Code = "EISDIR" ENOTEMPTY Code = "ENOTEMPTY" EINVAL Code = "EINVAL" EACCES Code = "EACCES" EPERM Code = "EPERM" EROFS Code = "EROFS" EFBIG Code = "EFBIG" ENOSPC Code = "ENOSPC" ENAMETOOLONG Code = "ENAMETOOLONG" ENOTSUP Code = "ENOTSUP" ENODATA Code = "ENODATA" EIO Code = "EIO" EBUSY Code = "EBUSY" ESTALE Code = "ESTALE" EBADCOOKIE Code = "EBADCOOKIE" )
type HelloAnswer ¶
type NamesAnswer ¶
type NodeAnswer ¶
type ReadDirAnswer ¶
type Request ¶
type Request struct {
ID uint64 `json:"id"`
Op string `json:"op"`
Proto int `json:"proto,omitempty"`
OS string `json:"os,omitempty"`
API string `json:"api,omitempty"`
Node uint64 `json:"node,omitempty"`
Dir uint64 `json:"dir,omitempty"`
ToDir uint64 `json:"to_dir,omitempty"`
Name []byte `json:"name,omitempty"`
ToName []byte `json:"to_name,omitempty"`
Target []byte `json:"target,omitempty"`
Type string `json:"type,omitempty"`
Mode *uint32 `json:"mode,omitempty"`
Size *int64 `json:"size,omitempty"`
Atime *Time `json:"atime,omitempty"`
Mtime *Time `json:"mtime,omitempty"`
UID *uint32 `json:"uid,omitempty"`
GID *uint32 `json:"gid,omitempty"`
Flags *uint32 `json:"flags,omitempty"`
// Delete makes xattr_set remove the attribute.
Delete bool `json:"delete,omitempty"`
Offset int64 `json:"offset,omitempty"`
Length int `json:"length,omitempty"`
// Want names the attributes of an answer. Cookie, Verifier and Budget belong to readdir.
Want []string `json:"want,omitempty"`
Cookie uint64 `json:"cookie,omitempty"`
Verifier uint64 `json:"verifier,omitempty"`
Budget int `json:"budget,omitempty"`
}
Request is the header of a request. A field that the op does not use is absent. A name, a link target and a xattr name are bytes, and JSON writes bytes as base64.