tmpfs

package
v0.0.0-...-8516598 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0, MIT Imports: 29 Imported by: 19

Documentation

Overview

Package tmpfs provides an in-memory filesystem whose contents are application-mutable, consistent with Linux's tmpfs.

Lock order:

filesystem.mu
	inode.mu
	  regularFileFD.offMu
	    *** "memmap.Mappable/MappingIdentity locks" below this point
	    regularFile.mapsMu
	      *** "memmap.Mappable locks taken by Translate" below this point
	      regularFile.dataMu
	        fs.pagesUsedMu
	    filesystem.ancestryMu
	  directory.iterMu

Index

Constants

View Source
const Name = "tmpfs"

Name is the default filesystem name.

Variables

This section is empty.

Functions

func AddSeals

func AddSeals(fd *vfs.FileDescription, val uint32) error

AddSeals adds new file seals to a memfd inode.

func GetSeals

func GetSeals(fd *vfs.FileDescription) (uint32, error)

GetSeals returns the current set of seals on a memfd inode.

func NewMemfd

func NewMemfd(ctx context.Context, creds *auth.Credentials, mount *vfs.Mount, allowSeals bool, name string) (*vfs.FileDescription, error)

NewMemfd creates a new regular file and file description as for memfd_create.

Preconditions: mount must be a tmpfs mount.

func NewZeroFile

func NewZeroFile(ctx context.Context, creds *auth.Credentials, mount *vfs.Mount, size uint64) (*vfs.FileDescription, error)

NewZeroFile creates a new regular file and file description as for mmap(MAP_SHARED | MAP_ANONYMOUS). The file has the given size and is initially (implicitly) filled with zeroes.

Preconditions: mount must be a tmpfs mount.

func SetDefaultSizeLimit

func SetDefaultSizeLimit(sizeLimit uint64)

SetDefaultSizeLimit configures the size limit to be used for tmpfs mounts that do not specify a size= mount option. This must be called only once, before any tmpfs filesystems are created.

Types

type FilesystemOpts

type FilesystemOpts struct {
	// RootFileType is the FileType of the filesystem root. Valid values
	// are: S_IFDIR, S_IFREG, and S_IFLNK. Defaults to S_IFDIR.
	RootFileType uint16

	// RootSymlinkTarget is the target of the root symlink. Only valid if
	// RootFileType == S_IFLNK.
	RootSymlinkTarget string

	// FilesystemType allows setting a different FilesystemType for this
	// tmpfs filesystem. This allows tmpfs to "impersonate" other
	// filesystems, like ramdiskfs and cgroupfs.
	FilesystemType vfs.FilesystemType

	// Usage is the memory accounting category under which pages backing files in
	// the filesystem are accounted.
	Usage *usage.MemoryKind

	// MaxFilenameLen is the maximum filename length allowed by the tmpfs.
	MaxFilenameLen int

	// MemoryFile is the memory file that will be used to store file data. If
	// this is nil, then MemoryFileFromContext() is used.
	MemoryFile *pgalloc.MemoryFile

	// DisableDefaultSizeLimit disables setting a default size limit. In Linux,
	// SB_KERNMOUNT has this effect on tmpfs mounts; see mm/shmem.c:shmem_fill_super().
	DisableDefaultSizeLimit bool

	// AllowXattrPrefix is a set of xattr namespace prefixes that this
	// tmpfs mount will allow.
	AllowXattrPrefix []string
}

FilesystemOpts is used to pass configuration data to tmpfs.

+stateify savable

type FilesystemType

type FilesystemType struct{}

FilesystemType implements vfs.FilesystemType.

+stateify savable

func (FilesystemType) GetFilesystem

func (fstype FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.VirtualFilesystem, creds *auth.Credentials, _ string, opts vfs.GetFilesystemOptions) (*vfs.Filesystem, *vfs.Dentry, error)

GetFilesystem implements vfs.FilesystemType.GetFilesystem.

func (FilesystemType) Name

func (FilesystemType) Name() string

Name implements vfs.FilesystemType.Name.

func (FilesystemType) Release

func (FilesystemType) Release(ctx context.Context)

Release implements vfs.FilesystemType.Release.

Jump to

Keyboard shortcuts

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