Documentation
¶
Overview ¶
Package p9 implements file systems for the Plan 9 File Protocol.
Index ¶
- Constants
- func GetListeners(listener p9.File) ([]multiaddr.Multiaddr, error)
- func Listen(listener p9.File, maddr multiaddr.Multiaddr, permissions p9.FileMode) error
- func MkdirAll(root p9.File, names []string, permissions p9.FileMode, uid p9.UID, gid p9.GID) (p9.File, error)
- func NewDirectory(options ...DirectoryOption) (p9.QID, p9.File, error)
- func ReadAll(file p9.File) ([]byte, error)
- func ReadDir(dir p9.File) (p9.Dirents, error)
- func UnlinkEmptyChildren[OT generic.OptionFunc[T], T any, I directorySetter[T]](b bool) OT
- func UnlinkWhenEmpty[OT generic.OptionFunc[T], T any, I directorySetter[T]](b bool) OT
- func UnmountAll(mounts p9.File) error
- func UnmountTargets(mounts p9.File, mountPoints []string, decodeTargetFn DecodeTargetFunc) error
- func WithBuffer[OT generic.OptionFunc[T], T any, I channelSetter[T]](size int) OT
- func WithGID[OT generic.OptionFunc[T], T any, I metadataSetter[T]](gid p9.GID) OT
- func WithParent[OT generic.OptionFunc[T], T any, I linkSetter[T]](parent p9.File, child string) OT
- func WithPath[OT generic.OptionFunc[T], T any, I metadataSetter[T]](path *atomic.Uint64) OT
- func WithPermissions[OT generic.OptionFunc[T], T any, I metadataSetter[T]](permissions p9.FileMode) OT
- func WithRenamedFunc[OT generic.OptionFunc[T], T any, I linkSetter[T]](fn RenamedFunc) OT
- func WithUID[OT generic.OptionFunc[T], T any, I metadataSetter[T]](uid p9.UID) OT
- func WithoutRename[OT generic.OptionFunc[T], T any, I linkSetter[T]](disabled bool) OT
- type ChannelFile
- func (cf *ChannelFile) Close() error
- func (cf *ChannelFile) GetAttr(req p9.AttrMask) (p9.QID, p9.AttrMask, p9.Attr, error)
- func (of ChannelFile) Mode() p9.OpenFlags
- func (cf *ChannelFile) Open(mode p9.OpenFlags) (p9.QID, ioUnit, error)
- func (cf *ChannelFile) Rename(newDir p9.File, newName string) error
- func (cf *ChannelFile) Renamed(newDir p9.File, newName string)
- func (cf *ChannelFile) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error
- func (cf *ChannelFile) Walk(names []string) ([]p9.QID, p9.File, error)
- func (cf *ChannelFile) WriteAt(p []byte, _ int64) (int, error)
- type ChannelOption
- type ConnInfo
- type DecodeTargetFunc
- type Directory
- func (dir Directory) GetAttr(req p9.AttrMask) (p9.QID, p9.AttrMask, p9.Attr, error)
- func (dir *Directory) Link(file p9.File, name string) error
- func (dir *Directory) Mkdir(name string, permissions p9.FileMode, uid p9.UID, gid p9.GID) (p9.QID, error)
- func (dir *Directory) Open(mode p9.OpenFlags) (p9.QID, ioUnit, error)
- func (dir *Directory) Readdir(offset uint64, count uint32) (p9.Dirents, error)
- func (dir *Directory) Rename(newDir p9.File, newName string) error
- func (dir *Directory) RenameAt(oldName string, newDir p9.File, newName string) error
- func (dir *Directory) Renamed(newDir p9.File, newName string)
- func (dir Directory) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error
- func (dir *Directory) UnlinkAt(name string, _ uint32) error
- func (dir *Directory) Walk(names []string) ([]p9.QID, p9.File, error)
- type DirectoryOption
- type FieldError
- type FieldParser
- type GuestFile
- func (gf *GuestFile) Create(name string, flags p9.OpenFlags, permissions p9.FileMode, uid p9.UID, ...) (p9.File, p9.QID, uint32, error)
- func (gf *GuestFile) Mkdir(name string, permissions p9.FileMode, uid p9.UID, gid p9.GID) (p9.QID, error)
- func (gf *GuestFile) Mknod(name string, mode p9.FileMode, _, _ uint32, uid p9.UID, gid p9.GID) (p9.QID, error)
- func (gf *GuestFile) UnlinkAt(name string, flags uint32) error
- func (gf *GuestFile) Walk(names []string) ([]p9.QID, p9.File, error)
- type GuestIdentifier
- type GuestOption
- type HostFile
- func (hf *HostFile) Create(name string, flags p9.OpenFlags, permissions p9.FileMode, uid p9.UID, ...) (p9.File, p9.QID, uint32, error)
- func (hd *HostFile) Mkdir(name string, permissions p9.FileMode, uid p9.UID, gid p9.GID) (p9.QID, error)
- func (hf *HostFile) Mknod(name string, mode p9.FileMode, _, _ uint32, uid p9.UID, gid p9.GID) (p9.QID, error)
- func (hd *HostFile) Walk(names []string) ([]p9.QID, p9.File, error)
- type HostIdentifier
- type HosterOption
- type Listener
- type ListenerOption
- type MakeGuestFunc
- type MakeHostFunc
- type MakeMountPointFunc
- type MountFile
- func (mf *MountFile) Create(name string, flags p9.OpenFlags, permissions p9.FileMode, uid p9.UID, ...) (p9.File, p9.QID, uint32, error)
- func (mf *MountFile) Mkdir(name string, permissions p9.FileMode, uid p9.UID, gid p9.GID) (p9.QID, error)
- func (mf *MountFile) Mknod(name string, mode p9.FileMode, _, _ uint32, uid p9.UID, gid p9.GID) (p9.QID, error)
- func (mf *MountFile) Walk(names []string) ([]p9.QID, p9.File, error)
- type MountPoint
- type MountPointFile
- func (mf *MountPointFile[MP]) Close() error
- func (mf *MountPointFile[MP]) FSync() error
- func (mf *MountPointFile[MP]) GetAttr(req p9.AttrMask) (p9.QID, p9.AttrMask, p9.Attr, error)
- func (mf *MountPointFile[MP]) Open(mode p9.OpenFlags) (p9.QID, ioUnit, error)
- func (mf *MountPointFile[MP]) ReadAt(p []byte, offset int64) (int, error)
- func (mf *MountPointFile[MP]) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error
- func (mf *MountPointFile[MP]) Walk(names []string) ([]p9.QID, p9.File, error)
- func (mf *MountPointFile[MP]) WriteAt(p []byte, offset int64) (int, error)
- type MountPointOption
- type Mounter
- type MounterOption
- type RenamedFunc
- type SystemMaker
Constants ¶
const ( ExecuteOther p9.FileMode = p9.Exec << iota WriteOther ReadOther ExecuteGroup WriteGroup ReadGroup ExecuteUser WriteUser ReadUser )
Permission mode bits.
Variables ¶
This section is empty.
Functions ¶
func GetListeners ¶
GetListeners returns a slice of maddrs that correspond to active listeners contained within the `listener` file.
func Listen ¶
TODO: [Ame] English. Listen tries to listen on the provided [Multiaddr]. If successful, the [Multiaddr] is mapped as a directory, inheriting permissions from parent directories all the way down. The passed permissions are used for the final API file.
func NewDirectory ¶
func ReadAll ¶
ReadAll performs the following sequence on file: clone, stat(size), open(read-only), read, close.
func UnlinkEmptyChildren ¶
func UnlinkEmptyChildren[ OT generic.OptionFunc[T], T any, I directorySetter[T], ](b bool, ) OT
UnlinkEmptyChildren sets UnlinkWhenEmpty on files created by this file.
func UnlinkWhenEmpty ¶
func UnlinkWhenEmpty[ OT generic.OptionFunc[T], T any, I directorySetter[T], ](b bool, ) OT
UnlinkWhenEmpty causes files to unlink from their parent after they are considered empty and the last reference held by a Walk has been closed.
func UnmountAll ¶
func UnmountTargets ¶
func UnmountTargets(mounts p9.File, mountPoints []string, decodeTargetFn DecodeTargetFunc, ) error
func WithBuffer ¶
func WithBuffer[ OT generic.OptionFunc[T], T any, I channelSetter[T], ](size int, ) OT
func WithGID ¶
func WithGID[ OT generic.OptionFunc[T], T any, I metadataSetter[T], ](gid p9.GID, ) OT
WithGID specifies a GID value for a file's status information.
func WithParent ¶
func WithPath ¶
func WithPath[ OT generic.OptionFunc[T], T any, I metadataSetter[T], ](path *atomic.Uint64, ) OT
WithPath specifies the path to be used by this file.
func WithPermissions ¶
func WithPermissions[ OT generic.OptionFunc[T], T any, I metadataSetter[T], ](permissions p9.FileMode, ) OT
WithPermissions specifies the permission bits for a file's mode status.
func WithRenamedFunc ¶
func WithRenamedFunc[ OT generic.OptionFunc[T], T any, I linkSetter[T], ](fn RenamedFunc, ) OT
WithRenamedFunc provides a callback which is called after a successful rename operation.
func WithUID ¶
func WithUID[ OT generic.OptionFunc[T], T any, I metadataSetter[T], ](uid p9.UID, ) OT
WithUID specifies a UID value for a file's status information.
func WithoutRename ¶
func WithoutRename[ OT generic.OptionFunc[T], T any, I linkSetter[T], ](disabled bool, ) OT
WithoutRename causes rename operations to return an error when called.
Types ¶
type ChannelFile ¶
type ChannelFile struct { templatefs.NoopFile // contains filtered or unexported fields }
func NewChannelFile ¶
func NewChannelFile(ctx context.Context, options ...ChannelOption, ) (p9.QID, *ChannelFile, <-chan []byte, error)
func (*ChannelFile) Close ¶
func (cf *ChannelFile) Close() error
func (*ChannelFile) SetAttr ¶
func (cf *ChannelFile) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error
type ChannelOption ¶
type ChannelOption func(*channelFileSettings) error
type ConnInfo ¶
type ConnInfo struct { LastRead time.Time `json:"lastRead"` LastWrite time.Time `json:"lastWrite"` Local multiaddr.Multiaddr `json:"local"` Remote multiaddr.Multiaddr `json:"remote"` ID uintptr `json:"#"` }
func GetConnections ¶
GetConnections returns a slice of info that corresponds to active connections contained within the `listener` file.
func (*ConnInfo) UnmarshalJSON ¶
type DecodeTargetFunc ¶
type DecodeTargetFunc func(filesystem.Host, filesystem.ID, []byte) (string, error)
DecodeTargetFunc will be called with bytes representing an encoded mount point, and should decode then return the mount point's target. Under typical operation, the encoded data should have the same format as the argument passed to [Client.Mount]. However, this is not guaranteed; as different clients with different formats may call `Mount` and `Unmount` independently.
type Directory ¶
type Directory struct { templatefs.NoopFile // contains filtered or unexported fields }
type DirectoryOption ¶
type DirectoryOption func(*directorySettings) error
type FieldError ¶
FieldError describes which key was searched for and the available fields which were tried. Useful for chaining [FieldParser.ParseField] calls with errors.As.
func (FieldError) Error ¶
func (fe FieldError) Error() string
type FieldParser ¶
FieldParser should parse and assign its inputs. Returning either a FieldError if the key is not applicable, or any other error if the value is invalid.
type GuestFile ¶
type GuestFile struct {
// contains filtered or unexported fields
}
func NewGuestFile ¶
func NewGuestFile(makeMountPointFn MakeMountPointFunc, options ...GuestOption, ) (p9.QID, *GuestFile, error)
func (*GuestFile) Mkdir ¶
func (gf *GuestFile) Mkdir(name string, permissions p9.FileMode, uid p9.UID, gid p9.GID) (p9.QID, error)
TODO: stub out [Link] too?
type GuestIdentifier ¶
type GuestIdentifier interface {
GuestID() filesystem.ID
}
type GuestOption ¶
type GuestOption func(*guestSettings) error
type HostFile ¶
type HostFile struct {
// contains filtered or unexported fields
}
func NewHostFile ¶
func NewHostFile(makeGuestFn MakeGuestFunc, options ...HosterOption, ) (p9.QID, *HostFile, error)
type HostIdentifier ¶
type HostIdentifier interface {
HostID() filesystem.Host
}
type HosterOption ¶
type HosterOption func(*hosterSettings) error
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
func NewListener ¶
type ListenerOption ¶
type ListenerOption func(*listenerSettings) error
type MakeGuestFunc ¶
type MakeGuestFunc func(parent p9.File, guest filesystem.ID, mode p9.FileMode, uid p9.UID, gid p9.GID) (p9.QID, p9.File, error)
MakeGuestFunc should handle file creation operations for files representing a filesystem.ID. The file `mode` will contain file type bits.
type MakeHostFunc ¶
type MakeHostFunc func(parent p9.File, host filesystem.Host, mode p9.FileMode, uid p9.UID, gid p9.GID) (p9.QID, p9.File, error)
MakeHostFunc should handle file creation operations for files representing a filesystem.Host. The file `mode` will contain file type bits.
type MakeMountPointFunc ¶
type MakeMountPointFunc func(parent p9.File, name string, mode p9.FileMode, uid p9.UID, gid p9.GID, ) (p9.QID, p9.File, error)
MakeMountPointFunc should handle file creation operations for files representing mount points. The file `mode` will contain file type bits.
type MountFile ¶
type MountFile struct {
// contains filtered or unexported fields
}
func NewMounter ¶
func NewMounter(makeHostFn MakeHostFunc, options ...MounterOption) (p9.QID, *MountFile, error)
type MountPoint ¶
type MountPoint interface { SystemMaker Mounter HostIdentifier GuestIdentifier }
type MountPointFile ¶
type MountPointFile[MP MountPoint] struct { // contains filtered or unexported fields }
func NewMountPoint ¶
func NewMountPoint[ MP interface { *T MountPoint }, T any, ](options ...MountPointOption, ) (p9.QID, *MountPointFile[MP], error)
func (*MountPointFile[MP]) Close ¶
func (mf *MountPointFile[MP]) Close() error
func (*MountPointFile[MP]) FSync ¶
func (mf *MountPointFile[MP]) FSync() error
func (*MountPointFile[MP]) ReadAt ¶
func (mf *MountPointFile[MP]) ReadAt(p []byte, offset int64) (int, error)
func (*MountPointFile[MP]) SetAttr ¶
func (mf *MountPointFile[MP]) SetAttr(valid p9.SetAttrMask, attr p9.SetAttr) error
type MountPointOption ¶
type MountPointOption func(*fileSettings) error
type MounterOption ¶
type MounterOption func(*mounterSettings) error
type RenamedFunc ¶
type RenamedFunc func(old, new string)