casfuse

package
v0.1.23-oss Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPathLen = 4096

Variables

View Source
var (
	ErrEntryNotFound   = fs.ErrNotExist
	ErrNotADirectory   = errors.New("entry is not a directory")
	ErrNotAFile        = errors.New("entry is not a file")
	ErrEntryExists     = fs.ErrExist
	ErrDirNotEmpty     = syscall.ENOTEMPTY
	ErrNotSupported    = errors.New("not supported")
	ErrUnknownXattr    = errors.New("unknown xattr")
	ErrInvalidXattrVal = errors.New("invalid xattr value")
	ErrInvalidPath     = errors.New("invalid path")

	ErrTryAgain             = errors.New("try again")
	ErrInvalidState         = errors.New("invalid state")
	ErrDirty                = errors.New("dirty")
	ErrNotDirty             = errors.New("not dirty")
	ErrSnapshotStuck        = errors.New("snapshot stuck")
	ErrNotCASNode           = errors.New("not cas node")
	ErrInvalidSession       = errors.New("invalid session")
	ErrSessionAlreadyExists = errors.New("session already exists")
)
View Source
var (
	ErrInvalid  = os.ErrInvalid
	ErrNotExist = os.ErrNotExist
)

Want to return os errors from these functions

View Source
var ContextKey = &contextKeyType{}

ContextKey the context key is used by the fuse implementations to send caller data through the context

Functions

func Chmod

func Chmod(ctx context.Context, dir Dentry, name string, mode cas.FileMode) error

func DentryHash

func DentryHash(dir Dentry, name string) string

func Lstat

func Lstat(ctx context.Context, dir Dentry, name string) (cas.FileInfo, error)

func NewCASFSAPI

func NewCASFSAPI(mountPath string, api API, fs FS) fs.FS

func NewFSAPI

func NewFSAPI(fs FS) *namei

func OpenFile

func OpenFile(ctx context.Context, dir Dentry, name string, flags int, perm cas.FileMode) (fs.FSFile, error)
func Readlink(ctx context.Context, dir Dentry, name string) (string, error)

func Remove

func Remove(ctx context.Context, dir Dentry, name string) error

func Rename

func Rename(ctx context.Context, oldDir Dentry, oldName string, newDir Dentry, newName string) error

func RenameDentries

func RenameDentries(oldEntry, newEntry Dentry)

Types

type API

type API interface {
	Type(inode Inode) cas.FileMode
	// Check if the path has been modified locally and not committed to the store
	Dirty(inode Inode) (bool, error)
	// DirList get a directory listing hash
	DirList(ctx context.Context, inode Inode) (hash.Hash, error)
	// Loaded check if the content at the path has been loaded locally
	Loaded(inode Inode) (bool, error)
	// Excluded check if the path is excluded from parent's hash calculation
	Excluded(inode Inode) (bool, error)
	// SetExcluded sets the excluded attribute
	SetExcluded(inode Inode, val bool) error
	// Hash if dirty the contents are stored to the store with a new hash value
	Hash(ctx context.Context, inode Inode) (hash.Hash, error)
	// SetHash set the hash of the path, only valid if the path is not yet loaded.
	SetHash(inode Inode, hash hash.Hash) error
	// HashStat get the hash,mode, and size of the path
	HashStat(ctx context.Context, inode Inode) (*fs.HashStat, error)
	// HashSet get the hash,size of a file at the given path.
	HashSize(ctx context.Context, inode Inode) (hash.Hash, int64, error)
	// SetHashSize set the hash,size for a file at the given path, only valid if the path
	// is not yet loaded.
	SetHashSize(inode Inode, hash hash.Hash, size int64) error
	// SetDeepTree set the deep tree hash for the given directory path, only valid if
	// the path is not yet loaded.  After setting the deep tree hash all children
	// nodes can answer Stat() call without accessing the backend.
	SetDeepTree(inode Inode, hash hash.Hash) error
	// Debug get the debug attribute of the path.
	Debug(inode Inode) (bool, error)
	// SetDebug set dynamic debug for the given path
	SetDebug(inode Inode, val bool) error

	// Create control directory under path
	CreateControl(ctx context.Context, inode Inode, directory string) error
	// Create a non-cas ramfs type directory under the input path
	CreateRamfs(ctx context.Context, inode Inode, directory string) error
	// Create GIT project under given path
	CreateGit(ctx context.Context, inode Inode, directory, head string) error
	// Create GIT objects only under the given path
	CreateGitObjects(ctx context.Context, inode Inode, directory string) error
	// Status of FS
	Status() (*fs.Status, error)
}

Provide an internal CASFS API corresponding to the cas fs api using the internal inodes instead of paths

type ContextValue

type ContextValue struct {
	Pid uint32
}

type Dcache

type Dcache interface {
	Add(d Dentry) error
	Create(dir Dentry, name string) Dentry
	Lookup(dir Dentry, name string) Dentry
	Remove(d Dentry)
	Rename(oldEntry, newEntry Dentry)
	Path(d Dentry) string
	NotifyChange(d Dentry)
	RegisterWatch(DcacheWatch)
}

func CreateDcache

func CreateDcache() Dcache

type DcacheWatch

type DcacheWatch interface {
	Change(Dentry)
}

type Dentry

type Dentry interface {
	Name() string
	Parent() Dentry
	Path() string
	Instantiate(inode Inode)
	IsHashed() bool
	Inode() Inode
	Get()
	Put()
	Ext() any
	SetExt(any)
	Dcache() Dcache
}

func CreateFile

func CreateFile(ctx context.Context, dir Dentry, name string, mode cas.FileMode) (Dentry, error)

func CreateTmpFile

func CreateTmpFile(ctx context.Context, dir Dentry, mode cas.FileMode) (Dentry, error)
func Link(ctx context.Context, dir Dentry, name string, target Dentry) (Dentry, error)

func Lookup

func Lookup(ctx context.Context, dir Dentry, name string) Dentry

func LookupNegative

func LookupNegative(ctx context.Context, dir Dentry, name string) (Dentry, error)

func LookupPositive

func LookupPositive(ctx context.Context, dir Dentry, name string) (Dentry, error)

func Mkdir

func Mkdir(ctx context.Context, dir Dentry, name string, mode cas.FileMode) (Dentry, error)

func Mknod

func Mknod(ctx context.Context, dir Dentry, name string, mode cas.FileMode, rDev int) (Dentry, error)

func Resolve

func Resolve(ctx context.Context, d Dentry, p string) (Dentry, error)
func Symlink(ctx context.Context, dir Dentry, name, target string) (Dentry, error)

type DentryState

type DentryState uint32
const (
	DentryStateHashed DentryState = 1 << iota
)

type Dir

type Dir interface {
	Inode

	Entries(ctx context.Context) (map[string]Inode, error)
	Lookup(ctx context.Context, dentry Dentry) (Inode, error)
	Mkdir(ctx context.Context, dentry Dentry, perm cas.FileMode) (Inode, error)
	Remove(ctx context.Context, dentry Dentry) error
	CreateTmpFile(ctx context.Context, dentry Dentry, mode cas.FileMode) (Inode, error)
	CreateFile(ctx context.Context, dentry Dentry, mode cas.FileMode) (Inode, error)
	Symlink(ctx context.Context, dentry Dentry, target string) (Inode, error)
	Rename(ctx context.Context, oldDentry Dentry, newDirInode Inode, newDentry Dentry) error
	Mknod(ctx context.Context, dentry Dentry, mode cas.FileMode, rDev int) (Inode, error)
	Link(ctx context.Context, source Dentry, dentry Dentry) (Inode, error)
}

Dir directory interface

type ExtType

type ExtType int

Extension types

const (
	CASExt  ExtType = iota // Content Addressable
	GitExt                 // GIT
	CASTap                 // Tapping
	FuseExt                // Fuse control

)

type FS

type FS interface {
	Ready() bool
	SetReady(bool)

	Root() Dentry
	SetRoot(node Inode) error
	// Try to remove hasher here
	Hasher() hash.Hasher
	GetExt(key ExtType) interface{}
	RegisterExt(key ExtType, any interface{})
	Dcache() Dcache
}

type Fifo

type Fifo interface {
	Inode
}

Fifo interface

type File

type File interface {
	Inode
	SetAttr(ctx context.Context, dentry Dentry, size *int64, atime, mtime *time.Time, mode *cas.FileMode)
	Open(ctx context.Context, dentry Dentry, truncate, readOnly bool) error
	Close() error
	Fsync(ctx context.Context) error
	ReadAt(p []byte, off int64) (int, error)
	WriteAt(p []byte, off int64) (int, error)
	Release(ctx context.Context) error
	Flush(ctx context.Context) error
	Fallocate(ctx context.Context, mode int, offset, len int64) error
	Lseek(ctx context.Context, offset int64, whence uint32) (int64, error)
	Poll(ctx context.Context) (bool, bool)
}

File interface

type FileInfo

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

Provide cas.FileInfo interface

func (*FileInfo) IsDir

func (n *FileInfo) IsDir() bool

func (*FileInfo) ModTime

func (n *FileInfo) ModTime() time.Time

func (*FileInfo) Mode

func (n *FileInfo) Mode() cas.FileMode

func (*FileInfo) Name

func (n *FileInfo) Name() string

func (*FileInfo) Size

func (n *FileInfo) Size() int64

func (*FileInfo) Sys

func (n *FileInfo) Sys() any

type Inode

type Inode interface {
	Mode() cas.FileMode
	Attr(ctx context.Context, dentry Dentry) *NodeAttr
	Ino() uint64
	Size() int64

	CanCache() bool

	FS() FS
}

Inode interface for all supported nodes

type NodeAttr

type NodeAttr struct {
	Ino       uint64
	Size      int64
	Blocks    uint64
	Ctime     time.Time
	Atime     time.Time
	Mtime     time.Time
	Mode      cas.FileMode
	Nlinks    uint32
	Uid       uint32
	Gid       uint32
	Rdev      uint32
	BlockSize uint32
}

NodeAttr stat attributes of a file/dir/fifo/...

type Socket

type Socket interface {
	Inode
}

Socket interface

type SymLink interface {
	Inode

	Target(ctx context.Context, dentry Dentry) (string, error)
	SetTarget(ctx context.Context, target string)
}

Symlink interface

Jump to

Keyboard shortcuts

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