fs9

package module
v0.0.0-...-a2565bd Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

README

fs9

layered merging file system

WORK IN PROGRESS

Features
  • Snapshot
  • Content defined chunking
  • Compression
  • Encryption

Layer:

  • Memory
  • Disk
  • S3

Interface:

  • webdav
  • fuse
  • 9p

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadArgument  = errors.New("bad argument")
	ErrCannotLink   = errors.New("cannot link")
	ErrCannotRemove = errors.New("cannot remove")
	ErrClosed       = errors.New("closed")
	ErrDirNotEmpty  = errors.New("dir not empty")
	ErrFileExisted  = errors.New("file existed")
	ErrFileNotFound = errors.New("file not found")
	ErrImmutable    = errors.New("immutable")
	ErrInvalidName  = errors.New("invalid name")
	ErrInvalidPath  = errors.New("invalid path")
	ErrNameMismatch = errors.New("name mismatch")
	ErrNoPermission = errors.New("no permission")
	ErrNodeNotFound = errors.New("node not found")
	ErrOutOfBounds  = errors.New("out of bounds")
	ErrTypeMismatch = errors.New("type mismatch")
)

Functions

func NameToPath

func NameToPath(name string) (ret []string, err error)

Types

type ChangeOption

type ChangeOption func(*changeSpec)

func OptNoFollow

func OptNoFollow(b bool) ChangeOption

type DirEntry

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

func (DirEntry) Dump

func (d DirEntry) Dump(w io.Writer, level int)

func (DirEntry) Equal

func (d DirEntry) Equal(n2 Node) bool

func (DirEntry) Info

func (d DirEntry) Info() (fs.FileInfo, error)

func (DirEntry) IsDir

func (d DirEntry) IsDir() bool

func (DirEntry) KeyRange

func (d DirEntry) KeyRange() (Key, Key)

func (DirEntry) Merge

func (d DirEntry) Merge(ctx Scope, node2 Node) (Node, error)

TODO 3-way merge

func (DirEntry) Mutate

func (d DirEntry) Mutate(ctx Scope, path KeyPath, fn func(Node) (Node, error)) (Node, error)

func (DirEntry) Name

func (d DirEntry) Name() string

func (DirEntry) Type

func (d DirEntry) Type() fs.FileMode

type ExtFileInfo

type ExtFileInfo struct {
	UserID     int
	GroupID    int
	AccessTime time.Time
}

type FS

type FS interface {
	fs.FS

	ChangeMode(name string, mode fs.FileMode, options ...ChangeOption) error
	ChangeOwner(name string, uid, gid int, options ...ChangeOption) error
	ChangeTimes(name string, atime time.Time, mtime time.Time, options ...ChangeOption) error
	Create(name string) (Handle, error)
	Link(oldname, newname string) error
	MakeDir(path string) error
	MakeDirAll(path string) error
	OpenHandle(path string, options ...OpenOption) (Handle, error)
	ReadLink(name string) (string, error)
	Remove(path string, options ...RemoveOption) error
	Rename(oldpath, newpath string) error
	SymLink(oldname, newname string) error
	Truncate(name string, size int64) error
	Stat(name string) (fs.FileInfo, error)
	LinkStat(name string) (fs.FileInfo, error)

	Snapshot() FS
}

type File

type File struct {
	ID         FileID
	IsDir      bool
	Size       int64
	Mode       fs.FileMode
	ModTime    time.Time
	Subs       *NodeSet // name -> NamedFileID
	Symlink    string
	Content    []byte //TODO sharded bytes slice
	UserID     int
	GroupID    int
	AccessTime time.Time
	// contains filtered or unexported fields
}

func NewFile

func NewFile(isDir bool) *File

func (*File) Clone

func (f *File) Clone() *File

func (File) Dump

func (f File) Dump(w io.Writer, level int)

func (File) Equal

func (f File) Equal(n2 Node) bool

func (File) KeyRange

func (f File) KeyRange() (Key, Key)

func (*File) Merge

func (f *File) Merge(ctx Scope, node2 Node) (Node, error)

TODO 3-way merge

func (*File) Mutate

func (f *File) Mutate(
	ctx Scope,
	path KeyPath,
	fn func(Node) (Node, error),
) (
	retNode Node,
	err error,
)

func (File) ReadAt

func (f File) ReadAt(buf []byte, offset int64) (n int, err error)

func (File) Stat

func (f File) Stat() (FileInfo, error)

func (*File) WriteAt

func (f *File) WriteAt(data []byte, offset int64) (*File, int, error)

type FileID

type FileID uint64

func (FileID) Cmp

func (f FileID) Cmp(i any) int

type FileInfo

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

func (FileInfo) IsDir

func (f FileInfo) IsDir() bool

func (FileInfo) ModTime

func (f FileInfo) ModTime() time.Time

func (FileInfo) Mode

func (f FileInfo) Mode() fs.FileMode

func (FileInfo) Name

func (f FileInfo) Name() string

func (FileInfo) Size

func (f FileInfo) Size() int64

func (FileInfo) Sys

func (f FileInfo) Sys() any

type FileMap

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

FileMap is sharded map of FileID to *File

func NewFileMap

func NewFileMap(level int, shardKey uint8) *FileMap

func (*FileMap) Clone

func (f *FileMap) Clone() *FileMap

func (FileMap) Dump

func (f FileMap) Dump(w io.Writer, level int)

func (*FileMap) Equal

func (f *FileMap) Equal(n2 Node) bool

func (FileMap) GetPath

func (f FileMap) GetPath(id FileID) (path KeyPath)

func (FileMap) KeyRange

func (f FileMap) KeyRange() (Key, Key)

func (*FileMap) Merge

func (f *FileMap) Merge(ctx Scope, node2 Node) (Node, error)

TODO 3-way merge

func (*FileMap) Mutate

func (f *FileMap) Mutate(
	ctx Scope,
	path KeyPath,
	fn func(Node) (Node, error),
) (
	retNode Node,
	err error,
)

type Handle

type Handle interface {
	fs.File
	fs.ReadDirFile
	io.Seeker
	io.Writer
	io.ReaderAt

	ChangeMode(mode fs.FileMode) error
	ChangeOwner(uid, gid int) error
	ChangeTimes(atime time.Time, mtime time.Time) error
	Name() string
	Sync() error
	Truncate(size int64) error
}

type Key

type Key = it.Key

type KeyPath

type KeyPath = it.KeyPath

type MemFS

type MemFS struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMemFS

func NewMemFS() *MemFS

func (*MemFS) ChangeMode

func (m *MemFS) ChangeMode(name string, mode fs.FileMode, options ...ChangeOption) (err error)

func (*MemFS) ChangeOwner

func (m *MemFS) ChangeOwner(name string, uid, gid int, options ...ChangeOption) (err error)

func (*MemFS) ChangeTimes

func (m *MemFS) ChangeTimes(name string, atime, mtime time.Time, options ...ChangeOption) (err error)

func (*MemFS) Create

func (m *MemFS) Create(name string) (handle Handle, err error)
func (m *MemFS) Link(oldname, newname string) (err error)

func (*MemFS) LinkStat

func (m *MemFS) LinkStat(name string) (info fs.FileInfo, err error)

func (*MemFS) MakeDir

func (m *MemFS) MakeDir(p string) (err error)

func (*MemFS) MakeDirAll

func (m *MemFS) MakeDirAll(p string) (err error)

func (*MemFS) NewReadBatch

func (m *MemFS) NewReadBatch() (
	batch *MemFSReadBatch,
	done func(*error),
)

func (*MemFS) NewWriteBatch

func (m *MemFS) NewWriteBatch() (
	batch *MemFSWriteBatch,
	done func(*error),
)

func (*MemFS) Open

func (m *MemFS) Open(path string) (fs.File, error)

func (*MemFS) OpenHandle

func (m *MemFS) OpenHandle(name string, options ...OpenOption) (handle Handle, err error)
func (m *MemFS) ReadLink(name string) (link string, err error)

func (*MemFS) Remove

func (m *MemFS) Remove(name string, options ...RemoveOption) (err error)

func (*MemFS) Rename

func (m *MemFS) Rename(oldname, newname string) (err error)

func (*MemFS) Snapshot

func (m *MemFS) Snapshot() FS

func (*MemFS) Stat

func (m *MemFS) Stat(name string) (info fs.FileInfo, err error)
func (m *MemFS) SymLink(oldname, newname string) (err error)

func (*MemFS) Truncate

func (m *MemFS) Truncate(name string, size int64) (err error)

type MemFSReadBatch

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

func (*MemFSReadBatch) GetDirEntryByPath

func (m *MemFSReadBatch) GetDirEntryByPath(parent *DirEntry, path []string, followSymlink bool) (entry *DirEntry, err error)

func (*MemFSReadBatch) GetFileByID

func (m *MemFSReadBatch) GetFileByID(id FileID) (*File, error)

func (*MemFSReadBatch) GetFileByName

func (m *MemFSReadBatch) GetFileByName(name string, followSymlink bool) (*File, error)

func (*MemFSReadBatch) GetFileIDByPath

func (m *MemFSReadBatch) GetFileIDByPath(path []string, followSymlink bool) (FileID, error)

func (*MemFSReadBatch) LinkStat

func (m *MemFSReadBatch) LinkStat(name string) (fs.FileInfo, error)

func (*MemFSReadBatch) NewHandle

func (m *MemFSReadBatch) NewHandle(name string, id FileID) *MemHandle
func (m *MemFSReadBatch) ReadLink(name string) (link string, err error)

func (*MemFSReadBatch) Stat

func (m *MemFSReadBatch) Stat(name string) (fs.FileInfo, error)

type MemFSWriteBatch

type MemFSWriteBatch struct {
	MemFSReadBatch
}

func (*MemFSWriteBatch) ChangeMode

func (m *MemFSWriteBatch) ChangeMode(name string, mode fs.FileMode, options ...ChangeOption) error

func (*MemFSWriteBatch) ChangeOwner

func (m *MemFSWriteBatch) ChangeOwner(name string, uid, gid int, options ...ChangeOption) error

func (*MemFSWriteBatch) ChangeTimes

func (m *MemFSWriteBatch) ChangeTimes(name string, atime, mtime time.Time, options ...ChangeOption) error

func (*MemFSWriteBatch) Create

func (m *MemFSWriteBatch) Create(name string) (Handle, error)
func (m *MemFSWriteBatch) Link(oldname, newname string) error

func (*MemFSWriteBatch) MakeDir

func (m *MemFSWriteBatch) MakeDir(p string) error

func (*MemFSWriteBatch) MakeDirAll

func (m *MemFSWriteBatch) MakeDirAll(p string) error

func (*MemFSWriteBatch) OpenHandle

func (m *MemFSWriteBatch) OpenHandle(name string, options ...OpenOption) (handle Handle, err error)

func (*MemFSWriteBatch) Remove

func (m *MemFSWriteBatch) Remove(name string, options ...RemoveOption) error

func (*MemFSWriteBatch) Rename

func (m *MemFSWriteBatch) Rename(oldname string, newname string) error
func (m *MemFSWriteBatch) SymLink(oldname, newname string) error

func (*MemFSWriteBatch) Truncate

func (m *MemFSWriteBatch) Truncate(name string, size int64) error

type MemHandle

type MemHandle struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*MemHandle) ChangeMode

func (h *MemHandle) ChangeMode(mode fs.FileMode) (err error)

func (*MemHandle) ChangeOwner

func (h *MemHandle) ChangeOwner(uid, gid int) (err error)

func (*MemHandle) ChangeTimes

func (h *MemHandle) ChangeTimes(atime, mtime time.Time) (err error)

func (*MemHandle) Close

func (m *MemHandle) Close() error

func (*MemHandle) Name

func (m *MemHandle) Name() string

func (*MemHandle) Read

func (m *MemHandle) Read(buf []byte) (n int, err error)

func (*MemHandle) ReadAt

func (m *MemHandle) ReadAt(buf []byte, offset int64) (n int, err error)

func (*MemHandle) ReadDir

func (m *MemHandle) ReadDir(n int) (ret []fs.DirEntry, err error)

func (*MemHandle) Seek

func (m *MemHandle) Seek(offset int64, whence int) (n int64, err error)

func (*MemHandle) Stat

func (m *MemHandle) Stat() (fs.FileInfo, error)

func (*MemHandle) Sync

func (h *MemHandle) Sync() error

func (*MemHandle) Truncate

func (h *MemHandle) Truncate(size int64) (err error)

func (*MemHandle) Write

func (m *MemHandle) Write(data []byte) (n int, err error)

type Node

type Node = it.Node

type NodeSet

type NodeSet = it.NodeSet

type OpenOption

type OpenOption func(*openSpec)

func OptCreate

func OptCreate(b bool) OpenOption

type RemoveOption

type RemoveOption func(*removeSpec)

func OptAll

func OptAll(b bool) RemoveOption

type Scope

type Scope = dscope.Scope

type Sink

type Sink = pp.Sink

type Src

type Src = pp.Src

Jump to

Keyboard shortcuts

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