Documentation
¶
Index ¶
- func Errno(err error) syscall.Errno
- type Adapter
- func (a *Adapter) Close()
- func (a *Adapter) Create(ctx context.Context, parent uint64, name []byte, opts filesystem.CreateOptions) (result filesystem.CreateResult, errno syscall.Errno)
- func (*Adapter) FileLock(context.Context) syscall.Errno
- func (a *Adapter) Flush(ctx context.Context, inode uint64, fh uint64) syscall.Errno
- func (a *Adapter) Fsync(ctx context.Context, inode uint64, fh uint64, datasync bool) syscall.Errno
- func (a *Adapter) FsyncDirectory(ctx context.Context, inode uint64) syscall.Errno
- func (a *Adapter) GetAttr(ctx context.Context, inode uint64) (filesystem.Stat, syscall.Errno)
- func (*Adapter) Link(context.Context) syscall.Errno
- func (a *Adapter) Lookup(ctx context.Context, parent uint64, name []byte) (filesystem.Stat, syscall.Errno)
- func (a *Adapter) Mkdir(ctx context.Context, parent uint64, name []byte, opts filesystem.CreateOptions) (result filesystem.CreateResult, errno syscall.Errno)
- func (a *Adapter) Mknod(ctx context.Context, parent uint64, name []byte, opts filesystem.CreateOptions) (result filesystem.CreateResult, errno syscall.Errno)
- func (a *Adapter) Open(ctx context.Context, inode uint64) (uint64, syscall.Errno)
- func (a *Adapter) Read(ctx context.Context, inode uint64, fh uint64, offset uint64, size uint64) ([]byte, syscall.Errno)
- func (a *Adapter) Readdir(ctx context.Context, inode uint64, cookie string) (filesystem.ReaddirResult, syscall.Errno)
- func (*Adapter) Readlink(context.Context) syscall.Errno
- func (a *Adapter) Release(ctx context.Context, inode uint64, fh uint64) syscall.Errno
- func (a *Adapter) Rename(ctx context.Context, oldParent uint64, oldName []byte, newParent uint64, ...) (errno syscall.Errno)
- func (a *Adapter) Rmdir(ctx context.Context, parent uint64, name []byte) (errno syscall.Errno)
- func (a *Adapter) SetAttr(ctx context.Context, inode uint64, mask filesystem.SetAttrMask, ...) (stat filesystem.Stat, errno syscall.Errno)
- 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 (a *Adapter) Write(ctx context.Context, inode uint64, fh uint64, offset uint64, data []byte) (n int, errno syscall.Errno)
- type Core
- type Option
- func WithHandleKeepaliveInterval(interval time.Duration) Option
- func WithHandleKeepaliveTimeout(timeout time.Duration) Option
- func WithJournaledCreate(session filesystem.OperationSessionID) Option
- func WithJournaledLeaseRefresh(session filesystem.OperationSessionID) Option
- func WithJournaledMetadata(session filesystem.OperationSessionID) Option
- func WithJournaledMkdir(session filesystem.OperationSessionID) Option
- func WithJournaledOpen(session filesystem.OperationSessionID) Option
- func WithJournaledRelease(session filesystem.OperationSessionID) Option
- func WithJournaledRename(session filesystem.OperationSessionID) Option
- func WithJournaledRmdir(session filesystem.OperationSessionID) Option
- func WithJournaledUnlink(session filesystem.OperationSessionID) Option
- func WithJournaledWrites(session filesystem.OperationSessionID) Option
- func WithReaddirLimit(limit int) Option
- func WithStrictMode(session filesystem.OperationSessionID) Option
- type RawFileSystem
- func (r *RawFileSystem) Access(cancel <-chan struct{}, input *fuse.AccessIn) fuse.Status
- func (r *RawFileSystem) Create(cancel <-chan struct{}, input *fuse.CreateIn, name string, out *fuse.CreateOut) fuse.Status
- func (r *RawFileSystem) Flush(cancel <-chan struct{}, input *fuse.FlushIn) fuse.Status
- func (r *RawFileSystem) Fsync(cancel <-chan struct{}, input *fuse.FsyncIn) fuse.Status
- func (r *RawFileSystem) FsyncDir(cancel <-chan struct{}, input *fuse.FsyncIn) fuse.Status
- 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 (r *RawFileSystem) Lookup(cancel <-chan struct{}, header *fuse.InHeader, name string, out *fuse.EntryOut) fuse.Status
- func (r *RawFileSystem) Mkdir(cancel <-chan struct{}, input *fuse.MkdirIn, name string, out *fuse.EntryOut) fuse.Status
- func (r *RawFileSystem) Mknod(cancel <-chan struct{}, input *fuse.MknodIn, name string, out *fuse.EntryOut) fuse.Status
- func (r *RawFileSystem) OnReplyAttempt(unique uint64, _ uint32, _ fuse.Status, _ fuse.Status)
- func (r *RawFileSystem) OnReplySuppressed(unique uint64, _ uint32, _ fuse.Status)
- func (r *RawFileSystem) Open(cancel <-chan struct{}, input *fuse.OpenIn, out *fuse.OpenOut) fuse.Status
- func (r *RawFileSystem) OpenDir(cancel <-chan struct{}, input *fuse.OpenIn, out *fuse.OpenOut) fuse.Status
- func (r *RawFileSystem) Read(cancel <-chan struct{}, input *fuse.ReadIn, _ []byte) (fuse.ReadResult, fuse.Status)
- 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 (r *RawFileSystem) Release(cancel <-chan struct{}, input *fuse.ReleaseIn)
- func (r *RawFileSystem) ReleaseDir(input *fuse.ReleaseIn)
- func (r *RawFileSystem) Rename(cancel <-chan struct{}, input *fuse.RenameIn, oldName string, newName string) fuse.Status
- func (r *RawFileSystem) Rmdir(cancel <-chan struct{}, header *fuse.InHeader, name string) fuse.Status
- func (r *RawFileSystem) SetAttr(cancel <-chan struct{}, input *fuse.SetAttrIn, out *fuse.AttrOut) fuse.Status
- func (r *RawFileSystem) StatFs(cancel <-chan struct{}, input *fuse.InHeader, out *fuse.StatfsOut) fuse.Status
- 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 (r *RawFileSystem) Write(cancel <-chan struct{}, input *fuse.WriteIn, data []byte) (uint32, fuse.Status)
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
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) FsyncDirectory ¶
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) Readdir ¶
func (a *Adapter) Readdir(ctx context.Context, inode uint64, cookie string) (filesystem.ReaddirResult, 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)
type Core ¶
type Core interface {
Resolve(context.Context, uint64, []byte) (uint64, error)
GetAttr(context.Context, uint64) (filesystem.Stat, error)
SetAttr(context.Context, uint64, filesystem.SetAttrMask, filesystem.SetAttr) (filesystem.Stat, error)
Open(context.Context, uint64, []byte) (uint64, error)
Read(context.Context, uint64, uint64, uint64, uint64) ([]byte, error)
Write(context.Context, uint64, uint64, uint64, []byte) (int, error)
Flush(context.Context, uint64, uint64) error
Fsync(context.Context, uint64, uint64, bool) error
Release(context.Context, uint64, uint64, []byte) error
RefreshOpenHandleLease(context.Context, uint64, uint64, []byte) error
Create(context.Context, uint64, []byte, filesystem.CreateOptions) (filesystem.CreateResult, error)
Mkdir(context.Context, uint64, []byte, filesystem.CreateOptions) (filesystem.CreateResult, error)
Unlink(context.Context, uint64, []byte) error
Rmdir(context.Context, uint64, []byte) error
Rename(context.Context, uint64, []byte, uint64, []byte) error
Readdir(context.Context, uint64, string, int) (filesystem.ReaddirResult, error)
StatFS(context.Context, uint64) (filesystem.StatFS, error)
}
Core is the filesystem backend surface required by the FUSE adapter.
type Option ¶
type Option func(*Adapter)
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 ¶
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 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) 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) OnReplyAttempt ¶
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) 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 (*RawFileSystem) Release ¶
func (r *RawFileSystem) Release(cancel <-chan struct{}, input *fuse.ReleaseIn)
func (*RawFileSystem) ReleaseDir ¶
func (r *RawFileSystem) ReleaseDir(input *fuse.ReleaseIn)
func (*RawFileSystem) String ¶
func (r *RawFileSystem) String() string
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server owns an active kernel mount and its adapter session.
func Mount ¶
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) UnmountContext ¶
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 ¶
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) WaitMount ¶
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.