fuseutil

package
v0.0.0-...-edf18a6 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 7 Imported by: 254

Documentation

Overview

Types and functions that make it easier to work with package fuse.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFileSystemServer

func NewFileSystemServer(fs FileSystem) fuse.Server

Create a fuse.Server that handles ops by calling the associated FileSystem method.Respond with the resulting error. Unsupported ops are responded to directly with ENOSYS.

Each call to a FileSystem method (except ForgetInode) is made on its own goroutine, and is free to block. ForgetInode may be called synchronously, and should not depend on calls to other methods being received concurrently.

(It is safe to naively process ops concurrently because the kernel guarantees to serialize operations that the user expects to happen in order, cf. http://goo.gl/jnkHPO, fuse-devel thread "Fuse guarantees on concurrent requests").

func WriteDirent

func WriteDirent(buf []byte, d Dirent) (n int)

Write the supplied directory entry into the given buffer in the format expected in fuseops.ReadFileOp.Data, returning the number of bytes written. Return zero if the entry would not fit.

Types

type Dirent

type Dirent struct {
	// The (opaque) offset within the directory file of the entry following this
	// one. See notes on fuseops.ReadDirOp.Offset for details.
	Offset fuseops.DirOffset

	// The inode of the child file or directory, and its name within the parent.
	Inode fuseops.InodeID
	Name  string

	// The type of the child. The zero value (DT_Unknown) is legal, but means
	// that the kernel will need to call GetAttr when the type is needed.
	Type DirentType
}

A struct representing an entry within a directory file, describing a child. See notes on fuseops.ReadDirOp and on WriteDirent for details.

type DirentType

type DirentType uint32
const (
	DT_Unknown   DirentType = 0
	DT_Socket    DirentType = syscall.DT_SOCK
	DT_Link      DirentType = syscall.DT_LNK
	DT_File      DirentType = syscall.DT_REG
	DT_Block     DirentType = syscall.DT_BLK
	DT_Directory DirentType = syscall.DT_DIR
	DT_Char      DirentType = syscall.DT_CHR
	DT_FIFO      DirentType = syscall.DT_FIFO
)

type FileSystem

type FileSystem interface {
	StatFS(context.Context, *fuseops.StatFSOp) error
	LookUpInode(context.Context, *fuseops.LookUpInodeOp) error
	GetInodeAttributes(context.Context, *fuseops.GetInodeAttributesOp) error
	SetInodeAttributes(context.Context, *fuseops.SetInodeAttributesOp) error
	ForgetInode(context.Context, *fuseops.ForgetInodeOp) error
	BatchForget(context.Context, *fuseops.BatchForgetOp) error
	MkDir(context.Context, *fuseops.MkDirOp) error
	MkNode(context.Context, *fuseops.MkNodeOp) error
	CreateFile(context.Context, *fuseops.CreateFileOp) error
	CreateLink(context.Context, *fuseops.CreateLinkOp) error
	CreateSymlink(context.Context, *fuseops.CreateSymlinkOp) error
	Rename(context.Context, *fuseops.RenameOp) error
	RmDir(context.Context, *fuseops.RmDirOp) error
	Unlink(context.Context, *fuseops.UnlinkOp) error
	OpenDir(context.Context, *fuseops.OpenDirOp) error
	ReadDir(context.Context, *fuseops.ReadDirOp) error
	ReleaseDirHandle(context.Context, *fuseops.ReleaseDirHandleOp) error
	OpenFile(context.Context, *fuseops.OpenFileOp) error
	ReadFile(context.Context, *fuseops.ReadFileOp) error
	WriteFile(context.Context, *fuseops.WriteFileOp) error
	SyncFile(context.Context, *fuseops.SyncFileOp) error
	FlushFile(context.Context, *fuseops.FlushFileOp) error
	ReleaseFileHandle(context.Context, *fuseops.ReleaseFileHandleOp) error
	ReadSymlink(context.Context, *fuseops.ReadSymlinkOp) error
	RemoveXattr(context.Context, *fuseops.RemoveXattrOp) error
	GetXattr(context.Context, *fuseops.GetXattrOp) error
	ListXattr(context.Context, *fuseops.ListXattrOp) error
	SetXattr(context.Context, *fuseops.SetXattrOp) error
	Fallocate(context.Context, *fuseops.FallocateOp) error

	// Regard all inodes (including the root inode) as having their lookup counts
	// decremented to zero, and clean up any resources associated with the file
	// system. No further calls to the file system will be made.
	Destroy()
}

An interface with a method for each op type in the fuseops package. This can be used in conjunction with NewFileSystemServer to avoid writing a "dispatch loop" that switches on op types, instead receiving typed method calls directly.

The FileSystem implementation should not call Connection.Reply, instead returning the error with which the caller should respond.

See NotImplementedFileSystem for a convenient way to embed default implementations for methods you don't care about.

type NotImplementedFileSystem

type NotImplementedFileSystem struct {
}

A FileSystem that responds to all ops with fuse.ENOSYS. Embed this in your struct to inherit default implementations for the methods you don't care about, ensuring your struct will continue to implement FileSystem even as new methods are added.

func (*NotImplementedFileSystem) BatchForget

func (*NotImplementedFileSystem) CreateFile

func (*NotImplementedFileSystem) Destroy

func (fs *NotImplementedFileSystem) Destroy()

func (*NotImplementedFileSystem) Fallocate

func (*NotImplementedFileSystem) FlushFile

func (*NotImplementedFileSystem) ForgetInode

func (*NotImplementedFileSystem) GetInodeAttributes

func (fs *NotImplementedFileSystem) GetInodeAttributes(
	ctx context.Context,
	op *fuseops.GetInodeAttributesOp) error

func (*NotImplementedFileSystem) GetXattr

func (*NotImplementedFileSystem) ListXattr

func (*NotImplementedFileSystem) LookUpInode

func (*NotImplementedFileSystem) MkDir

func (*NotImplementedFileSystem) MkNode

func (*NotImplementedFileSystem) OpenDir

func (*NotImplementedFileSystem) OpenFile

func (*NotImplementedFileSystem) ReadDir

func (*NotImplementedFileSystem) ReadFile

func (*NotImplementedFileSystem) ReleaseDirHandle

func (fs *NotImplementedFileSystem) ReleaseDirHandle(
	ctx context.Context,
	op *fuseops.ReleaseDirHandleOp) error

func (*NotImplementedFileSystem) ReleaseFileHandle

func (fs *NotImplementedFileSystem) ReleaseFileHandle(
	ctx context.Context,
	op *fuseops.ReleaseFileHandleOp) error

func (*NotImplementedFileSystem) RemoveXattr

func (*NotImplementedFileSystem) Rename

func (*NotImplementedFileSystem) RmDir

func (*NotImplementedFileSystem) SetInodeAttributes

func (fs *NotImplementedFileSystem) SetInodeAttributes(
	ctx context.Context,
	op *fuseops.SetInodeAttributesOp) error

func (*NotImplementedFileSystem) SetXattr

func (*NotImplementedFileSystem) StatFS

func (*NotImplementedFileSystem) SyncFile

func (*NotImplementedFileSystem) WriteFile

Jump to

Keyboard shortcuts

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