Documentation ¶
Overview ¶
Package ramfs provides the fundamentals for a simple in-memory filesystem.
Index ¶
- 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 transport.BoundEndpoint, ...) (*fs.Dirent, error)
- func (d *Dir) Children() ([]string, map[string]fs.DentAttr)
- 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 (d *Dir) FindChild(name string) (*fs.Inode, bool)
- func (d *Dir) GetFile(ctx context.Context, dirent *fs.Dirent, flags fs.FileFlags) (*fs.File, error)
- func (d *Dir) Lookup(ctx context.Context, _ *fs.Inode, p string) (*fs.Dirent, error)
- func (d *Dir) Release(ctx context.Context)
- func (d *Dir) Remove(ctx context.Context, _ *fs.Inode, name string) error
- func (d *Dir) RemoveDirectory(ctx context.Context, _ *fs.Inode, name string) error
- func (*Dir) Rename(ctx context.Context, inode *fs.Inode, oldParent *fs.Inode, oldName string, ...) error
- func (d *Dir) StateFields() []string
- func (d *Dir) StateLoad(stateSourceObject state.Source)
- func (d *Dir) StateSave(stateSinkObject state.Sink)
- func (d *Dir) StateTypeName() string
- type Socket
- func (s *Socket) BoundEndpoint(*fs.Inode, string) transport.BoundEndpoint
- func (s *Socket) GetFile(ctx context.Context, dirent *fs.Dirent, flags fs.FileFlags) (*fs.File, error)
- func (s *Socket) StateFields() []string
- func (s *Socket) StateLoad(stateSourceObject state.Source)
- func (s *Socket) StateSave(stateSinkObject state.Sink)
- func (s *Socket) StateTypeName() string
- type Symlink
- func (s *Symlink) GetFile(ctx context.Context, dirent *fs.Dirent, flags fs.FileFlags) (*fs.File, error)
- func (*Symlink) Getlink(context.Context, *fs.Inode) (*fs.Dirent, error)
- 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) StateFields() []string
- func (s *Symlink) StateLoad(stateSourceObject state.Source)
- func (s *Symlink) StateSave(stateSinkObject state.Sink)
- func (s *Symlink) StateTypeName() string
- func (s *Symlink) UnstableAttr(ctx context.Context, inode *fs.Inode) (fs.UnstableAttr, error)
Constants ¶
This section is empty.
Variables ¶
This section is 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 "/".
All directories in the created tree will have full (read-write-execute) permissions, but note that file creation inside the directories is not actually supported because ramfs.Dir.CreateOpts == nil. However, these directory trees are normally "underlayed" under another filesystem (possibly the root), and file creation inside these directories in the overlay will be possible if the upper is writeable.
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 transport.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 { fsutil.InodeGenericChecker `state:"nosave"` fsutil.InodeIsDirAllocate `state:"nosave"` fsutil.InodeIsDirTruncate `state:"nosave"` fsutil.InodeNoopWriteOut `state:"nosave"` fsutil.InodeNotMappable `state:"nosave"` fsutil.InodeNotSocket `state:"nosave"` fsutil.InodeNotSymlink `state:"nosave"` fsutil.InodeVirtual `state:"nosave"` fsutil.InodeSimpleAttributes fsutil.InodeSimpleExtendedAttributes // 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.
+stateify savable
func NewDir ¶
func NewDir(ctx context.Context, contents map[string]*fs.Inode, owner fs.FileOwner, perms fs.FilePermissions) *Dir
NewDir returns a new Dir with the given contents and attributes. A reference on each fs.Inode in the `contents` map will be donated to this Dir.
func (*Dir) Bind ¶
func (d *Dir) Bind(ctx context.Context, dir *fs.Inode, name string, ep transport.BoundEndpoint, perms fs.FilePermissions) (*fs.Dirent, error)
Bind implements fs.InodeOperations.Bind.
func (*Dir) Children ¶
Children returns the names and DentAttrs of all children. It can be used to implement Readdir for types that embed ramfs.Dir.
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) Lookup ¶
Lookup loads an inode at p into a Dirent. It returns the fs.Dirent along with a reference.
func (*Dir) RemoveDirectory ¶
RemoveDirectory removes the named directory.
func (*Dir) Rename ¶
func (*Dir) Rename(ctx context.Context, inode *fs.Inode, oldParent *fs.Inode, oldName string, newParent *fs.Inode, newName string, replacement bool) error
Rename implements fs.InodeOperations.Rename.
func (*Dir) StateFields ¶
func (*Dir) StateTypeName ¶
type Socket ¶
type Socket struct { fsutil.InodeGenericChecker `state:"nosave"` fsutil.InodeNoopRelease `state:"nosave"` fsutil.InodeNoopWriteOut `state:"nosave"` fsutil.InodeNotAllocatable `state:"nosave"` fsutil.InodeNotDirectory `state:"nosave"` fsutil.InodeNotMappable `state:"nosave"` fsutil.InodeNotSymlink `state:"nosave"` fsutil.InodeNotTruncatable `state:"nosave"` fsutil.InodeVirtual `state:"nosave"` fsutil.InodeSimpleAttributes fsutil.InodeSimpleExtendedAttributes // contains filtered or unexported fields }
Socket represents a socket.
+stateify savable
func NewSocket ¶
func NewSocket(ctx context.Context, ep transport.BoundEndpoint, owner fs.FileOwner, perms fs.FilePermissions) *Socket
NewSocket returns a new Socket.
func (*Socket) BoundEndpoint ¶
BoundEndpoint returns the socket data.
func (*Socket) GetFile ¶
func (s *Socket) GetFile(ctx context.Context, dirent *fs.Dirent, flags fs.FileFlags) (*fs.File, error)
GetFile implements fs.FileOperations.GetFile.
func (*Socket) StateFields ¶
func (*Socket) StateTypeName ¶
type Symlink ¶
type Symlink struct { fsutil.InodeGenericChecker `state:"nosave"` fsutil.InodeNoopRelease `state:"nosave"` fsutil.InodeNoopWriteOut `state:"nosave"` fsutil.InodeNotAllocatable `state:"nosave"` fsutil.InodeNotDirectory `state:"nosave"` fsutil.InodeNotMappable `state:"nosave"` fsutil.InodeNotSocket `state:"nosave"` fsutil.InodeNotTruncatable `state:"nosave"` fsutil.InodeVirtual `state:"nosave"` fsutil.InodeSimpleAttributes fsutil.InodeSimpleExtendedAttributes // Target is the symlink target. Target string }
Symlink represents a symlink.
+stateify savable
func NewSymlink ¶
NewSymlink returns a new Symlink.
func (*Symlink) GetFile ¶
func (s *Symlink) GetFile(ctx context.Context, dirent *fs.Dirent, flags fs.FileFlags) (*fs.File, error)
GetFile implements fs.FileOperations.GetFile.
func (*Symlink) Getlink ¶
Getlink returns ErrResolveViaReadlink, falling back to walking to the result of Readlink().
func (*Symlink) SetPermissions ¶
SetPermissions on a symlink is always rejected.
func (*Symlink) StateFields ¶
func (*Symlink) StateTypeName ¶
func (*Symlink) UnstableAttr ¶
UnstableAttr returns all attributes of this ramfs symlink.