fs

package
v0.0.0-...-cdd27d5 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

fs package implements fuse.RawFileSystem on top of the other modules of go-tfhfs project.

The low-level API is more or less mandatory as e.g. list of files from huge directory is not feasible to provide in one chunk, and we want to have fairly dynamic relationship with the tree.

fstest provides (raw) fuse filesystem code

Tests are mostly written with DummyUser module which provides ~os module functionality across the fuse APIs. This does NOT intentionally really mount the filesystem for obvious reasons.

(parallel testing, arbitrary permission simulation with nonroot user)

Index

Constants

View Source
const (
	// MV_NEW indicates the preference in src->dst tree delta
	MV_NEW mergeVerdict = iota

	// MV_EXISTING indicates the preference of status quo
	MV_EXISTING

	// MV_NONE indicates preference for getting rid of ALL data
	// for particular inode.
	MV_NONE
)
View Source
const (
	BDT_EXTENT ibtree.BlockDataType = 0x42
)
View Source
const EmbeddedSize = 1024

Variables

This section is empty.

Functions

func BytesToNodeData

func BytesToNodeData(bd []byte) *ibtree.NodeData

func IterateInoSubTypeKeys

func IterateInoSubTypeKeys(t *ibtree.Transaction, ino uint64, bst BlockSubType, keycb func(key BlockKey) bool)

func MergeTo3

func MergeTo3(tr *hugger.Transaction, src, dst *ibtree.Node, local bool)

MergeTo3 performs 3-way merge. It iterates changes in orig -> new, and then compares them with the current state in the tree that is handed in as the Transaction. If local is set, all changes are assumed to be dealt with on per-leaf node difference basis. Otherwise metadata of the particular inode is used to determine which version of the truth is preferrable.

Types

type BlockKey

type BlockKey string

func NewBlockKey

func NewBlockKey(ino uint64, st BlockSubType, data string) BlockKey

func NewBlockKeyDirFilename

func NewBlockKeyDirFilename(ino uint64, filename string) BlockKey

func NewBlockKeyNameBlock

func NewBlockKeyNameBlock(name, id string) BlockKey

func NewBlockKeyNameEnd

func NewBlockKeyNameEnd(name string) BlockKey

func NewBlockKeyOffset

func NewBlockKeyOffset(ino uint64, offset uint64) BlockKey

func NewBlockKeyReverseDirFilename

func NewBlockKeyReverseDirFilename(ino, dirIno uint64, filename string) BlockKey

func (BlockKey) Filename

func (self BlockKey) Filename() string

func (BlockKey) IB

func (self BlockKey) IB() ibtree.Key

func (BlockKey) Ino

func (self BlockKey) Ino() uint64

func (BlockKey) String

func (self BlockKey) String() string

func (BlockKey) SubType

func (self BlockKey) SubType() BlockSubType

func (BlockKey) SubTypeData

func (self BlockKey) SubTypeData() string

type BlockSubType

type BlockSubType byte
const (
	// should not occur in real world
	// (can be used as end-of-range marker given ino+1 + this OST)
	BST_NONE BlockSubType = 0

	// value: InodeMeta
	BST_META BlockSubType = 1

	// key: k (string->bytes), value: data (bytes)
	BST_XATTR BlockSubType = 2

	// key: fnvhash.name, value: 8 byte inode
	BST_DIR_NAME2INODE BlockSubType = 0x10

	// key: inode (dir it is in) . filename
	BST_FILE_INODEFILENAME BlockSubType = 0x20
	// key: 8 byte offset, value: data block id (for data @ offset)
	BST_FILE_OFFSET2EXTENT BlockSubType = 0x21

	// should not occur in real world
	// (can be used as end-of-range marker)
	BST_LAST = 0x2f

	BST_NAMEHASH_NAME_BLOCK BlockSubType = 0x30
)

func (*BlockSubType) DecodeMsg

func (z *BlockSubType) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable We treat empty fields as if we read a Nil from the wire.

func (BlockSubType) EncodeMsg

func (z BlockSubType) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (BlockSubType) MarshalMsg

func (z BlockSubType) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (BlockSubType) Msgsize

func (z BlockSubType) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*BlockSubType) UnmarshalMsg

func (z *BlockSubType) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

func (*BlockSubType) UnmarshalMsgWithCfg

func (z *BlockSubType) UnmarshalMsgWithCfg(bts []byte, cfg *msgp.RuntimeConfig) (o []byte, err error)

type FSUser

type FSUser struct {
	fuse.InHeader
	// contains filtered or unexported fields
}

func NewFSUser

func NewFSUser(fs *Fs) *FSUser

func (*FSUser) Chmod

func (self *FSUser) Chmod(path string, mode os.FileMode) (err error)

Chmod is clone of os.Chmod

func (*FSUser) Chown

func (self *FSUser) Chown(path string, uid, gid int) (err error)

Chown is clone of os.Chown

func (*FSUser) Chtimes

func (self *FSUser) Chtimes(path string, atime time.Time, mtime time.Time) (err error)

Chtimes is clone of os.Chtimes

func (*FSUser) GetXAttr

func (self *FSUser) GetXAttr(path, attr string) (b []byte, err error)
func (self *FSUser) Link(oldpath, newpath string) (err error)

Link is clone of os.Link

func (*FSUser) ListDir

func (self *FSUser) ListDir(name string) (ret []string, err error)

func (*FSUser) ListXAttr

func (self *FSUser) ListXAttr(path string) (s []string, err error)

func (*FSUser) Mkdir

func (self *FSUser) Mkdir(path string, perm os.FileMode) (err error)

MkDir is clone of os.MkDir

func (*FSUser) OpenFile

func (self *FSUser) OpenFile(path string, flag uint32, perm uint32) (f *fsFile, err error)

func (*FSUser) ReadDir

func (self *FSUser) ReadDir(dirname string) (ret []os.FileInfo, err error)

ReadDir is clone of ioutil.ReadDir

func (self *FSUser) Readlink(path string) (s string, err error)

Readlink is clone of os.Readlink

func (*FSUser) Remove

func (self *FSUser) Remove(path string) (err error)

Remove is clone of os.Remove

func (*FSUser) RemoveXAttr

func (self *FSUser) RemoveXAttr(path, attr string) (err error)

func (*FSUser) Rename

func (self *FSUser) Rename(oldpath, newpath string) (err error)

Rename is clone of os.Rename

func (*FSUser) SetXAttr

func (self *FSUser) SetXAttr(path, attr string, data []byte) (err error)

func (*FSUser) Stat

func (self *FSUser) Stat(path string) (fi os.FileInfo, err error)

Stat is clone of os.Stat

func (*FSUser) String

func (self *FSUser) String() string
func (self *FSUser) Symlink(oldpath, newpath string) (err error)

Symlink is clone of os.Symlink

type Fs

type Fs struct {
	Ops fsOps

	hugger.Hugger
	// contains filtered or unexported fields
}

func NewFs

func NewFs(st *storage.Storage, RootName string, cacheSize int) *Fs

func (*Fs) AddFile

func (self *Fs) AddFile(file *inodeFH)

func (*Fs) Close

func (self *Fs) Close()

func (*Fs) CreateInode

func (self *Fs) CreateInode() *inode

func (*Fs) Flush

func (self *Fs) Flush()

func (*Fs) GetFileByFh

func (self *Fs) GetFileByFh(fh uint64) *inodeFH

func (*Fs) GetInode

func (self *Fs) GetInode(ino uint64) *inode

func (*Fs) Init

func (self *Fs) Init(fs *Fs)

func (*Fs) ListDir

func (self *Fs) ListDir(ino uint64) (ret []string)

ListDir provides testing utility as output of ReadDir/ReadDirPlus is binary garbage and I am too lazy to write a decoder for it.

func (*Fs) RemoveFile

func (self *Fs) RemoveFile(file *inodeFH)

func (*Fs) WithoutParallelWrites

func (self *Fs) WithoutParallelWrites(cb func())

WithoutParallelWrites ensures the data being read is entirely consistent. This means that there is no locks on filehandles, and that all pending data has been written to Storage (which will persist it eventually).

type InodeMeta

type InodeMeta struct {
	InodeMetaData
	Data []byte `zid:"10"`
}

func (*InodeMeta) DecodeMsg

func (z *InodeMeta) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable We treat empty fields as if we read a Nil from the wire.

func (*InodeMeta) EncodeMsg

func (z *InodeMeta) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*InodeMeta) MarshalMsg

func (z *InodeMeta) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*InodeMeta) Msgsize

func (z *InodeMeta) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*InodeMeta) UnmarshalMsg

func (z *InodeMeta) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

func (*InodeMeta) UnmarshalMsgWithCfg

func (z *InodeMeta) UnmarshalMsgWithCfg(bts []byte, cfg *msgp.RuntimeConfig) (o []byte, err error)

type InodeMetaAtomicPointer

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

InodeMetaAtomicPointer provides typesafe access to type

func (*InodeMetaAtomicPointer) Get

func (self *InodeMetaAtomicPointer) Get() *InodeMeta

func (*InodeMetaAtomicPointer) Set

func (self *InodeMetaAtomicPointer) Set(value *InodeMeta)

func (*InodeMetaAtomicPointer) SetIfEqualTo

func (self *InodeMetaAtomicPointer) SetIfEqualTo(newAtomicPointer, oldAtomicPointer *InodeMeta) bool

type InodeMetaData

type InodeMetaData struct {
	// int64 st_ino = 1;
	// ^ part of key, not data
	StMode    uint32 `zid:"0"`
	StRdev    uint32 `zid:"1"`
	StUid     uint32 `zid:"2"`
	StGid     uint32 `zid:"3"`
	StAtimeNs uint64 `zid:"4"`
	StCtimeNs uint64 `zid:"5"`
	StMtimeNs uint64 `zid:"6"`
	StSize    uint64 `zid:"7"`
	StNlink   uint32 `zid:"8"`

	// What is ino of our parent (directory-only)
	ParentIno uint64 `zid:"9"`
}

func (*InodeMetaData) DecodeMsg

func (z *InodeMetaData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable We treat empty fields as if we read a Nil from the wire.

func (*InodeMetaData) EncodeMsg

func (z *InodeMetaData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*InodeMetaData) IsDir

func (self *InodeMetaData) IsDir() bool

func (*InodeMetaData) MarshalMsg

func (z *InodeMetaData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*InodeMetaData) Msgsize

func (z *InodeMetaData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*InodeMetaData) SetATimeNow

func (self *InodeMetaData) SetATimeNow()

func (*InodeMetaData) SetCTimeNow

func (self *InodeMetaData) SetCTimeNow()

func (*InodeMetaData) SetCreateIn

func (self *InodeMetaData) SetCreateIn(input *fuse.CreateIn)

func (*InodeMetaData) SetMTimeNow

func (self *InodeMetaData) SetMTimeNow()

func (*InodeMetaData) SetMkdirIn

func (self *InodeMetaData) SetMkdirIn(input *fuse.MkdirIn)

func (*InodeMetaData) SetMknodIn

func (self *InodeMetaData) SetMknodIn(input *fuse.MknodIn)

func (*InodeMetaData) UnmarshalMsg

func (z *InodeMetaData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

func (*InodeMetaData) UnmarshalMsgWithCfg

func (z *InodeMetaData) UnmarshalMsgWithCfg(bts []byte, cfg *msgp.RuntimeConfig) (o []byte, err error)

Jump to

Keyboard shortcuts

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