fskitwire

package
v0.46.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	Proto = 1
	// MaxFrame is the size of a whole frame, the four bytes of total included.
	MaxFrame = 9 << 20
	MaxBody  = 8 << 20
)
View Source
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"
)
View Source
const (
	TypeFile    = "file"
	TypeDir     = "dir"
	TypeSymlink = "symlink"
	TypeSocket  = "socket"
)
View Source
const (
	EntryBase = 24
	AttrCost  = 128
)

Variables

View Source
var (
	ErrFrameTooLarge = errors.New("fskitwire: frame over 9 MiB")
	ErrBodyTooLarge  = errors.New("fskitwire: body over 8 MiB")
	ErrMalformed     = errors.New("fskitwire: malformed frame")
)

Functions

func EntryCost

func EntryCost(name int, attrs bool) int

func ReadFrame

func ReadFrame(r io.Reader) (header, body []byte, err error)

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

func SocketName(workspace string) string

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.

func WriteFrame

func WriteFrame(w io.Writer, header, body []byte) error

WriteFrame writes one frame. It writes nothing when a limit fails.

Types

type Answer

type Answer struct {
	ID uint64 `json:"id"`
}

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"`
}

func (Attr) Only

func (a Attr) Only(want []string) Attr

type AttrAnswer

type AttrAnswer struct {
	ID   uint64 `json:"id"`
	Attr Attr   `json:"attr"`
}

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 DirEntry

type DirEntry struct {
	Name   []byte `json:"name"`
	Type   string `json:"type"`
	Ino    uint64 `json:"ino"`
	Cookie uint64 `json:"cookie"`
	Attr   *Attr  `json:"attr,omitempty"`
}

type ErrAnswer

type ErrAnswer struct {
	ID  uint64 `json:"id"`
	Err Code   `json:"err"`
	Msg string `json:"msg"`
}

type HelloAnswer

type HelloAnswer struct {
	ID       uint64 `json:"id"`
	Proto    int    `json:"proto"`
	Boot     string `json:"boot"`
	MaxFrame int    `json:"max_frame"`
	Root     uint64 `json:"root"`
}

type NamesAnswer

type NamesAnswer struct {
	ID    uint64   `json:"id"`
	Names [][]byte `json:"names"`
}

type NodeAnswer

type NodeAnswer struct {
	ID   uint64 `json:"id"`
	Node uint64 `json:"node"`
	Attr Attr   `json:"attr"`
}

type ReadDirAnswer

type ReadDirAnswer struct {
	ID       uint64     `json:"id"`
	Verifier uint64     `json:"verifier"`
	Entries  []DirEntry `json:"entries"`
	EOF      bool       `json:"eof"`
}

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.

type SetAttrAnswer

type SetAttrAnswer struct {
	ID       uint64   `json:"id"`
	Attr     Attr     `json:"attr"`
	Consumed []string `json:"consumed"`
}

type TargetAnswer

type TargetAnswer struct {
	ID     uint64 `json:"id"`
	Target []byte `json:"target"`
}

type Time

type Time [2]int64

func TimeOf

func TimeOf(ns int64) Time

func (Time) Nanos

func (t Time) Nanos() int64

type WriteAnswer

type WriteAnswer struct {
	ID uint64 `json:"id"`
	N  int    `json:"n"`
}

Jump to

Keyboard shortcuts

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