templatefs

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: Apache-2.0 Imports: 2 Imported by: 1

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

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.

func (IsDir) ReadAt

func (IsDir) ReadAt(p []byte, offset int64) (int, error)

ReadAt implements p9.File.ReadAt.

func (IsDir) WriteAt

func (IsDir) WriteAt(p []byte, offset int64) (int, error)

WriteAt implements p9.File.WriteAt.

type NilCloser

type NilCloser struct{}

NilCloser returns nil for Close.

func (NilCloser) Close

func (NilCloser) Close() error

Close implements p9.File.Close.

type NilSyncer added in v0.3.0

type NilSyncer struct{}

NilSyncer returns nil for FSync.

func (NilSyncer) FSync added in v0.3.0

func (NilSyncer) FSync() error

FSync implements p9.File.FSync.

type NoopFile

NoopFile is a p9.File with every method unimplemented.

type NoopRenamed

type NoopRenamed struct{}

NoopRenamed does nothing when the file is renamed.

func (NoopRenamed) Renamed

func (NoopRenamed) Renamed(parent p9.File, newName string)

Renamed implements p9.File.Renamed.

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(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.

func (NotDirectoryFile) Readdir

func (NotDirectoryFile) Readdir(offset uint64, count uint32) (p9.Dirents, error)

Readdir implements p9.File.Readdir.

func (NotDirectoryFile) RenameAt

func (NotDirectoryFile) RenameAt(oldname string, newdir p9.File, newname string) error

RenameAt implements p9.File.RenameAt.

func (NotDirectoryFile) Symlink(oldname string, newname string, _ p9.UID, _ p9.GID) (p9.QID, error)

Symlink implements p9.File.Symlink.

func (NotDirectoryFile) UnlinkAt

func (NotDirectoryFile) UnlinkAt(name string, flags uint32) error

UnlinkAt implements p9.File.UnlinkAt.

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) GetAttr added in v0.3.0

func (NotImplementedFile) GetAttr(req p9.AttrMask) (p9.QID, p9.AttrMask, p9.Attr, error)

GetAttr implements p9.File.GetAttr.

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) Open added in v0.3.0

func (NotImplementedFile) Open(mode p9.OpenFlags) (p9.QID, uint32, error)

Open implements p9.File.Open.

func (NotImplementedFile) ReadAt added in v0.3.0

func (NotImplementedFile) ReadAt(p []byte, offset int64) (int, error)

ReadAt implements p9.File.ReadAt.

func (NotImplementedFile) Readdir added in v0.3.0

func (NotImplementedFile) Readdir(offset uint64, count uint32) (p9.Dirents, error)

Readdir implements p9.File.Readdir.

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) RenameAt added in v0.3.0

func (NotImplementedFile) RenameAt(oldname string, newdir p9.File, newname string) error

RenameAt implements p9.File.RenameAt.

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(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.

func (NotImplementedFile) Walk added in v0.3.0

func (NotImplementedFile) Walk(names []string) ([]p9.QID, p9.File, error)

Walk implements p9.File.Walk.

func (NotImplementedFile) WriteAt added in v0.3.0

func (NotImplementedFile) WriteAt(p []byte, offset int64) (int, error)

WriteAt implements p9.File.WriteAt.

type NotLockable added in v0.3.0

type NotLockable struct{}

func (NotLockable) Lock added in v0.3.0

func (NotLockable) Lock(pid int, locktype p9.LockType, flags p9.LockFlags, start, length uint64, client string) (p9.LockStatus, error)

Lock implements p9.File.Lock.

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() (string, error)

Readlink implements p9.File.Readlink.

type ReadOnlyDir

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) FSync

func (ReadOnlyDir) FSync() error

FSync implements p9.File.FSync.

func (ReadOnlyDir) Link(target p9.File, newname string) error

Link implements p9.File.Link.

func (ReadOnlyDir) Mkdir

func (ReadOnlyDir) Mkdir(name string, permissions p9.FileMode, _ p9.UID, _ p9.GID) (p9.QID, error)

Mkdir implements p9.File.Mkdir.

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) Readdir

func (ReadOnlyDir) Readdir(offset uint64, count uint32) (p9.Dirents, error)

Readdir implements p9.File.Readdir.

func (ReadOnlyDir) Remove

func (ReadOnlyDir) Remove() error

Remove implements p9.File.Remove.

func (ReadOnlyDir) Rename

func (ReadOnlyDir) Rename(directory p9.File, name string) error

Rename implements p9.File.Rename.

func (ReadOnlyDir) RenameAt

func (ReadOnlyDir) RenameAt(oldname string, newdir p9.File, newname string) error

RenameAt implements p9.File.RenameAt.

func (ReadOnlyDir) SetAttr

func (ReadOnlyDir) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error

SetAttr implements p9.File.SetAttr.

func (ReadOnlyDir) Symlink(oldname string, newname string, _ p9.UID, _ p9.GID) (p9.QID, error)

Symlink implements p9.File.Symlink.

func (ReadOnlyDir) UnlinkAt

func (ReadOnlyDir) UnlinkAt(name string, flags uint32) error

UnlinkAt implements p9.File.UnlinkAt.

type ReadOnlyFile

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) FSync

func (ReadOnlyFile) FSync() error

FSync implements p9.File.FSync.

func (ReadOnlyFile) Flush

func (ReadOnlyFile) Flush() error

Flush implements p9.File.Flush.

func (ReadOnlyFile) Remove

func (ReadOnlyFile) Remove() error

Remove implements p9.File.Remove.

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.

func (ReadOnlyFile) WriteAt

func (ReadOnlyFile) WriteAt(p []byte, offset int64) (int, error)

WriteAt implements p9.File.WriteAt.

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.

Jump to

Keyboard shortcuts

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