fuseadapter

package
v0.0.0-...-3ab43b7 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errno

func Errno(err error) syscall.Errno

Errno maps a backend error to the errno reported to the kernel. Service operations absorb definitive OCC conflicts before returning to FUSE; EAGAIN remains the legacy fallback for paths not yet integrated with replanning.

Types

type Adapter

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

func New

func New(core Core, clientID []byte, opts ...Option) *Adapter

func (*Adapter) Close

func (a *Adapter) Close()

func (*Adapter) Create

func (a *Adapter) Create(
	ctx context.Context,
	parent uint64,
	name []byte,
	opts filesystem.CreateOptions,
) (result filesystem.CreateResult, errno syscall.Errno)

func (*Adapter) FileLock

func (*Adapter) FileLock(context.Context) syscall.Errno

func (*Adapter) Flush

func (a *Adapter) Flush(ctx context.Context, inode uint64, fh uint64) syscall.Errno

func (*Adapter) Fsync

func (a *Adapter) Fsync(ctx context.Context, inode uint64, fh uint64, datasync bool) syscall.Errno

func (*Adapter) FsyncDirectory

func (a *Adapter) FsyncDirectory(ctx context.Context, inode uint64) syscall.Errno

func (*Adapter) GetAttr

func (a *Adapter) GetAttr(ctx context.Context, inode uint64) (filesystem.Stat, syscall.Errno)

func (*Adapter) Lookup

func (a *Adapter) Lookup(ctx context.Context, parent uint64, name []byte) (filesystem.Stat, syscall.Errno)

func (*Adapter) Mkdir

func (a *Adapter) Mkdir(
	ctx context.Context,
	parent uint64,
	name []byte,
	opts filesystem.CreateOptions,
) (result filesystem.CreateResult, errno syscall.Errno)

func (*Adapter) Mknod

func (a *Adapter) Mknod(
	ctx context.Context,
	parent uint64,
	name []byte,
	opts filesystem.CreateOptions,
) (result filesystem.CreateResult, errno syscall.Errno)

func (*Adapter) Open

func (a *Adapter) Open(ctx context.Context, inode uint64) (uint64, syscall.Errno)

func (*Adapter) Read

func (a *Adapter) Read(ctx context.Context, inode uint64, fh uint64, offset uint64, size uint64) ([]byte, syscall.Errno)

func (*Adapter) Readdir

func (a *Adapter) Readdir(ctx context.Context, inode uint64, cookie string) (filesystem.ReaddirResult, syscall.Errno)
func (*Adapter) Readlink(context.Context) syscall.Errno

func (*Adapter) Release

func (a *Adapter) Release(ctx context.Context, inode uint64, fh uint64) syscall.Errno

func (*Adapter) Rename

func (a *Adapter) Rename(
	ctx context.Context,
	oldParent uint64,
	oldName []byte,
	newParent uint64,
	newName []byte,
) (errno syscall.Errno)

func (*Adapter) Rmdir

func (a *Adapter) Rmdir(ctx context.Context, parent uint64, name []byte) (errno syscall.Errno)

func (*Adapter) SetAttr

func (a *Adapter) SetAttr(
	ctx context.Context,
	inode uint64,
	mask filesystem.SetAttrMask,
	attrs filesystem.SetAttr,
) (stat filesystem.Stat, errno syscall.Errno)

func (*Adapter) StatFS

func (a *Adapter) StatFS(ctx context.Context, inode uint64) (filesystem.StatFS, syscall.Errno)
func (*Adapter) Symlink(context.Context) syscall.Errno
func (a *Adapter) Unlink(ctx context.Context, parent uint64, name []byte) (errno syscall.Errno)

func (*Adapter) Write

func (a *Adapter) Write(ctx context.Context, inode uint64, fh uint64, offset uint64, data []byte) (n int, errno syscall.Errno)

type Option

type Option func(*Adapter)

func WithHandleKeepaliveInterval

func WithHandleKeepaliveInterval(interval time.Duration) Option

func WithHandleKeepaliveTimeout

func WithHandleKeepaliveTimeout(timeout time.Duration) Option

func WithJournaledCreate

func WithJournaledCreate(session filesystem.OperationSessionID) Option

WithJournaledCreate journals file creation and returns its original inode and handle.

func WithJournaledLeaseRefresh

func WithJournaledLeaseRefresh(session filesystem.OperationSessionID) Option

WithJournaledLeaseRefresh journals foreground and keepalive lease renewals.

func WithJournaledMetadata

func WithJournaledMetadata(session filesystem.OperationSessionID) Option

WithJournaledMetadata journals setattr requests, including size changes.

func WithJournaledMkdir

func WithJournaledMkdir(session filesystem.OperationSessionID) Option

WithJournaledMkdir journals directory creation and its original inode.

func WithJournaledOpen

func WithJournaledOpen(session filesystem.OperationSessionID) Option

WithJournaledOpen journals handle allocation and its original lease.

func WithJournaledRelease

func WithJournaledRelease(session filesystem.OperationSessionID) Option

WithJournaledRelease records a terminal release for each FUSE handle.

func WithJournaledRename

func WithJournaledRename(session filesystem.OperationSessionID) Option

WithJournaledRename journals same-directory rename requests.

func WithJournaledRmdir

func WithJournaledRmdir(session filesystem.OperationSessionID) Option

WithJournaledRmdir journals empty-directory removal requests.

func WithJournaledUnlink(session filesystem.OperationSessionID) Option

WithJournaledUnlink journals file unlink requests under the same session.

func WithJournaledWrites

func WithJournaledWrites(session filesystem.OperationSessionID) Option

WithJournaledWrites assigns one durable operation identity to each FUSE write request. The caller must register the session before mounting.

func WithReaddirLimit

func WithReaddirLimit(limit int) Option

func WithStrictMode

func WithStrictMode(session filesystem.OperationSessionID) Option

WithStrictMode routes every supported mutation through the registered operation session and enables reply-bound acknowledgement.

type RawFileSystem

type RawFileSystem struct {
	fuse.RawFileSystem
	// contains filtered or unexported fields
}

RawFileSystem binds the protocol-neutral adapter to go-fuse's wire API. Embedding the default implementation keeps out-of-scope operations explicit: go-fuse returns ENOSYS unless this type overrides the operation below.

func NewRawFileSystem

func NewRawFileSystem(adapter *Adapter) *RawFileSystem

NewRawFileSystem creates the request bridge without mounting it. Tests and embedders can exercise this surface directly; Mount performs the kernel bind.

func (*RawFileSystem) Access

func (r *RawFileSystem) Access(cancel <-chan struct{}, input *fuse.AccessIn) fuse.Status

func (*RawFileSystem) Create

func (r *RawFileSystem) Create(cancel <-chan struct{}, input *fuse.CreateIn, name string, out *fuse.CreateOut) fuse.Status

func (*RawFileSystem) Flush

func (r *RawFileSystem) Flush(cancel <-chan struct{}, input *fuse.FlushIn) fuse.Status

func (*RawFileSystem) Fsync

func (r *RawFileSystem) Fsync(cancel <-chan struct{}, input *fuse.FsyncIn) fuse.Status

func (*RawFileSystem) FsyncDir

func (r *RawFileSystem) FsyncDir(cancel <-chan struct{}, input *fuse.FsyncIn) fuse.Status

func (*RawFileSystem) GetAttr

func (r *RawFileSystem) GetAttr(cancel <-chan struct{}, input *fuse.GetAttrIn, out *fuse.AttrOut) fuse.Status
func (r *RawFileSystem) Link(<-chan struct{}, *fuse.LinkIn, string, *fuse.EntryOut) fuse.Status

func (*RawFileSystem) Lookup

func (r *RawFileSystem) Lookup(cancel <-chan struct{}, header *fuse.InHeader, name string, out *fuse.EntryOut) fuse.Status

func (*RawFileSystem) Mkdir

func (r *RawFileSystem) Mkdir(cancel <-chan struct{}, input *fuse.MkdirIn, name string, out *fuse.EntryOut) fuse.Status

func (*RawFileSystem) Mknod

func (r *RawFileSystem) Mknod(cancel <-chan struct{}, input *fuse.MknodIn, name string, out *fuse.EntryOut) fuse.Status

func (*RawFileSystem) OnReplyAttempt

func (r *RawFileSystem) OnReplyAttempt(unique uint64, _ uint32, _ fuse.Status, _ fuse.Status)

OnReplyAttempt is invoked by the local go-fuse bridge after its device write.

func (*RawFileSystem) OnReplySuppressed

func (r *RawFileSystem) OnReplySuppressed(unique uint64, _ uint32, _ fuse.Status)

OnReplySuppressed retires a request after go-fuse has decided that no FUSE reply can be sent, including an interrupted request on a dead connection.

func (*RawFileSystem) Open

func (r *RawFileSystem) Open(cancel <-chan struct{}, input *fuse.OpenIn, out *fuse.OpenOut) fuse.Status

func (*RawFileSystem) OpenDir

func (r *RawFileSystem) OpenDir(cancel <-chan struct{}, input *fuse.OpenIn, out *fuse.OpenOut) fuse.Status

func (*RawFileSystem) Read

func (r *RawFileSystem) Read(cancel <-chan struct{}, input *fuse.ReadIn, _ []byte) (fuse.ReadResult, fuse.Status)

func (*RawFileSystem) ReadDir

func (r *RawFileSystem) ReadDir(cancel <-chan struct{}, input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status
func (r *RawFileSystem) Readlink(<-chan struct{}, *fuse.InHeader) ([]byte, fuse.Status)

func (*RawFileSystem) Release

func (r *RawFileSystem) Release(cancel <-chan struct{}, input *fuse.ReleaseIn)

func (*RawFileSystem) ReleaseDir

func (r *RawFileSystem) ReleaseDir(input *fuse.ReleaseIn)

func (*RawFileSystem) Rename

func (r *RawFileSystem) Rename(cancel <-chan struct{}, input *fuse.RenameIn, oldName string, newName string) fuse.Status

func (*RawFileSystem) Rmdir

func (r *RawFileSystem) Rmdir(cancel <-chan struct{}, header *fuse.InHeader, name string) fuse.Status

func (*RawFileSystem) SetAttr

func (r *RawFileSystem) SetAttr(cancel <-chan struct{}, input *fuse.SetAttrIn, out *fuse.AttrOut) fuse.Status

func (*RawFileSystem) StatFs

func (r *RawFileSystem) StatFs(cancel <-chan struct{}, input *fuse.InHeader, out *fuse.StatfsOut) fuse.Status

func (*RawFileSystem) String

func (r *RawFileSystem) String() string
func (r *RawFileSystem) Symlink(<-chan struct{}, *fuse.InHeader, string, string, *fuse.EntryOut) fuse.Status
func (r *RawFileSystem) Unlink(cancel <-chan struct{}, header *fuse.InHeader, name string) fuse.Status

func (*RawFileSystem) Write

func (r *RawFileSystem) Write(cancel <-chan struct{}, input *fuse.WriteIn, data []byte) (uint32, fuse.Status)

type Server

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

Server owns an active kernel mount and its adapter session.

func Mount

func Mount(mountPoint string, adapter *Adapter, options *fuse.MountOptions) (*Server, error)

Mount attaches adapter to mountPoint using go-fuse. The returned server is ready for Serve; callers should call Unmount during shutdown. It is MountContext with a background context; servers that can be told to stop during startup should use MountContext.

A dangling FUSE mount left at mountPoint by a server that died without unmounting (SIGKILL, a crash) is detached first, because fusermount3 refuses to mount over a mount point whose transport is not connected. Only a mount the mounts table reports with this server's own type (`fuse.<Name>`) and whose stat fails with ENOTCONN is touched; a live mount or a filesystem of any other type at the path is left alone.

func MountContext

func MountContext(ctx context.Context, mountPoint string, adapter *Adapter, options *fuse.MountOptions) (*Server, error)

MountContext is Mount whose pre-mount work (the stale-mount detach and the intent recovery) stops when ctx is cancelled, so a shutdown requested during startup does not wait on a hung fusermount helper, an unavailable leader, or a long recovery backlog. The returned Server's WaitMount stops on ctx too, releasing the mount; otherwise the kernel mount and the Server are not bound to ctx, and Unmount ends them.

func (*Server) Serve

func (s *Server) Serve()

Serve runs the request loop until the kernel mount goes away. After WaitMount released the mount of a cancelled startup it returns once that release has finished, even when a backend request that ignores its context still holds one of go-fuse's loops.

func (*Server) Unmount

func (s *Server) Unmount() error

func (*Server) UnmountContext

func (s *Server) UnmountContext(ctx context.Context) error

UnmountContext bounds and reaps the path-based helper before returning. Unlike go-fuse's Unmount, cancellation never leaves a helper that could later unmount a new filesystem at the same path.

func (*Server) UnmountLazy

func (s *Server) UnmountLazy(ctx context.Context) error

UnmountLazy detaches the mount from the namespace even while clients still hold files on it open (`fusermount -u -z`, or a lazy unmount(2)): new lookups see the plain directory at once, and the kernel releases the FUSE connection, ending Serve, once the last open handle is closed. It is the fallback for an Unmount that failed with EBUSY or did not return during shutdown, so it first stops serving: every request in flight, and every one that arrives later, has its context cancelled. A handler blocked in the backend (the reason the Unmount hung) therefore returns before the stores behind it are closed, and requests through a handle that is still open get an error from then on. The detach itself acts only on a mount of this server's own type still present at the mount point: when the kernel mount is already gone (Unmount removed it and is merely waiting for its event loop), or a filesystem of any other type is exposed there, nothing is touched and nil is returned. A nil or never-mounted Server is a no-op apart from the cancellation.

func (*Server) Wait

func (s *Server) Wait()

func (*Server) WaitMount

func (s *Server) WaitMount() error

WaitMount waits until the kernel mount answers requests. When the context MountContext ran under is cancelled first, it releases the mount (see release) and returns the cancellation, so a shutdown requested while the readiness check is stuck in a backend request is not held up by it. Serve must be running, as for go-fuse's own WaitMount.

Jump to

Keyboard shortcuts

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