fusefs

package
v0.0.0-...-c426cd6 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultChunkSizeBytes defines the default for newly created shade.File(s)
	DefaultChunkSizeBytes = 16 * 1024 * 1024
)

Functions

This section is empty.

Types

type InodeMap

type InodeMap struct {
	sync.RWMutex // protects acess to all fields of the struct
	// contains filtered or unexported fields
}

InodeMap provides a mapping from fuse.Node to and from the Path that it corresponds to.

func NewInodeMap

func NewInodeMap() *InodeMap

NewInodeMap returns an initialized InodeMap. Initially, it knows of only the path to the root inode.

func (*InodeMap) FromPath

func (im *InodeMap) FromPath(p string) uint64

FromPath returns the inode allocated for a given path. If no inode has been allocated for that path yet, it allocates a new one and returns it.

func (*InodeMap) Release

func (im *InodeMap) Release(inode uint64)

Release deletes the mapping from an inode to a given path.

func (*InodeMap) ToPath

func (im *InodeMap) ToPath(inode uint64) (string, error)

ToPath returns the path which was allocated to inode. If inode has not yet been allocated, ToPath returns an error.

type Node

type Node struct {
	// Filename is the complete path to a node, with no leading or trailing
	// slash.
	Filename     string
	Filesize     int64 // in bytes
	ModifiedTime time.Time
	// Deleted indicates the file was Deleted at ModifiedTime.  NodeByPath
	// responds exactly as if the node did not exist.
	Deleted   bool
	Sha256sum []byte // the sha of the full shade.File
	// Children is a map indicating the presence of a node immediately
	// below the current node in the tree.  The key is only the name of that
	// node, a relative path, not fully qualified.
	// TODO(asjoyner): use a struct{} here for efficiency?
	// unsafe.Sizeof indicates it would save 1 byte per FS entry
	Children map[string]bool
}

Node is a very compact representation of a shade.File. It can also be used to represent a sythetic directory, for tree traversal.

func (*Node) Synthetic

func (n *Node) Synthetic() bool

Synthetic returns true for synthetically created directories.

type Server

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

Server holds the state about the fuse connection

func New

func New(client drive.Client, conn *fuse.Conn, refresh *time.Ticker) (*Server, error)

New returns a Server which will service fuse requests arriving on conn, based on data retrieved from drive.Client. It is ready to serve requests when Server.conn.Ready is closed. The cached view of files is updated every refresh.

func (*Server) Refresh

func (sc *Server) Refresh() error

Refresh updates the view of the underlying drive.Client.

func (*Server) Serve

func (sc *Server) Serve() error

Serve receives and dispatches Requests from the kernel

type Tree

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

Tree is a representation of all files known to the provided drive.Client. It initially downlods, then periodically refreshes, the set of files by calling ListFiles and GetChunk. It presents methods to query for what file object currently describes what path, and can return a Node or shade.File struct representing that node in the tree.

func NewTree

func NewTree(client drive.Client, refresh *time.Ticker) (*Tree, error)

NewTree queries client to discover all the shade.File(s). It returns a Tree object which is ready to answer questions about the nodes in the file tree. If the initial query fails, an error is returned instead.

func (*Tree) Create

func (t *Tree) Create(filename string) Node

Create adds a new shade.File node to the tree

func (*Tree) FileByNode

func (t *Tree) FileByNode(n Node) (*shade.File, error)

FileByNode returns the full shade.File object for a given node.

func (*Tree) HasChild

func (t *Tree) HasChild(parent, child string) bool

HasChild returns true if child exists immediately below parent in the file tree.

func (*Tree) Mkdir

func (t *Tree) Mkdir(dir string) Node

Mkdir provides a way to create synthetic directories, for the Mkdir Fuse op

func (*Tree) NodeByPath

func (t *Tree) NodeByPath(p string) (Node, error)

NodeByPath returns a Node describing the given path.

func (*Tree) NumNodes

func (t *Tree) NumNodes() int

NumNodes returns the number of nodes (files + synthetic directories) in the system.

func (*Tree) Refresh

func (t *Tree) Refresh() error

Refresh updates the cached view of the Tree by calling ListFiles and processing the result.

func (*Tree) Update

func (t *Tree) Update(n Node)

Update accepts a replacement shade.File node

Jump to

Keyboard shortcuts

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