gotfs

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxBlobSize             = 1 << 21
	DefaultMinBlobSizeData         = 1 << 12
	DefaultAverageBlobSizeData     = 1 << 20
	DefaultAverageBlobSizeMetadata = 1 << 13
)
View Source
const MaxPathLen = 4096
View Source
const Sep = '/'

Variables

View Source
var File_models_proto protoreflect.FileDescriptor

Functions

func Dump

func Dump(ctx context.Context, s Store, root Root, w io.Writer) error

func Equal

func Equal(a, b Root) bool

func IsEmpty

func IsEmpty(root Root) bool

func Populate

func Populate(ctx context.Context, s Store, root Root, mdSet, dataSet cadata.Set) error

Populate adds the ID for all the metadata blobs to mdSet and all the data blobs to dataSet

func SpanForPath

func SpanForPath(p string) gotkv.Span

func Sync

func Sync(ctx context.Context, dst, src Store, root Root, syncData func(ref gdat.Ref) error) error

Sync ensures dst has all the data reachable from root dst and src should both be metadata stores. copyData will be called to sync metadata

Types

type Builder

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

Builder manages building a filesystem.

func (*Builder) BeginFile

func (b *Builder) BeginFile(p string, mode os.FileMode) error

BeginFile creates a metadata entry for a regular file at p and directs Write calls to the content of that file.

func (*Builder) Finish

func (b *Builder) Finish() (*Root, error)

Finish closes the builder and returns the Root to the filesystem. Finish is idempotent, and is safe to call multiple times. Not calling finish is not an error, the builder does not allocate resources other than memory.

func (*Builder) IsFinished

func (b *Builder) IsFinished() bool

func (*Builder) Mkdir

func (b *Builder) Mkdir(p string, mode os.FileMode) error

Mkdir creates a directory for p.

func (*Builder) Write

func (b *Builder) Write(data []byte) (int, error)

func (*Builder) WriteExtents

func (b *Builder) WriteExtents(ctx context.Context, exts []*Extent) error

WriteExtents adds extents to the current file. Rechunking is avoided, but the last Extent could be short, so it must be rechunked regardless. WriteExtents is useful for efficiently joining Extents from disjoint regions of a file. See also: Operator.CreateExtents

type DirEnt

type DirEnt struct {
	Name string
	Mode os.FileMode
}

type Extent

type Extent struct {
	Ref    []byte `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"`
	Length uint32 `protobuf:"varint,2,opt,name=length,proto3" json:"length,omitempty"`
	Offset uint32 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"`
	// contains filtered or unexported fields
}

func (*Extent) Descriptor deprecated

func (*Extent) Descriptor() ([]byte, []int)

Deprecated: Use Extent.ProtoReflect.Descriptor instead.

func (*Extent) GetLength

func (x *Extent) GetLength() uint32

func (*Extent) GetOffset

func (x *Extent) GetOffset() uint32

func (*Extent) GetRef

func (x *Extent) GetRef() []byte

func (*Extent) ProtoMessage

func (*Extent) ProtoMessage()

func (*Extent) ProtoReflect

func (x *Extent) ProtoReflect() protoreflect.Message

func (*Extent) Reset

func (x *Extent) Reset()

func (*Extent) String

func (x *Extent) String() string

type ExtentDiffFn

type ExtentDiffFn = func(p string, offset uint64, left, right *Extent) error

type FileReader

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

func (*FileReader) Read

func (fr *FileReader) Read(buf []byte) (int, error)

type Metadata

type Metadata struct {
	Mode   uint32            `protobuf:"varint,1,opt,name=mode,proto3" json:"mode,omitempty"`
	Labels map[string]string `` /* 153-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*Metadata) Descriptor deprecated

func (*Metadata) Descriptor() ([]byte, []int)

Deprecated: Use Metadata.ProtoReflect.Descriptor instead.

func (*Metadata) GetLabels

func (x *Metadata) GetLabels() map[string]string

func (*Metadata) GetMode

func (x *Metadata) GetMode() uint32

func (*Metadata) ProtoMessage

func (*Metadata) ProtoMessage()

func (*Metadata) ProtoReflect

func (x *Metadata) ProtoReflect() protoreflect.Message

func (*Metadata) Reset

func (x *Metadata) Reset()

func (*Metadata) String

func (x *Metadata) String() string

type MetadataDiffFn

type MetadataDiffFn = func(p string, left, right *Metadata) error

type Operator

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

func NewOperator

func NewOperator(opts ...Option) Operator

func (*Operator) AddPrefix

func (o *Operator) AddPrefix(root Root, p string) Root

func (*Operator) Check

func (o *Operator) Check(ctx context.Context, s Store, root Root, checkData func(ref gdat.Ref) error) error

func (*Operator) CreateExtents

func (o *Operator) CreateExtents(ctx context.Context, ds Store, r io.Reader) ([]*Extent, error)

CreateExtents returns a list of extents created from r

func (*Operator) CreateFile

func (o *Operator) CreateFile(ctx context.Context, ms, ds Store, x Root, p string, r io.Reader) (*Root, error)

CreateFile creates a file at p with data from r If there is an entry at p CreateFile returns an error ms is the store used for metadata ds is the store used for data.

func (*Operator) CreateFileRoot

func (o *Operator) CreateFileRoot(ctx context.Context, ms, ds Store, r io.Reader) (*Root, error)

CreateFileRoot creates a new filesystem with the contents read from r at the root

func (*Operator) CreateFileRootFromExtents

func (o *Operator) CreateFileRootFromExtents(ctx context.Context, ms, ds Store, exts []*Extent) (*Root, error)

func (*Operator) Diff

func (o *Operator) Diff(ctx context.Context, s cadata.Store, lRoot, rRoot Root, metaFn MetadataDiffFn, extentFn ExtentDiffFn) error

func (*Operator) DiffPaths

func (o *Operator) DiffPaths(ctx context.Context, s cadata.Store, prev, next Root, addFn, delFn func(string)) error

DiffPaths calls addFn for additions in next, but not prev, and delFn for paths in prev, but not next.

func (*Operator) ForEach

func (o *Operator) ForEach(ctx context.Context, s cadata.Store, root Root, p string, fn func(p string, md *Metadata) error) error

func (*Operator) ForEachFile

func (o *Operator) ForEachFile(ctx context.Context, s cadata.Store, root Root, p string, fn func(p string, md *Metadata) error) error

func (*Operator) GetDirMetadata

func (o *Operator) GetDirMetadata(ctx context.Context, s Store, x Root, p string) (*Metadata, error)

GetDirMetadata returns directory metadata at p if it exists, and errors otherwise

func (*Operator) GetFileMetadata

func (o *Operator) GetFileMetadata(ctx context.Context, s Store, x Root, p string) (*Metadata, error)

GetFileMetadata returns the file metadata at p if it exists, and errors otherwise

func (*Operator) GetMetadata

func (o *Operator) GetMetadata(ctx context.Context, s Store, x Root, p string) (*Metadata, error)

GetMetadata retrieves the metadata at p if it exists and errors otherwise

func (*Operator) Graft

func (o *Operator) Graft(ctx context.Context, ms, ds cadata.Store, root Root, p string, branch Root) (*Root, error)

Graft places branch at p in root. If p == "" then branch is returned unaltered.

func (*Operator) Mkdir

func (o *Operator) Mkdir(ctx context.Context, s Store, x Root, p string) (*Root, error)

Mkdir creates a directory at path p

func (*Operator) MkdirAll

func (o *Operator) MkdirAll(ctx context.Context, s Store, x Root, p string) (*Root, error)

MkdirAll creates the directory p and any of p's ancestors if necessary.

func (*Operator) NewBuilder

func (o *Operator) NewBuilder(ctx context.Context, ms, ds Store) *Builder

func (*Operator) NewEmpty

func (o *Operator) NewEmpty(ctx context.Context, s Store) (*Root, error)

NewEmpty creates a new filesystem with nothing in it.

func (*Operator) NewReader

func (o *Operator) NewReader(ctx context.Context, ms, ds Store, x Root, p string) *FileReader

func (*Operator) PutMetadata

func (o *Operator) PutMetadata(ctx context.Context, s Store, x Root, p string, md *Metadata) (*Root, error)

PutMetadata assigns metadata to p

func (*Operator) ReadDir

func (o *Operator) ReadDir(ctx context.Context, s Store, x Root, p string, fn func(e DirEnt) error) error

ReadDir calls fn for every child of the directory at p.

func (*Operator) ReadFileAt

func (o *Operator) ReadFileAt(ctx context.Context, ms, ds Store, x Root, p string, start uint64, buf []byte) (int, error)

ReadFileAt fills `buf` with data in the file at `p` starting at offset `start`

func (*Operator) RemoveAll

func (o *Operator) RemoveAll(ctx context.Context, s Store, x Root, p string) (*Root, error)

func (*Operator) Select

func (o *Operator) Select(ctx context.Context, s cadata.Store, root Root, p string) (*Root, error)

Select returns a new root containing everything under p, shifted to the root.

func (*Operator) SizeOfFile

func (o *Operator) SizeOfFile(ctx context.Context, s Store, x Root, p string) (uint64, error)

SizeOfFile returns the size of the file at p in bytes.

func (*Operator) Splice

func (o *Operator) Splice(ctx context.Context, ms, ds Store, segs []Segment) (*Root, error)

type Option

type Option func(o *Operator)

func WithContentCacheSize

func WithContentCacheSize(n int) Option

WithContentCacheSize sets the size of the cache for raw data

func WithMetaCacheSize

func WithMetaCacheSize(n int) Option

WithMetaCacheSize sets the size of the cache for metadata

func WithSeed

func WithSeed(seed *[32]byte) Option

type Ref

type Ref = gotkv.Ref

type Root

type Root = gotkv.Root

type Segment

type Segment struct {
	Span gotkv.Span
	Root Root
}

Segment is a span of a GotFS instance.

func ChangesOnBase

func ChangesOnBase(base Root, changes []Segment) []Segment

ChangesOnBase inserts segments from base between each Segment in changes.

func (Segment) String

func (s Segment) String() string

type Store

type Store = gotkv.Store

Jump to

Keyboard shortcuts

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