Documentation
¶
Overview ¶
Package templatefs provides template p9.Files.
NoopFile can be used to leave some methods unimplemented in incomplete p9.File implementations.
NilCloser, ReadOnlyFile, NotDirectoryFile, and NotSymlinkFile can be used as templates for commonly implemented file types. They are careful not to conflict with each others' methods, so they can be embedded together.
Index ¶
- type IsDir
- type NilCloser
- type NilSyncer
- type NoopFile
- type NoopRenamed
- type NotDirectoryFile
- func (NotDirectoryFile) Create(name string, mode p9.OpenFlags, permissions p9.FileMode, _ p9.UID, _ p9.GID) (p9.File, p9.QID, uint32, error)
- func (NotDirectoryFile) Link(target p9.File, newname string) error
- func (NotDirectoryFile) Mkdir(name string, permissions p9.FileMode, _ p9.UID, _ p9.GID) (p9.QID, error)
- func (NotDirectoryFile) Mknod(name string, mode p9.FileMode, major uint32, minor uint32, _ p9.UID, _ p9.GID) (p9.QID, error)
- func (NotDirectoryFile) Readdir(offset uint64, count uint32) (p9.Dirents, error)
- func (NotDirectoryFile) RenameAt(oldname string, newdir p9.File, newname string) error
- func (NotDirectoryFile) Symlink(oldname string, newname string, _ p9.UID, _ p9.GID) (p9.QID, error)
- func (NotDirectoryFile) UnlinkAt(name string, flags uint32) error
- type NotImplementedFile
- func (NotImplementedFile) Create(name string, mode p9.OpenFlags, permissions p9.FileMode, _ p9.UID, _ p9.GID) (p9.File, p9.QID, uint32, error)
- func (NotImplementedFile) GetAttr(req p9.AttrMask) (p9.QID, p9.AttrMask, p9.Attr, error)
- func (NotImplementedFile) Link(target p9.File, newname string) error
- func (NotImplementedFile) Mkdir(name string, permissions p9.FileMode, _ p9.UID, _ p9.GID) (p9.QID, error)
- func (NotImplementedFile) Mknod(name string, mode p9.FileMode, major uint32, minor uint32, _ p9.UID, _ p9.GID) (p9.QID, error)
- func (NotImplementedFile) Open(mode p9.OpenFlags) (p9.QID, uint32, error)
- func (NotImplementedFile) ReadAt(p []byte, offset int64) (int, error)
- func (NotImplementedFile) Readdir(offset uint64, count uint32) (p9.Dirents, error)
- func (NotImplementedFile) Readlink() (string, error)
- func (NotImplementedFile) Remove() error
- func (NotImplementedFile) Rename(directory p9.File, name string) error
- func (NotImplementedFile) RenameAt(oldname string, newdir p9.File, newname string) error
- func (NotImplementedFile) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error
- func (NotImplementedFile) StatFS() (p9.FSStat, error)
- func (NotImplementedFile) Symlink(oldname string, newname string, _ p9.UID, _ p9.GID) (p9.QID, error)
- func (NotImplementedFile) UnlinkAt(name string, flags uint32) error
- func (NotImplementedFile) Walk(names []string) ([]p9.QID, p9.File, error)
- func (NotImplementedFile) WriteAt(p []byte, offset int64) (int, error)
- type NotLockable
- type NotSymlinkFile
- type ReadOnlyDir
- func (ReadOnlyDir) Create(name string, mode p9.OpenFlags, permissions p9.FileMode, _ p9.UID, _ p9.GID) (p9.File, p9.QID, uint32, error)
- func (ReadOnlyDir) FSync() error
- func (ReadOnlyDir) Link(target p9.File, newname string) error
- func (ReadOnlyDir) Mkdir(name string, permissions p9.FileMode, _ p9.UID, _ p9.GID) (p9.QID, error)
- func (ReadOnlyDir) Mknod(name string, mode p9.FileMode, major uint32, minor uint32, _ p9.UID, _ p9.GID) (p9.QID, error)
- func (ReadOnlyDir) Readdir(offset uint64, count uint32) (p9.Dirents, error)
- func (ReadOnlyDir) Remove() error
- func (ReadOnlyDir) Rename(directory p9.File, name string) error
- func (ReadOnlyDir) RenameAt(oldname string, newdir p9.File, newname string) error
- func (ReadOnlyDir) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error
- func (ReadOnlyDir) Symlink(oldname string, newname string, _ p9.UID, _ p9.GID) (p9.QID, error)
- func (ReadOnlyDir) UnlinkAt(name string, flags uint32) error
- type ReadOnlyFile
- func (ReadOnlyFile) FSync() error
- func (ReadOnlyFile) Flush() error
- func (ReadOnlyFile) Remove() error
- func (ReadOnlyFile) Rename(directory p9.File, name string) error
- func (ReadOnlyFile) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error
- func (ReadOnlyFile) WriteAt(p []byte, offset int64) (int, error)
- type XattrUnimplemented
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IsDir ¶
type IsDir struct{}
IsDir returns EISDIR for ReadAt and WriteAt.
type NoopFile ¶
type NoopFile struct { NotImplementedFile NilCloser NilSyncer NoopRenamed }
NoopFile is a p9.File with every method unimplemented.
type NotDirectoryFile ¶
type NotDirectoryFile struct{}
NotDirectoryFile denies any directory operations with ENOTDIR.
Those operations are Create, Mkdir, Symlink, Link, Mknod, RenameAt, UnlinkAt, and Readdir.
func (NotDirectoryFile) Create ¶
func (NotDirectoryFile) Create(name string, mode p9.OpenFlags, permissions p9.FileMode, _ p9.UID, _ p9.GID) (p9.File, p9.QID, uint32, error)
Create implements p9.File.Create.
func (NotDirectoryFile) Link ¶
func (NotDirectoryFile) Link(target p9.File, newname string) error
Link implements p9.File.Link.
func (NotDirectoryFile) Mkdir ¶
func (NotDirectoryFile) Mkdir(name string, permissions p9.FileMode, _ p9.UID, _ p9.GID) (p9.QID, error)
Mkdir implements p9.File.Mkdir.
func (NotDirectoryFile) Mknod ¶
func (NotDirectoryFile) Mknod(name string, mode p9.FileMode, major uint32, minor uint32, _ p9.UID, _ p9.GID) (p9.QID, error)
Mknod implements p9.File.Mknod.
type NotImplementedFile ¶ added in v0.3.0
type NotImplementedFile struct { p9.DefaultWalkGetAttr NotLockable XattrUnimplemented }
NotImplementedFile is a p9.File that returns ENOSYS for every listed method.
Compatible with NoopRenamed, NilCloser, and NilSyncer.
func (NotImplementedFile) Create ¶ added in v0.3.0
func (NotImplementedFile) Create(name string, mode p9.OpenFlags, permissions p9.FileMode, _ p9.UID, _ p9.GID) (p9.File, p9.QID, uint32, error)
Create implements p9.File.Create.
func (NotImplementedFile) Link ¶ added in v0.3.0
func (NotImplementedFile) Link(target p9.File, newname string) error
Link implements p9.File.Link.
func (NotImplementedFile) Mkdir ¶ added in v0.3.0
func (NotImplementedFile) Mkdir(name string, permissions p9.FileMode, _ p9.UID, _ p9.GID) (p9.QID, error)
Mkdir implements p9.File.Mkdir.
func (NotImplementedFile) Mknod ¶ added in v0.3.0
func (NotImplementedFile) Mknod(name string, mode p9.FileMode, major uint32, minor uint32, _ p9.UID, _ p9.GID) (p9.QID, error)
Mknod implements p9.File.Mknod.
func (NotImplementedFile) ReadAt ¶ added in v0.3.0
func (NotImplementedFile) ReadAt(p []byte, offset int64) (int, error)
ReadAt implements p9.File.ReadAt.
func (NotImplementedFile) Readlink ¶ added in v0.3.0
func (NotImplementedFile) Readlink() (string, error)
Readlink implements p9.File.Readlink.
func (NotImplementedFile) Remove ¶ added in v0.3.0
func (NotImplementedFile) Remove() error
Remove implements p9.File.Remove.
func (NotImplementedFile) Rename ¶ added in v0.3.0
func (NotImplementedFile) Rename(directory p9.File, name string) error
Rename implements p9.File.Rename.
func (NotImplementedFile) SetAttr ¶ added in v0.3.0
func (NotImplementedFile) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error
SetAttr implements p9.File.SetAttr.
func (NotImplementedFile) StatFS ¶ added in v0.3.0
func (NotImplementedFile) StatFS() (p9.FSStat, error)
StatFS implements p9.File.StatFS.
Not implemented.
func (NotImplementedFile) Symlink ¶ added in v0.3.0
func (NotImplementedFile) Symlink(oldname string, newname string, _ p9.UID, _ p9.GID) (p9.QID, error)
Symlink implements p9.File.Symlink.
func (NotImplementedFile) UnlinkAt ¶ added in v0.3.0
func (NotImplementedFile) UnlinkAt(name string, flags uint32) error
UnlinkAt implements p9.File.UnlinkAt.
type NotLockable ¶ added in v0.3.0
type NotLockable struct{}
type NotSymlinkFile ¶
type NotSymlinkFile struct{}
NotSymlinkFile denies Readlink with EINVAL.
EINVAL is returned by readlink(2) when the file is not a symlink.
func (NotSymlinkFile) Readlink ¶
func (NotSymlinkFile) Readlink() (string, error)
Readlink implements p9.File.Readlink.
type ReadOnlyDir ¶
type ReadOnlyDir struct { NotSymlinkFile IsDir XattrUnimplemented NoopRenamed NotLockable }
ReadOnlyDir implements default denials for all methods except Walk, Open, GetAttr, Readdir, Close.
Creation operations return EROFS. Read/write operations return EISDIR. EINVAL for readlink. Renaming does nothing by default, xattr and locking are unimplemented.
func (ReadOnlyDir) Create ¶
func (ReadOnlyDir) Create(name string, mode p9.OpenFlags, permissions p9.FileMode, _ p9.UID, _ p9.GID) (p9.File, p9.QID, uint32, error)
Create implements p9.File.Create.
func (ReadOnlyDir) Link ¶
func (ReadOnlyDir) Link(target p9.File, newname string) error
Link implements p9.File.Link.
func (ReadOnlyDir) Mknod ¶
func (ReadOnlyDir) Mknod(name string, mode p9.FileMode, major uint32, minor uint32, _ p9.UID, _ p9.GID) (p9.QID, error)
Mknod implements p9.File.Mknod.
func (ReadOnlyDir) Rename ¶
func (ReadOnlyDir) Rename(directory p9.File, name string) error
Rename implements p9.File.Rename.
func (ReadOnlyDir) SetAttr ¶
func (ReadOnlyDir) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error
SetAttr implements p9.File.SetAttr.
type ReadOnlyFile ¶
type ReadOnlyFile struct { NotSymlinkFile NotDirectoryFile XattrUnimplemented NoopRenamed NotLockable }
ReadOnlyFile returns default denials for all methods except Open, ReadAt, Walk, Close, and GetAttr.
Returns EROFS for most modifying operations, ENOTDIR for file creation ops or readdir, EINVAL for readlink, xattr and lock operations return ENOSYS.
Does nothing for Renamed.
func (ReadOnlyFile) Rename ¶
func (ReadOnlyFile) Rename(directory p9.File, name string) error
Rename implements p9.File.Rename.
func (ReadOnlyFile) SetAttr ¶
func (ReadOnlyFile) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error
SetAttr implements p9.File.SetAttr.
type XattrUnimplemented ¶ added in v0.3.0
type XattrUnimplemented struct{}
XattrUnimplemented implements Xattr methods returning ENOSYS.
func (XattrUnimplemented) GetXattr ¶ added in v0.3.0
func (XattrUnimplemented) GetXattr(attr string) ([]byte, error)
GetXattr implements p9.File.GetXattr.
func (XattrUnimplemented) ListXattrs ¶ added in v0.3.0
func (XattrUnimplemented) ListXattrs() ([]string, error)
ListXattrs implements p9.File.ListXattrs.
func (XattrUnimplemented) RemoveXattr ¶ added in v0.3.0
func (XattrUnimplemented) RemoveXattr(attr string) error
RemoveXattr implements p9.File.RemoveXattr.
func (XattrUnimplemented) SetXattr ¶ added in v0.3.0
func (XattrUnimplemented) SetXattr(attr string, data []byte, flags p9.XattrFlags) error
SetXattr implements p9.File.SetXattr.