hookfs

package
v0.0.0-...-6d943f5 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const LogLevelMax = 2

LogLevelMax is the maximum log level

View Source
const LogLevelMin = 0

LogLevelMin is the minimum log level

Variables

This section is empty.

Functions

func LogLevel

func LogLevel() int

LogLevel gets the log level.

func NotOk

func NotOk(tb testing.TB, err error)

NotOk fails the test if an err is nil.

func Ok

func Ok(tb testing.TB, err error)

Ok fails the test if an err is not nil.

func SetLogLevel

func SetLogLevel(level log.Level)

SetLogLevel sets the log level. newLevel must be >= LogLevelMin, and <= LogLevelMax.

Types

type Hook

type Hook interface{}

Hook is the base interface for user-written hooks.

You have to implement HookXXX (e.g. HookOnOpen, HookOnRead, HookOnWrite, ..) interfaces.

type HookContext

type HookContext interface{}

HookContext is the context objects for interaction between prehooks and posthooks.

type HookFs

type HookFs struct {
	Original   string
	Mountpoint string
	FsName     string
	// contains filtered or unexported fields
}

HookFs is the object hooking the fs.

func NewHookFs

func NewHookFs(original string, mountpoint string, hook Hook) (*HookFs, error)

NewHookFs creates a new HookFs object

func (*HookFs) Access

func (h *HookFs) Access(name string, mode uint32, context *fuse.Context) fuse.Status

Access implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) Chmod

func (h *HookFs) Chmod(name string, mode uint32, context *fuse.Context) fuse.Status

Chmod implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) Chown

func (h *HookFs) Chown(name string, uid uint32, gid uint32, context *fuse.Context) fuse.Status

Chown implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) Create

func (h *HookFs) Create(name string, flags uint32, mode uint32, context *fuse.Context) (nodefs.File, fuse.Status)

Create implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) GetAttr

func (h *HookFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status)

GetAttr implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) GetXAttr

func (h *HookFs) GetXAttr(name string, attribute string, context *fuse.Context) ([]byte, fuse.Status)

GetXAttr implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (h *HookFs) Link(oldName string, newName string, context *fuse.Context) fuse.Status

Link implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) ListXAttr

func (h *HookFs) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status)

ListXAttr implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) Mkdir

func (h *HookFs) Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status

Mkdir implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) Mknod

func (h *HookFs) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status

Mknod implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) OnMount

func (h *HookFs) OnMount(nodeFs *pathfs.PathNodeFs)

OnMount implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) OnUnmount

func (h *HookFs) OnUnmount()

OnUnmount implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) Open

func (h *HookFs) Open(name string, flags uint32, context *fuse.Context) (nodefs.File, fuse.Status)

Open implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) OpenDir

func (h *HookFs) OpenDir(name string, context *fuse.Context) ([]fuse.DirEntry, fuse.Status)

OpenDir implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (h *HookFs) Readlink(name string, context *fuse.Context) (string, fuse.Status)

Readlink implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) RemoveXAttr

func (h *HookFs) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status

RemoveXAttr implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) Rename

func (h *HookFs) Rename(oldName string, newName string, context *fuse.Context) fuse.Status

Rename implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) Rmdir

func (h *HookFs) Rmdir(name string, context *fuse.Context) fuse.Status

Rmdir implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) Serve

func (h *HookFs) Serve() error

Serve starts the server (blocking).

func (*HookFs) ServeAsync

func (h *HookFs) ServeAsync() (*fuse.Server, error)

Serve initiates the FUSE loop. Normally, callers should run Serve() and wait for it to exit, but tests will want to run this in a goroutine.

func (*HookFs) SetDebug

func (h *HookFs) SetDebug(debug bool)

SetDebug implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) SetXAttr

func (h *HookFs) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status

SetXAttr implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) StatFs

func (h *HookFs) StatFs(name string) *fuse.StatfsOut

StatFs implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) String

func (h *HookFs) String() string

String implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (h *HookFs) Symlink(value string, linkName string, context *fuse.Context) fuse.Status

Symlink implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) Truncate

func (h *HookFs) Truncate(name string, size uint64, context *fuse.Context) fuse.Status

Truncate implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (h *HookFs) Unlink(name string, context *fuse.Context) fuse.Status

Unlink implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

func (*HookFs) Utimens

func (h *HookFs) Utimens(name string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) fuse.Status

Utimens implements hanwen/go-fuse/fuse/pathfs.FileSystem. You are not expected to call h manually.

type HookOnFsync

type HookOnFsync interface {
	// if hooked is true, the real fsync() would not be called
	PreFsync(path string, flags uint32) (hooked bool, ctx HookContext, err error)
	PostFsync(realRetCode int32, prehookCtx HookContext) (hooked bool, err error)
}

HookOnFsync is called on fsync. This also implements Hook.

type HookOnMkdir

type HookOnMkdir interface {
	// if hooked is true, the real mkdir() would not be called
	PreMkdir(path string, mode uint32) (hooked bool, ctx HookContext, err error)
	PostMkdir(realRetCode int32, prehookCtx HookContext) (hooked bool, err error)
}

HookOnMkdir is called on mkdir. This also implements Hook.

type HookOnOpen

type HookOnOpen interface {
	// if hooked is true, the real open() would not be called
	PreOpen(path string, flags uint32) (hooked bool, ctx HookContext, err error)
	PostOpen(realRetCode int32, prehookCtx HookContext) (hooked bool, err error)
}

HookOnOpen is called on open. This also implements Hook.

type HookOnOpenDir

type HookOnOpenDir interface {
	// if hooked is true, the real opendir() would not be called
	PreOpenDir(path string) (hooked bool, ctx HookContext, err error)
	PostOpenDir(realRetCode int32, prehookCtx HookContext) (hooked bool, err error)
}

HookOnOpenDir is called on opendir. This also implements Hook.

type HookOnRead

type HookOnRead interface {
	// if hooked is true, the real read() would not be called
	PreRead(path string, length int64, offset int64) (buf []byte, hooked bool, ctx HookContext, err error)
	PostRead(realRetCode int32, realBuf []byte, prehookCtx HookContext) (buf []byte, hooked bool, err error)
}

HookOnRead is called on read. This also implements Hook.

type HookOnRename

type HookOnRename interface {
	PreRename(oldPatgh string, newPath string) (hooked bool, ctx HookContext, err error)
	PostRename(oldPatgh string, newPath string) (hooked bool, ctx HookContext, err error)
}

HookOnRename is called on rename

type HookOnRmdir

type HookOnRmdir interface {
	// if hooked is true, the real rmdir() would not be called
	PreRmdir(path string) (hooked bool, ctx HookContext, err error)
	PostRmdir(realRetCode int32, prehookCtx HookContext) (hooked bool, err error)
}

HookOnRmdir is called on rmdir. This also implements Hook.

type HookOnWrite

type HookOnWrite interface {
	// if hooked is true, the real write() would not be called
	PreWrite(path string, buf []byte, offset int64) (hooked bool, ctx HookContext, err error)
	PostWrite(realRetCode int32, prehookCtx HookContext) (hooked bool, err error)
}

HookOnWrite is called on write. This also implements Hook.

type HookWithInit

type HookWithInit interface {
	Init() (err error)
}

HookWithInit is called on mount. This also implements Hook.

Jump to

Keyboard shortcuts

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