fs

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package fs provides generic interfaces and types for file and filesystem operations, abstracting over different file implementations and enabling flexible filesystem backends.

The File interface defines a set of methods for file operations, including reading, writing, seeking, directory reading, file statistics, synchronization, and truncation.

The FileSystem interface is a generic interface for filesystem operations, parameterized by a File type. It includes methods for opening files, creating directories, retrieving file statistics, renaming, removing files, and reading directory entries.

Additional interfaces are provided for extended filesystem operations, such as unlinking, removing directories, creating links and symlinks, reading symlinks, changing permissions and ownership, and checking access permissions.

The FileSystemMount interface abstracts mounting and unmounting of filesystems, providing access to the underlying FileSystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File interface {
	io.ReadWriteCloser
	io.ReaderAt
	io.WriterAt
	io.Seeker

	ReadDir(count int) ([]fs.DirEntry, error)
	Stat() (fs.FileInfo, error)
	Sync() error
	Truncate(size int64) error
}

type FileSystem

type FileSystem[F File] interface {
	OpenFile(name string, flag int, perm fs.FileMode) (F, error)
	Mkdir(name string, perm fs.FileMode) error
	Stat(name string) (fs.FileInfo, error)
	Rename(source, target string) error
	Remove(name string) error
	ReadDir(name string) ([]fs.DirEntry, error)
}

type FileSystemAccess

type FileSystemAccess interface {
	Access(path string, mode uint32) error
}

type FileSystemChmod

type FileSystemChmod interface {
	Chmod(name string, perm fs.FileMode) error
}

type FileSystemChown

type FileSystemChown interface {
	Chown(name string, uid, gid int) error
}

type FileSystemInitDestroy added in v1.7.2

type FileSystemInitDestroy interface {
	Init()
	Destroy()
}
type FileSystemLink interface {
	Link(oldpath string, newpath string) error
}

type FileSystemMount

type FileSystemMount[T File, F FileSystem[T]] interface {
	Mount(context.Context) error // Mount filesystem
	Done()                       // Wait unmount
	SetOption(...any)            // Set option to fuse or winfsp
}

func New

func New[T File](target string, fs FileSystem[T]) FileSystemMount[T, FileSystem[T]]

Mount fuse

type FileSystemReadlink interface {
	Readlink(string) (string, error)
}

type FileSystemRmdir

type FileSystemRmdir interface {
	Rmdir(name string) error
}

type FileSystemStatFS

type FileSystemStatFS interface {
	Statfs(path string) (total, free uint64, err error)
}

type FileSystemStatFst added in v1.7.8

type FileSystemStatFst interface {
	Statfs(path string, stat *fuse.Statfs_t) error
}
type FileSystemSymlink interface {
	Symlink(target string, newpath string) error
}
type FileSystemUnlink interface {
	Unlink(name string) error
}

type FileSystemUtimens added in v1.7.6

type FileSystemUtimens interface {
	Utimens(path string, access, modification time.Time) error
}

type FuseFs added in v1.7.8

type FuseFs[T File, F FileSystem[T]] struct {
	fuse.FileSystemBase // Fs Base

	Target string
	FS     F

	FdOpen *mapSync[uint64, T]  // Map Filesytem virtual and local opened
	Host   *fuse.FileSystemHost // Fuse Mount
}

func (*FuseFs[T, F]) Access added in v1.7.8

func (fused *FuseFs[T, F]) Access(path string, mask uint32) int

func (*FuseFs[T, F]) Chmod added in v1.7.8

func (fused *FuseFs[T, F]) Chmod(path string, mode uint32) int

func (*FuseFs[T, F]) Chown added in v1.7.8

func (fused *FuseFs[T, F]) Chown(path string, uid uint32, gid uint32) int

func (*FuseFs[T, F]) Create added in v1.7.8

func (fused *FuseFs[T, F]) Create(path string, flags int, mode uint32) (int, uint64)

Create creates and opens a file.

func (*FuseFs[T, F]) Destroy added in v1.7.8

func (fused *FuseFs[T, F]) Destroy()

func (FuseFs[_, _]) Done added in v1.7.8

func (fs FuseFs[_, _]) Done()

func (*FuseFs[T, F]) Fdd added in v1.7.8

func (fused *FuseFs[T, F]) Fdd(file T) uintptr

func (*FuseFs[T, F]) Flush added in v1.7.8

func (fused *FuseFs[T, F]) Flush(path string, fh uint64) int

func (*FuseFs[T, F]) Fsync added in v1.7.8

func (fused *FuseFs[T, F]) Fsync(path string, datasync bool, fh uint64) int

func (*FuseFs[T, F]) Fsyncdir added in v1.7.8

func (fused *FuseFs[T, F]) Fsyncdir(path string, datasync bool, fh uint64) int

func (*FuseFs[T, F]) Getattr added in v1.7.8

func (fused *FuseFs[T, F]) Getattr(path string, stat *fuse.Stat_t, fh uint64) int

func (*FuseFs[T, F]) Init added in v1.7.8

func (fused *FuseFs[T, F]) Init()
func (fused *FuseFs[T, F]) Link(oldpath string, newpath string) int

func (*FuseFs[T, F]) Lseek added in v1.7.8

func (fused *FuseFs[T, F]) Lseek(path string, offset uint64, whence int, fh uint64) int

func (*FuseFs[T, F]) Mkdir added in v1.7.8

func (fused *FuseFs[T, F]) Mkdir(path string, mode uint32) int

func (FuseFs[_, _]) Mount added in v1.7.8

func (fs FuseFs[_, _]) Mount(ctx context.Context) error

func (*FuseFs[T, F]) Open added in v1.7.8

func (fused *FuseFs[T, F]) Open(path string, flags int) (int, uint64)

Open opens a file.

func (*FuseFs[T, F]) Opendir added in v1.7.8

func (fused *FuseFs[T, F]) Opendir(path string) (int, uint64)

func (*FuseFs[T, F]) Read added in v1.7.8

func (fused *FuseFs[T, F]) Read(path string, buf []byte, ofst int64, fh uint64) int

func (*FuseFs[T, F]) Readdir added in v1.7.8

func (fused *FuseFs[T, F]) Readdir(path string, fill fuse.StatFill, ofst int64, fh uint64) int
func (fused *FuseFs[T, F]) Readlink(path string) (int, string)

func (*FuseFs[T, F]) Release added in v1.7.8

func (fused *FuseFs[T, F]) Release(path string, fh uint64) int

func (*FuseFs[T, F]) Releasedir added in v1.7.8

func (fused *FuseFs[T, F]) Releasedir(path string, fh uint64) int

func (*FuseFs[T, F]) Rename added in v1.7.8

func (fused *FuseFs[T, F]) Rename(oldpath string, newpath string) int

func (*FuseFs[T, F]) Rmdir added in v1.7.8

func (fused *FuseFs[T, F]) Rmdir(path string) int

func (FuseFs[_, _]) SetOption added in v1.7.8

func (fs FuseFs[_, _]) SetOption(args ...any)

func (*FuseFs[T, F]) Statfs added in v1.7.8

func (fused *FuseFs[T, F]) Statfs(path string, stat *fuse.Statfs_t) int
func (fused *FuseFs[T, F]) Symlink(target string, newpath string) int

func (*FuseFs[T, F]) Truncate added in v1.7.8

func (fused *FuseFs[T, F]) Truncate(path string, size int64, fh uint64) int
func (fused *FuseFs[T, F]) Unlink(path string) int

func (*FuseFs[T, F]) Utimens added in v1.7.8

func (fused *FuseFs[T, F]) Utimens(path string, tmsp []fuse.Timespec) int

func (*FuseFs[T, F]) Write added in v1.7.8

func (fused *FuseFs[T, F]) Write(path string, buf []byte, ofst int64, fh uint64) int

Source Files

  • fs.go
  • fs_unix.go

Jump to

Keyboard shortcuts

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