templatefs

package
v0.2.1-0...-7d74b92 Latest Latest
Warning

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

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

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 NoopFile

NoopFile is a p9.File that returns ENOSYS for every method.

func (NoopFile) Create

func (NoopFile) 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 (NoopFile) FSync

func (NoopFile) FSync() error

FSync implements p9.File.FSync.

func (NoopFile) GetAttr

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

GetAttr implements p9.File.GetAttr.

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

Link implements p9.File.Link.

func (NoopFile) Mkdir

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

Mkdir implements p9.File.Mkdir.

func (NoopFile) Mknod

func (NoopFile) Mknod(name string, mode p9.FileMode, major uint32, minor uint32, _ p9.UID, _ p9.GID) (p9.QID, error)

Mknod implements p9.File.Mknod.

func (NoopFile) Open

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

Open implements p9.File.Open.

func (NoopFile) ReadAt

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

ReadAt implements p9.File.ReadAt.

func (NoopFile) Readdir

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

Readdir implements p9.File.Readdir.

func (NoopFile) Readlink() (string, error)

Readlink implements p9.File.Readlink.

func (NoopFile) Remove

func (NoopFile) Remove() error

Remove implements p9.File.Remove.

func (NoopFile) Rename

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

Rename implements p9.File.Rename.

func (NoopFile) RenameAt

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

RenameAt implements p9.File.RenameAt.

func (NoopFile) SetAttr

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

SetAttr implements p9.File.SetAttr.

func (NoopFile) StatFS

func (NoopFile) StatFS() (p9.FSStat, error)

StatFS implements p9.File.StatFS.

Not implemented.

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

Symlink implements p9.File.Symlink.

func (NoopFile) UnlinkAt

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

UnlinkAt implements p9.File.UnlinkAt.

func (NoopFile) Walk

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

Walk implements p9.File.Walk.

func (NoopFile) WriteAt

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

WriteAt implements p9.File.WriteAt.

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 NotLockable

type NotLockable struct{}

func (NotLockable) Lock

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

type ReadOnlyDir struct{}

ReadOnlyDir denies any directory and file operations with EROFS

Those operations are Create, Mkdir, Symlink, Link, Mknod, RenameAt, UnlinkAt, Readdir, Rename, SetAttr, FSync, and Remove.

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

type ReadOnlyFile struct{}

ReadOnlyFile returns EROFS for FSync, SetAttr, Remove, Rename, WriteAt, and nil for Flush.

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.

Jump to

Keyboard shortcuts

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