fuseutil

package
v0.0.0-...-887b5f6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2019 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 7 Imported by: 0

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 intto 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
	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

	// 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) CreateFile

func (fs *NotImplementedFileSystem) CreateFile(
	ctx context.Context,
	op *fuseops.CreateFileOp) (err error)
func (fs *NotImplementedFileSystem) CreateLink(
	ctx context.Context,
	op *fuseops.CreateLinkOp) (err error)
func (fs *NotImplementedFileSystem) CreateSymlink(
	ctx context.Context,
	op *fuseops.CreateSymlinkOp) (err error)

func (*NotImplementedFileSystem) Destroy

func (fs *NotImplementedFileSystem) Destroy()

func (*NotImplementedFileSystem) FlushFile

func (fs *NotImplementedFileSystem) FlushFile(
	ctx context.Context,
	op *fuseops.FlushFileOp) (err error)

func (*NotImplementedFileSystem) ForgetInode

func (fs *NotImplementedFileSystem) ForgetInode(
	ctx context.Context,
	op *fuseops.ForgetInodeOp) (err error)

func (*NotImplementedFileSystem) GetInodeAttributes

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

func (*NotImplementedFileSystem) GetXattr

func (fs *NotImplementedFileSystem) GetXattr(
	ctx context.Context,
	op *fuseops.GetXattrOp) (err error)

func (*NotImplementedFileSystem) ListXattr

func (fs *NotImplementedFileSystem) ListXattr(
	ctx context.Context,
	op *fuseops.ListXattrOp) (err error)

func (*NotImplementedFileSystem) LookUpInode

func (fs *NotImplementedFileSystem) LookUpInode(
	ctx context.Context,
	op *fuseops.LookUpInodeOp) (err error)

func (*NotImplementedFileSystem) MkDir

func (fs *NotImplementedFileSystem) MkDir(
	ctx context.Context,
	op *fuseops.MkDirOp) (err error)

func (*NotImplementedFileSystem) MkNode

func (fs *NotImplementedFileSystem) MkNode(
	ctx context.Context,
	op *fuseops.MkNodeOp) (err error)

func (*NotImplementedFileSystem) OpenDir

func (fs *NotImplementedFileSystem) OpenDir(
	ctx context.Context,
	op *fuseops.OpenDirOp) (err error)

func (*NotImplementedFileSystem) OpenFile

func (fs *NotImplementedFileSystem) OpenFile(
	ctx context.Context,
	op *fuseops.OpenFileOp) (err error)

func (*NotImplementedFileSystem) ReadDir

func (fs *NotImplementedFileSystem) ReadDir(
	ctx context.Context,
	op *fuseops.ReadDirOp) (err error)

func (*NotImplementedFileSystem) ReadFile

func (fs *NotImplementedFileSystem) ReadFile(
	ctx context.Context,
	op *fuseops.ReadFileOp) (err error)
func (fs *NotImplementedFileSystem) ReadSymlink(
	ctx context.Context,
	op *fuseops.ReadSymlinkOp) (err error)

func (*NotImplementedFileSystem) ReleaseDirHandle

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

func (*NotImplementedFileSystem) ReleaseFileHandle

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

func (*NotImplementedFileSystem) RemoveXattr

func (fs *NotImplementedFileSystem) RemoveXattr(
	ctx context.Context,
	op *fuseops.RemoveXattrOp) (err error)

func (*NotImplementedFileSystem) Rename

func (fs *NotImplementedFileSystem) Rename(
	ctx context.Context,
	op *fuseops.RenameOp) (err error)

func (*NotImplementedFileSystem) RmDir

func (fs *NotImplementedFileSystem) RmDir(
	ctx context.Context,
	op *fuseops.RmDirOp) (err error)

func (*NotImplementedFileSystem) SetInodeAttributes

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

func (*NotImplementedFileSystem) SetXattr

func (fs *NotImplementedFileSystem) SetXattr(
	ctx context.Context,
	op *fuseops.SetXattrOp) (err error)

func (*NotImplementedFileSystem) StatFS

func (fs *NotImplementedFileSystem) StatFS(
	ctx context.Context,
	op *fuseops.StatFSOp) (err error)

func (*NotImplementedFileSystem) SyncFile

func (fs *NotImplementedFileSystem) SyncFile(
	ctx context.Context,
	op *fuseops.SyncFileOp) (err error)
func (fs *NotImplementedFileSystem) Unlink(
	ctx context.Context,
	op *fuseops.UnlinkOp) (err error)

func (*NotImplementedFileSystem) WriteFile

func (fs *NotImplementedFileSystem) WriteFile(
	ctx context.Context,
	op *fuseops.WriteFileOp) (err error)

Jump to

Keyboard shortcuts

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