filesystem

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const EntryCount = apis.MaxChunkSize / EntrySize
View Source
const EntrySize = 32
View Source
const MaxName = EntrySize - 8 - 1
View Source
const MaxSymLinkSize = 1024

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	MountPoint          string
	ClientConfig        client.Configuration
	SyncServerAddresses []apis.ServerAddress
}

type Entry

type Entry struct {
	Index int // not stored in encoding; broadly optional
	Type  NodeType
	Name  string
	Chunk apis.ChunkNum
}

func (*Entry) IsOk

func (e *Entry) IsOk() bool

type File

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

func (*File) Read

func (f *File) Read(offset uint32, length uint32) ([]byte, error)

func (*File) Release

func (f *File) Release()

func (*File) Size

func (f *File) Size() (uint32, error)

TODO: use caching... we're allowed to, since we have a read lock!

func (*File) Truncate

func (f *File) Truncate(nlength uint32) error

func (*File) Write

func (f *File) Write(offset uint32, data []byte) error

type Filesystem

type Filesystem interface {
	Mkdir(path string) error
	Rename(source string, dest string) error
	Unlink(path string) error
	Rmdir(path string) error
	OpenRead(path string) (ReadOnlyFile, error)
	// Note: this does *NOT* truncate by default!
	OpenWrite(path string, create bool, exclusive bool) (WritableFile, error)
	SymLink(source string, dest string) error
	Stat(path string) (os.FileInfo, error)
	ReadLink(path string) (string, error)
	Truncate(path string, length uint32) error
	ListDir(path string) ([]string, error)

	GetTraverser() (*Traverser, error)
}

func NewFilesystem

func NewFilesystem(client apis.Client, sync apis.SyncServer) Filesystem

func NewFilesystemClient

func NewFilesystemClient(config Configuration) (Filesystem, error)

type FilesystemSync

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

func (*FilesystemSync) GetRoot

func (f *FilesystemSync) GetRoot() (apis.ChunkNum, error)

note: the root chunk never changes

func (*FilesystemSync) ReadLockChunk

func (f *FilesystemSync) ReadLockChunk(chunk apis.ChunkNum) (Unlocker, error)

func (*FilesystemSync) WriteLockChunk

func (f *FilesystemSync) WriteLockChunk(chunk apis.ChunkNum) (Unlocker, error)

type NodeType

type NodeType uint8
const (
	NONEXISTENT NodeType = iota
	FILE        NodeType = iota
	DIRECTORY   NodeType = iota
	SYMLINK     NodeType = iota
)

type ReadOnlyFile

type ReadOnlyFile interface {
	io.Reader
	io.ReaderAt
	io.Seeker
	io.Closer
}

type Reference

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

func (*Reference) LookupDir

func (r *Reference) LookupDir(name string) (*Reference, error)

func (*Reference) LookupFile

func (r *Reference) LookupFile(name string) (*File, error)
func (r *Reference) LookupSymLink(name string) (string, error)

func (*Reference) MoveTo

func (r *Reference) MoveTo(target *Reference, sourcename string, targetname string) error

func (*Reference) NewDir

func (r *Reference) NewDir(name string) error

func (*Reference) NewFile

func (r *Reference) NewFile(name string) error
func (r *Reference) NewSymLink(name string, target string) error

func (*Reference) Release

func (r *Reference) Release()

func (*Reference) Remove

func (r *Reference) Remove(name string, rmdir bool) error

func (*Reference) Rename

func (r *Reference) Rename(sourcename string, targetname string) error

func (*Reference) Stat

func (r *Reference) Stat(name string) (NodeType, error)

type Traverser

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

func (Traverser) PathDir

func (t Traverser) PathDir(path string) (*Reference, error)

func (Traverser) Root

func (t Traverser) Root() (*Reference, error)

type Unlocker

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

func (*Unlocker) Elevate

func (u *Unlocker) Elevate() (Unlocker, error)

func (*Unlocker) Ensure

func (u *Unlocker) Ensure() error

func (*Unlocker) EnsureWrite

func (u *Unlocker) EnsureWrite() error

func (*Unlocker) Unlock

func (u *Unlocker) Unlock()

type WritableFile

type WritableFile interface {
	io.Reader
	io.ReaderAt
	io.Writer
	io.WriterAt
	io.Seeker
	io.Closer
	Truncate(uint64) error
}

func WithErroringWrite

func WithErroringWrite(i ReadOnlyFile) WritableFile

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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