Documentation
¶
Overview ¶
9p File System Implementations.
Various implementations of servers that conform to the ninep.FileSystem interface.
Index ¶
- func Env() ninep.FileSystem
- func FS(f FileSystem) ninep.FileSystem
- func NewDelayFS(underlying ninep.FileSystem, delay time.Duration) ninep.FileSystem
- func Populate(fs ninep.FileSystem, files map[string]string) error
- func ReadOnly(fsys ninep.FileSystem) ninep.FileSystem
- func ReadOnlyFS(f fs.FS) ninep.FileSystem
- func Restrict(fs ninep.FileSystem, disallow Disallow) ninep.FileSystem
- func Sub(fs ninep.FileSystem, subdir string) ninep.FileSystem
- func TraceFs(fs ninep.FileSystem, l *slog.Logger) ninep.FileSystem
- func WithClose(f ninep.FileSystem, closers ...context.CancelFunc) ninep.FileSystem
- type Dir
- func (d Dir) CreateFile(ctx context.Context, path string, flag ninep.OpenMode, mode ninep.Mode) (ninep.FileHandle, error)
- func (d Dir) Delete(ctx context.Context, path string) error
- func (d Dir) ListDir(ctx context.Context, path string) iter.Seq2[fs.FileInfo, error]
- func (d Dir) MakeDir(ctx context.Context, path string, mode ninep.Mode) error
- func (d Dir) OpenFile(ctx context.Context, path string, flag ninep.OpenMode) (ninep.FileHandle, error)
- func (d Dir) Stat(ctx context.Context, path string) (fs.FileInfo, error)
- func (d Dir) Traverse(ctx context.Context, path string) (ninep.TraversableFile, error)
- func (d Dir) Walk(ctx context.Context, parts []string) ([]os.FileInfo, error)
- func (d Dir) WriteStat(ctx context.Context, path string, s ninep.Stat) error
- type Disallow
- type FileInfoChangeRequest
- type FileSystem
- type Mem
- func (m *Mem) CreateFile(ctx context.Context, path string, flag ninep.OpenMode, mode ninep.Mode) (ninep.FileHandle, error)
- func (m *Mem) Delete(ctx context.Context, path string) error
- func (m *Mem) ListDir(ctx context.Context, path string) iter.Seq2[os.FileInfo, error]
- func (m *Mem) MakeDir(ctx context.Context, path string, mode ninep.Mode) error
- func (m *Mem) OpenFile(ctx context.Context, path string, flag ninep.OpenMode) (ninep.FileHandle, error)
- func (m *Mem) Stat(ctx context.Context, path string) (os.FileInfo, error)
- func (m *Mem) Traverse(ctx context.Context, path string) (ninep.TraversableFile, error)
- func (m *Mem) WriteStat(ctx context.Context, path string, s ninep.Stat) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Env ¶
func Env() ninep.FileSystem
Env implements a basic file system to the process environment variables.
func FS ¶
func FS(f FileSystem) ninep.FileSystem
FS wraps a FileSystem to provide a ninep.FileSystem interface This provides an interface using io/fs when possible.
func NewDelayFS ¶
func NewDelayFS(underlying ninep.FileSystem, delay time.Duration) ninep.FileSystem
func ReadOnly ¶
func ReadOnly(fsys ninep.FileSystem) ninep.FileSystem
ReadOnly wraps a FileSystem and returns a read-only version of it.
func ReadOnlyFS ¶
func ReadOnlyFS(f fs.FS) ninep.FileSystem
ReadOnlyFS wraps an fs.FS and returns a read-only version of it for use with ninep.
func Restrict ¶
func Restrict(fs ninep.FileSystem, disallow Disallow) ninep.FileSystem
Restrict returns a new FileSystem that disallows certain operations.
func Sub ¶
func Sub(fs ninep.FileSystem, subdir string) ninep.FileSystem
Sub returns a new FileSystem that operates on a subdirectory of the given FileSystem.
func TraceFs ¶
func TraceFs(fs ninep.FileSystem, l *slog.Logger) ninep.FileSystem
Returns a trace file system the wraps a given file system.
The trace file system simply logs all file system operations are logged to the loggable.
Supports also walkable file systems.
func WithClose ¶
func WithClose(f ninep.FileSystem, closers ...context.CancelFunc) ninep.FileSystem
WithClose returns a wrapped file system that attaches the given closers to the Close() method of the filesystem. These methods are call prior to calling Close() on the underlying filesystem.
Types ¶
type Dir ¶
type Dir string
Dir implements a basic file system to the local file system with a given root dir. The type represents the root directory for this file system
func (Dir) CreateFile ¶
func (d Dir) CreateFile(ctx context.Context, path string, flag ninep.OpenMode, mode ninep.Mode) (ninep.FileHandle, error)
CreateFile creates a new file as a descendent of the root directory of Dir
func (Dir) OpenFile ¶
func (d Dir) OpenFile(ctx context.Context, path string, flag ninep.OpenMode) (ninep.FileHandle, error)
OpenFile opens an existing file that is a descendent of the root directory of Dir for reading/writing
type Disallow ¶
type Disallow uint64
const ( DisallowMakeDirectory Disallow = 1 << iota DisallowCreateFile DisallowOpenFile DisallowListDir DisallowStat DisallowWriteStat DisallowDelete DisallowOpenFileTruncate DisallowRemoveOnClose DisallowCreation = DisallowMakeDirectory | DisallowCreateFile DisallowMutation = DisallowWriteStat | DisallowDelete | DisallowOpenFileTruncate | DisallowRemoveOnClose )
type FileInfoChangeRequest ¶
type FileInfoChangeRequest struct {
Name *string
Owner *string
Group *string
LastModifiedUser *string
Mode *fs.FileMode
ModTime *time.Time
AccessTime *time.Time
Length *int64
}
FileInfoChangeRequest is used to change the stat of a file or directory. If a value is nil, the caller does not want that part of the stat to be changed.
type FileSystem ¶
type FileSystem interface {
// Creates a directory. Implementions should recursively make directories
// whenever possible.
MakeDir(ctx context.Context, path string, mode fs.FileMode) error
// Creates a file and opens it for reading/writing
CreateFile(ctx context.Context, path string, flag int, mode fs.FileMode) (ninep.FileHandle, error)
// Opens an existing file for reading/writing
OpenFile(ctx context.Context, path string, flag int) (ninep.FileHandle, error)
// Lists directories and files in a given path. Does not include '.' or '..'
// fs.FileInfo may optionally implement Statable. Iterations are allowed to
// return a nil FileInfo if they have an error.
ListDir(ctx context.Context, path string) iter.Seq2[fs.FileInfo, error]
// Lists stats about a given file or directory. Implementations may return
// fs.ErrNotExist for directories that do not exist.
Stat(ctx context.Context, path string) (fs.FileInfo, error)
// Writes stats about a given file or directory.
// The req contains all desired changes. If a value is nil, the caller
// does not want that part of the stat to be changed.
WriteStat(ctx context.Context, path string, info FileInfoChangeRequest) error
// Deletes a file or directory. Implementations may reject directories that aren't empty
Delete(ctx context.Context, path string) error
}
FileSystem is a bridging interface to provide a ninep.FileSystem interface. This allows implementing using familiar fs types without knowing about the 9p protocol. Note that various fs.FileMode values cannot be translated to 9p.
type Mem ¶
type Mem struct {
Root memNode
}
Implements a basic file system in memory only. Also, not a particularly efficient implementation.
func NewMemFSWithFiles ¶
NewMemFS creates a new in-memory file system with a given set of files.
func (*Mem) CreateFile ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Implements a 9p file system that talks to a docker daemon.
|
Implements a 9p file system that talks to a docker daemon. |
|
Implements a 9p file system encrypts its data on another 9p file server
|
Implements a 9p file system encrypts its data on another 9p file server |
|
muxfs provides a file system based on a mux.
|
muxfs provides a file system based on a mux. |
|
Implements a 9p file server that behaves similar to /proc on some unix systems
|
Implements a 9p file server that behaves similar to /proc on some unix systems |
|
Implements a 9p file system that talks to Amazon's S3 Object Storage Service.
|
Implements a 9p file system that talks to Amazon's S3 Object Storage Service. |
|
Implements a 9p file system that talks to a given server via SFTP
|
Implements a 9p file system that talks to a given server via SFTP |