ramfs

package
v0.0.0-...-ff2c174 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package ramfs provides the fundamentals for a simple in-memory filesystem.

Index

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.

func Rename

func Rename(ctx context.Context, oldParent fs.InodeOperations, oldName string, newParent fs.InodeOperations, newName string, replacement bool) error

Rename renames from a *ramfs.Dir to another *ramfs.Dir.

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

func (d *Dir) AddChild(ctx context.Context, name string, inode *fs.Inode)

AddChild adds a child to this dir, inheriting its reference.

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

func (d *Dir) Children() ([]string, map[string]fs.DentAttr)

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 (d *Dir) CreateHardLink(ctx context.Context, dir *fs.Inode, target *fs.Inode, name string) error

CreateHardLink creates a new hard link.

func (d *Dir) CreateLink(ctx context.Context, dir *fs.Inode, oldname, newname string) error

CreateLink returns a new link.

func (*Dir) FindChild

func (d *Dir) FindChild(name string) (*fs.Inode, bool)

FindChild returns (child, true) if the directory contains name.

func (*Dir) GetFile

func (d *Dir) GetFile(ctx context.Context, dirent *fs.Dirent, flags fs.FileFlags) (*fs.File, error)

GetFile implements fs.InodeOperations.GetFile.

func (*Dir) Lookup

func (d *Dir) Lookup(ctx context.Context, _ *fs.Inode, p string) (*fs.Dirent, error)

Lookup loads an inode at p into a Dirent. It returns the fs.Dirent along with a reference.

func (*Dir) Release

func (d *Dir) Release(ctx context.Context)

Release implements fs.InodeOperation.Release.

func (*Dir) Remove

func (d *Dir) Remove(ctx context.Context, _ *fs.Inode, name string) error

Remove removes the named non-directory.

func (*Dir) RemoveDirectory

func (d *Dir) RemoveDirectory(ctx context.Context, _ *fs.Inode, name string) error

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 (d *Dir) StateFields() []string

func (*Dir) StateLoad

func (d *Dir) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*Dir) StateSave

func (d *Dir) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*Dir) StateTypeName

func (d *Dir) StateTypeName() string

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

func (s *Socket) BoundEndpoint(*fs.Inode, string) transport.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 (s *Socket) StateFields() []string

func (*Socket) StateLoad

func (s *Socket) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*Socket) StateSave

func (s *Socket) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*Socket) StateTypeName

func (s *Socket) StateTypeName() string
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(ctx context.Context, owner fs.FileOwner, target string) *Symlink

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(context.Context, *fs.Inode) (*fs.Dirent, error)

Getlink returns ErrResolveViaReadlink, falling back to walking to the result of Readlink().

func (s *Symlink) Readlink(ctx context.Context, _ *fs.Inode) (string, error)

Readlink reads the symlink value.

func (*Symlink) SetPermissions

func (s *Symlink) SetPermissions(context.Context, *fs.Inode, fs.FilePermissions) bool

SetPermissions on a symlink is always rejected.

func (*Symlink) StateFields

func (s *Symlink) StateFields() []string

func (*Symlink) StateLoad

func (s *Symlink) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*Symlink) StateSave

func (s *Symlink) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*Symlink) StateTypeName

func (s *Symlink) StateTypeName() string

func (*Symlink) UnstableAttr

func (s *Symlink) UnstableAttr(ctx context.Context, inode *fs.Inode) (fs.UnstableAttr, error)

UnstableAttr returns all attributes of this ramfs symlink.

Jump to

Keyboard shortcuts

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