Documentation ¶
Overview ¶
Package ramfs implements an in-memory file system that can be associated with any device.
Index ¶
- Variables
- func MakeDirectoryTree(ctx context.Context, msrc *fs.MountSource, subdirs []string) (*fs.Inode, error)
- func Rename(ctx context.Context, oldParent fs.InodeOperations, oldName string, ...) error
- type CreateOps
- type Dir
- func (d *Dir) AddChild(ctx context.Context, name string, inode *fs.Inode)
- func (d *Dir) Bind(ctx context.Context, dir *fs.Inode, name string, ep unix.BoundEndpoint, ...) error
- func (d *Dir) Create(ctx context.Context, dir *fs.Inode, name string, flags fs.FileFlags, ...) (*fs.File, error)
- func (d *Dir) CreateDirectory(ctx context.Context, dir *fs.Inode, name string, perms fs.FilePermissions) error
- func (d *Dir) CreateFifo(ctx context.Context, dir *fs.Inode, name string, perms fs.FilePermissions) error
- func (d *Dir) CreateHardLink(ctx context.Context, dir *fs.Inode, target *fs.Inode, name string) error
- func (d *Dir) CreateLink(ctx context.Context, dir *fs.Inode, oldname, newname string) error
- func (*Dir) DeprecatedPreadv(context.Context, usermem.IOSequence, int64) (int64, error)
- func (*Dir) DeprecatedPwritev(context.Context, usermem.IOSequence, int64) (int64, error)
- func (d *Dir) DeprecatedReaddir(ctx context.Context, dirCtx *fs.DirCtx, offset int) (int, error)
- func (d *Dir) FindChild(name string) (*fs.Inode, bool)
- func (d *Dir) InitDir(ctx context.Context, contents map[string]*fs.Inode, owner fs.FileOwner, ...)
- func (d *Dir) Lookup(ctx context.Context, dir *fs.Inode, p string) (*fs.Dirent, error)
- func (d *Dir) Remove(ctx context.Context, dir *fs.Inode, name string) error
- func (d *Dir) RemoveDirectory(ctx context.Context, dir *fs.Inode, name string) error
- func (d *Dir) RemoveEntry(ctx context.Context, name string) error
- type Entry
- func (e *Entry) AccessTime() ktime.Time
- func (e *Entry) AddLink()
- func (*Entry) Bind(context.Context, *fs.Inode, string, unix.BoundEndpoint, fs.FilePermissions) error
- func (*Entry) Check(ctx context.Context, inode *fs.Inode, p fs.PermMask) bool
- func (*Entry) Create(context.Context, *fs.Inode, string, fs.FileFlags, fs.FilePermissions) (*fs.File, error)
- func (*Entry) CreateDirectory(context.Context, *fs.Inode, string, fs.FilePermissions) error
- func (*Entry) CreateFifo(context.Context, *fs.Inode, string, fs.FilePermissions) error
- func (*Entry) CreateHardLink(context.Context, *fs.Inode, *fs.Inode, string) error
- func (*Entry) CreateLink(context.Context, *fs.Inode, string, string) error
- func (*Entry) DeprecatedFlush() error
- func (*Entry) DeprecatedFsync() error
- func (*Entry) DeprecatedMappable(context.Context, *fs.Inode) (memmap.Mappable, bool)
- func (*Entry) DeprecatedPreadv(context.Context, usermem.IOSequence, int64) (int64, error)
- func (*Entry) DeprecatedPwritev(context.Context, usermem.IOSequence, int64) (int64, error)
- func (*Entry) DeprecatedReaddir(context.Context, *fs.DirCtx, int) (int, error)
- func (e *Entry) DropLink()
- func (*Entry) GetFile(ctx context.Context, d *fs.Dirent, flags fs.FileFlags) (*fs.File, error)
- func (*Entry) Getlink(context.Context, *fs.Inode) (*fs.Dirent, error)
- func (e *Entry) Getxattr(inode *fs.Inode, name string) ([]byte, error)
- func (e *Entry) InitEntry(ctx context.Context, owner fs.FileOwner, p fs.FilePermissions)
- func (e *Entry) InitEntryWithAttr(ctx context.Context, uattr fs.UnstableAttr)
- func (*Entry) IsVirtual() bool
- func (e *Entry) Listxattr(inode *fs.Inode) (map[string]struct{}, error)
- func (*Entry) Lookup(context.Context, *fs.Inode, string) (*fs.Dirent, error)
- func (e *Entry) ModificationTime() ktime.Time
- func (e *Entry) NotifyAccess(ctx context.Context)
- func (e *Entry) NotifyModification(ctx context.Context)
- func (e *Entry) NotifyStatusChange(ctx context.Context)
- func (e *Entry) Permissions() fs.FilePermissions
- func (*Entry) Readlink(context.Context, *fs.Inode) (string, error)
- func (e *Entry) Release(context.Context)
- func (*Entry) Remove(context.Context, *fs.Inode, string) error
- func (*Entry) RemoveDirectory(context.Context, *fs.Inode, string) error
- func (e *Entry) Rename(ctx context.Context, oldParent *fs.Inode, oldName string, newParent *fs.Inode, ...) error
- func (e *Entry) SetOwner(ctx context.Context, inode *fs.Inode, owner fs.FileOwner) error
- func (e *Entry) SetPermissions(ctx context.Context, inode *fs.Inode, p fs.FilePermissions) bool
- func (e *Entry) SetTimestamps(ctx context.Context, inode *fs.Inode, ts fs.TimeSpec) error
- func (e *Entry) Setxattr(inode *fs.Inode, name string, value []byte) error
- func (*Entry) StatFS(context.Context) (fs.Info, error)
- func (e *Entry) StatusChangeTime() ktime.Time
- func (*Entry) Truncate(context.Context, *fs.Inode, int64) error
- func (e *Entry) UnstableAttr(ctx context.Context, inode *fs.Inode) (fs.UnstableAttr, error)
- type File
- func (f *File) Append(data []byte)
- func (f *File) DeprecatedPreadv(ctx context.Context, dst usermem.IOSequence, offset int64) (int64, error)
- func (f *File) DeprecatedPwritev(ctx context.Context, src usermem.IOSequence, offset int64) (int64, error)
- func (f *File) InitFile(ctx context.Context, owner fs.FileOwner, perms fs.FilePermissions)
- func (f *File) ReadAt(data []byte, offset int64) (int, error)
- func (f *File) Truncate(ctx context.Context, inode *fs.Inode, l int64) error
- func (f *File) UnstableAttr(ctx context.Context, inode *fs.Inode) (fs.UnstableAttr, error)
- func (f *File) WriteAt(data []byte, offset int64) (int, error)
- type Socket
- type Symlink
- func (s *Symlink) Check(ctx context.Context, inode *fs.Inode, p fs.PermMask) bool
- func (*Symlink) Getlink(context.Context, *fs.Inode) (*fs.Dirent, error)
- func (s *Symlink) InitSymlink(ctx context.Context, owner fs.FileOwner, target string)
- func (s *Symlink) Readlink(ctx context.Context, _ *fs.Inode) (string, error)
- func (s *Symlink) SetPermissions(context.Context, *fs.Inode, fs.FilePermissions) bool
- func (s *Symlink) UnstableAttr(ctx context.Context, inode *fs.Inode) (fs.UnstableAttr, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidOp indicates the operation is not valid. ErrInvalidOp = errors.New("invalid operation") // ErrDenied indicates the operation was denid. ErrDenied = errors.New("operation denied") // ErrNotFound indicates that a node was not found on a walk. ErrNotFound = errors.New("node not found") // ErrCrossDevice indicates a cross-device link or rename. ErrCrossDevice = errors.New("can't link across filesystems") // ErrIsDirectory indicates that the operation failed because // the node is a directory. ErrIsDirectory = errors.New("is a directory") // ErrNotDirectory indicates that the operation failed because // the node is a not directory. ErrNotDirectory = errors.New("not a directory") // ErrNotEmpty indicates that the operation failed because the // directory is not empty. ErrNotEmpty = errors.New("directory not empty") )
Functions ¶
func MakeDirectoryTree ¶
func MakeDirectoryTree(ctx context.Context, msrc *fs.MountSource, subdirs []string) (*fs.Inode, error)
MakeDirectoryTree constructs a ramfs tree of all directories containing subdirs. Each element of subdir must be a clean path, and cannot be empty or "/".
Types ¶
type CreateOps ¶
type CreateOps struct { // NewDir creates a new directory. NewDir func(ctx context.Context, dir *fs.Inode, perms fs.FilePermissions) (*fs.Inode, error) // NewFile creates a new file. NewFile func(ctx context.Context, dir *fs.Inode, perms fs.FilePermissions) (*fs.Inode, error) // NewSymlink creates a new symlink with permissions 0777. NewSymlink func(ctx context.Context, dir *fs.Inode, target string) (*fs.Inode, error) // NewBoundEndpoint creates a new socket. NewBoundEndpoint func(ctx context.Context, dir *fs.Inode, ep unix.BoundEndpoint, perms fs.FilePermissions) (*fs.Inode, error) // NewFifo creates a new fifo. NewFifo func(ctx context.Context, dir *fs.Inode, perm fs.FilePermissions) (*fs.Inode, error) }
CreateOps represents operations to create different file types.
type Dir ¶
type Dir struct { Entry // CreateOps may be provided. // // These may only be modified during initialization (while the application // is not running). No sychronization is performed when accessing these // operations during syscalls. *CreateOps `state:"nosave"` // contains filtered or unexported fields }
Dir represents a single directory in the filesystem.
func (*Dir) Bind ¶
func (d *Dir) Bind(ctx context.Context, dir *fs.Inode, name string, ep unix.BoundEndpoint, perms fs.FilePermissions) error
Bind implements fs.InodeOperations.Bind.
func (*Dir) Create ¶
func (d *Dir) Create(ctx context.Context, dir *fs.Inode, name string, flags fs.FileFlags, perms fs.FilePermissions) (*fs.File, error)
Create creates a new Inode with the given name and returns its File.
func (*Dir) CreateDirectory ¶
func (d *Dir) CreateDirectory(ctx context.Context, dir *fs.Inode, name string, perms fs.FilePermissions) error
CreateDirectory returns a new subdirectory.
func (*Dir) CreateFifo ¶
func (d *Dir) CreateFifo(ctx context.Context, dir *fs.Inode, name string, perms fs.FilePermissions) error
CreateFifo implements fs.InodeOperations.CreateFifo.
func (*Dir) CreateHardLink ¶
func (d *Dir) CreateHardLink(ctx context.Context, dir *fs.Inode, target *fs.Inode, name string) error
CreateHardLink creates a new hard link.
func (*Dir) CreateLink ¶
CreateLink returns a new link.
func (*Dir) DeprecatedPreadv ¶
DeprecatedPreadv always returns ErrIsDirectory
func (*Dir) DeprecatedPwritev ¶
DeprecatedPwritev always returns ErrIsDirectory
func (*Dir) DeprecatedReaddir ¶
DeprecatedReaddir emits the entries contained in this directory.
func (*Dir) InitDir ¶
func (d *Dir) InitDir(ctx context.Context, contents map[string]*fs.Inode, owner fs.FileOwner, perms fs.FilePermissions)
InitDir initializes a directory.
func (*Dir) RemoveDirectory ¶
RemoveDirectory removes the named directory.
type Entry ¶
type Entry struct { waiter.AlwaysReady `state:"nosave"` fsutil.NoMappable `state:"nosave"` fsutil.NoopWriteOut `state:"nosave"` fsutil.InodeNotSocket `state:"nosave"` // contains filtered or unexported fields }
Entry represents common internal state for file and directory nodes. This may be used by other packages to easily create ramfs files.
func (*Entry) AccessTime ¶
AccessTime returns the last access time for this node.
func (*Entry) Bind ¶
func (*Entry) Bind(context.Context, *fs.Inode, string, unix.BoundEndpoint, fs.FilePermissions) error
Bind is not supported by default.
func (*Entry) Create ¶
func (*Entry) Create(context.Context, *fs.Inode, string, fs.FileFlags, fs.FilePermissions) (*fs.File, error)
Create is not supported by default.
func (*Entry) CreateDirectory ¶
CreateDirectory is not supported by default.
func (*Entry) CreateFifo ¶
CreateFifo implements fs.InodeOperations.CreateFifo. CreateFifo is not supported by default.
func (*Entry) CreateHardLink ¶
CreateHardLink is not supported by default.
func (*Entry) CreateLink ¶
CreateLink is not supported by default.
func (*Entry) DeprecatedFlush ¶
DeprecatedFlush always returns nil.
func (*Entry) DeprecatedMappable ¶
DeprecatedMappable implements fs.InodeOperations.DeprecatedMappable.
func (*Entry) DeprecatedPreadv ¶
DeprecatedPreadv always returns ErrInvalidOp.
func (*Entry) DeprecatedPwritev ¶
DeprecatedPwritev always returns ErrInvalidOp.
func (*Entry) DeprecatedReaddir ¶
DeprecatedReaddir is not supported by default.
func (*Entry) InitEntryWithAttr ¶
func (e *Entry) InitEntryWithAttr(ctx context.Context, uattr fs.UnstableAttr)
InitEntryWithAttr initializes an entry with a complete set of attributes.
func (*Entry) ModificationTime ¶
ModificationTime returns the last modification time for this node.
func (*Entry) NotifyAccess ¶
NotifyAccess updates the access time.
func (*Entry) NotifyModification ¶
NotifyModification updates the modification time and the status change time.
func (*Entry) NotifyStatusChange ¶
NotifyStatusChange updates the status change time (ctime).
func (*Entry) Permissions ¶
func (e *Entry) Permissions() fs.FilePermissions
Permissions returns permissions on this entry.
func (*Entry) RemoveDirectory ¶
RemoveDirectory is not supported by default.
func (*Entry) Rename ¶
func (e *Entry) Rename(ctx context.Context, oldParent *fs.Inode, oldName string, newParent *fs.Inode, newName string) error
Rename implements fs.InodeOperations.Rename.
func (*Entry) SetPermissions ¶
SetPermissions always sets the permissions.
func (*Entry) SetTimestamps ¶
SetTimestamps sets the timestamps.
func (*Entry) StatusChangeTime ¶
StatusChangeTime returns the last status change time for this node.
func (*Entry) UnstableAttr ¶
UnstableAttr implements fs.InodeOperations.UnstableAttr.
type File ¶
type File struct { Entry // contains filtered or unexported fields }
File represents a unique file. It uses a simple byte slice as storage, and thus should only be used for small files.
A File is not mappable.
func (*File) DeprecatedPreadv ¶
func (f *File) DeprecatedPreadv(ctx context.Context, dst usermem.IOSequence, offset int64) (int64, error)
DeprecatedPreadv reads into a collection of slices from a given offset.
func (*File) DeprecatedPwritev ¶
func (f *File) DeprecatedPwritev(ctx context.Context, src usermem.IOSequence, offset int64) (int64, error)
DeprecatedPwritev writes from a collection of slices at a given offset.
func (*File) UnstableAttr ¶
UnstableAttr returns unstable attributes of this ramfs file.
type Socket ¶
type Socket struct { Entry // contains filtered or unexported fields }
Socket represents a socket.
func (*Socket) BoundEndpoint ¶
BoundEndpoint returns the socket data.
func (*Socket) InitSocket ¶
func (s *Socket) InitSocket(ctx context.Context, ep unix.BoundEndpoint, owner fs.FileOwner, perms fs.FilePermissions)
InitSocket initializes a socket.
type Symlink ¶
type Symlink struct { Entry // Target is the symlink target. Target string // contains filtered or unexported fields }
Symlink represents a symlink.
func (*Symlink) Getlink ¶
Getlink returns ErrResolveViaReadlink, falling back to walking to the result of Readlink().
func (*Symlink) InitSymlink ¶
InitSymlink initializes a symlink, pointing to the given target. A symlink is assumed to always have permissions 0777.
func (*Symlink) SetPermissions ¶
SetPermissions on a symlink is always rejected.
func (*Symlink) UnstableAttr ¶
UnstableAttr returns all attributes of this ramfs symlink.