meta

package
v0.0.0-...-f899974 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeFile      = 1 // type for regular file
	TypeDirectory = 2 // type for directory
)
View Source
const (
	// SetAttrMode is a mask to update a attribute of node
	SetAttrMode = 1 << iota
	SetAttrUID
	SetAttrGID
	SetAttrSize
	SetAttrAtime
	SetAttrMtime
	SetAttrCtime
	SetAttrAtimeNow
	SetAttrMtimeNow
)
View Source
const MaxName = 255
View Source
const SkipDirMtime time.Duration = 100 * time.Millisecond

Variables

This section is empty.

Functions

This section is empty.

Types

type Attr

type Attr struct {
	Typ       uint8  // type of a node
	Mode      uint16 // permission mode
	Rdev      uint32 // device number
	Atime     int64  // last access time
	Mtime     int64  // last modified time
	Ctime     int64  // last change time for meta
	Atimensec uint32 // nanosecond part of atime
	Mtimensec uint32 // nanosecond part of mtime
	Ctimensec uint32 // nanosecond part of ctime
	Nlink     uint32 // number of links (sub-directories or hardlinks)
	Length    uint64 // length of regular file

	Parent Ino  // inode of parent; 0 means tracked by parentKey (for hardlinks)
	Full   bool // the attributes are completed or not
}

Attr represents attributes of a node.

func (Attr) SMode

func (a Attr) SMode() uint32

SMode is the file mode including type and unix permission.

type Entry

type Entry struct {
	Inode Ino
	Name  []byte
	Key   []byte
	Attr  *Attr
}

Entry is an entry inside a directory.

type Format

type Format struct {
	Name      string
	UUID      string
	Storage   string
	BlockSize int
	Capacity  uint64 `json:",omitempty"`
}

func (*Format) String

func (f *Format) String() string

type Ino

type Ino uint64
const RootInode Ino = 1
const SharedInode Ino = 2

func (Ino) IsNormal

func (i Ino) IsNormal() bool

func (Ino) IsValid

func (i Ino) IsValid() bool

func (Ino) String

func (i Ino) String() string

type Meta

type Meta interface {
	// Name of database
	Name() string
	// Init is used to initialize a meta service.
	Init(format *Format) error
	// Shutdown close current database connections.
	Shutdown()
	Load() (*Format, error)
	GetNextInode(ctx context.Context, lastIno *Ino) error
	GetUserId(username string, uid *uint32) error
	GetUserPublicKey(username string, pubKey *[]byte) error

	// Lookup returns the inode and attributes for the given entry in a directory.
	Lookup(ctx context.Context, userId uint32, parent, inode Ino, attr *Attr) syscall.Errno
	// GetAttr returns the attributes for given node.
	GetAttr(ctx context.Context, inode Ino, attr *Attr) syscall.Errno
	// SetAttr updates the attributes for given node.
	SetAttr(ctx context.Context, inode Ino, in *fuse.SetAttrIn, attr *Attr) syscall.Errno
	// Unlink removes a file entry from a directory.
	// The file will be deleted if it's not linked by any entries and not open by any sessions.
	Unlink(ctx context.Context, parent, inode Ino) syscall.Errno
	// Rmdir removes an empty sub-directory.
	Rmdir(ctx context.Context, parent, inode Ino) syscall.Errno
	// Readdir returns all entries for given directory, which include attributes if plus is true.
	Readdir(ctx context.Context, inode Ino, userId uint32, entries *[]*Entry) syscall.Errno
	Mknod(ctx context.Context, parent Ino, _type uint8, mode, id uint32, inode *Ino, name, key []byte, attr *Attr) syscall.Errno
	// Write put a slice of data on top of the given chunk.
	Write(ctx context.Context, inode uint64, data []byte, off int64) syscall.Errno
	GetKey(ctx context.Context, inode Ino, key *[]byte) syscall.Errno
	GetSharedKey(ctx context.Context, userdId uint32, inode Ino, key *[]byte) syscall.Errno

	CheckUser(username string) error
	CreateUser(username string, password, salt, rootKey, privKey, pubKey []byte) error
	VerifyUser(username string, password []byte, rootKey, privKey *[]byte) error
	GetSalt(username string, salt *[]byte) error
	ChangePassword(username string, password, salt, rootKey, privKey []byte) error
	ShareDir(user uint32, inode Ino, name, key []byte) error
	UnshareDir(user uint32, inode Ino) error
	GetPathKey(inode Ino, keys *[][]byte) error
}

Meta is a interface for a meta service for file system.

func RegisterMeta

func RegisterMeta(addr string) Meta

Jump to

Keyboard shortcuts

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