overlay

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRootlessOverlay = errors.New("rootless overlay not supported by kernel")

Functions

func AbsOverlay

func AbsOverlay(desc string) (string, error)

AbsOverlay takes an overlay description string (a path, optionally followed by a colon with an option string, like ":ro" or ":rw"), and replaces any relative path in the description string with an absolute one.

func CheckLower

func CheckLower(path string) error

CheckLower checks if the underlying filesystem of the provided path can be used as lower overlay directory.

func CheckRootless

func CheckRootless() error

CheckRootless checks whether the kernel overlay driver supports unprivileged use in a user namespace.

func CheckUpper

func CheckUpper(path string) error

CheckUpper checks if the underlying filesystem of the provided path can be used as an upper overlay directory.

func DetachAndDelete

func DetachAndDelete(overlayDir string) error

detachAndDelete performs an unmount system call on the specified directory, followed by deletion of the directory and all of its contents.

func DetachMount

func DetachMount(ctx context.Context, dir string) error

DetachMount performs an unmount system call on the specified directory.

func EnsureOverlayDir

func EnsureOverlayDir(dir string, createIfMissing bool, createPerm os.FileMode) error

ensureOverlayDir checks if a directory already exists; if it doesn't, and createIfMissing is true, it attempts to create it with the specified permissions.

func IsIncompatible

func IsIncompatible(err error) bool

IsIncompatible returns if the error corresponds to an incompatible filesystem error.

func UnprivOverlaysSupported

func UnprivOverlaysSupported() (bool, error)

UnprivOverlaysSupported checks whether there is kernel support for unprivileged overlays. The actual check is performed only once and cached in the unprivOverlays variable, above.

Types

type Item

type Item struct {
	// Type represents what type of overlay this is (from among the values in
	// pkg/image)
	Type int

	// Readonly represents whether this is a readonly overlay
	Readonly bool

	// SourcePath is the path of the overlay item, stripped of any
	// colon-prefixed options (like ":ro")
	SourcePath string

	// SourceOffset is the (optional) offset of the overlay filesystem within
	// SourcePath, in bytes.
	SourceOffset int64

	// StagingDir is the directory on which this overlay item is staged, to be
	// used as a source for an overlayfs mount as part of an overlay.Set
	StagingDir string
	// contains filtered or unexported fields
}

Item represents information about a single overlay item (as specified, for example, in a single --overlay argument)

func NewItemFromString

func NewItemFromString(overlayString string) (*Item, error)

NewItemFromString takes a string argument, as passed to --overlay, and returns an Item struct describing the requested overlay.

func (Item) GetMountDir

func (i Item) GetMountDir() string

GetMountDir returns the path to the directory that will actually be mounted for this overlay. For squashfs overlays, this is equivalent to the Item.StagingDir field. But for all other overlays, it is the "upper" subdirectory of Item.StagingDir.

func (*Item) GetParentDir

func (i *Item) GetParentDir() (string, error)

GetParentDir gets a parent-dir in which to create overlay-specific mount directories. If one has not been set using SetParentDir(), one will be created using os.MkdirTemp().

func (*Item) Mount

func (i *Item) Mount(ctx context.Context) error

Mount performs the necessary steps to mount an individual Item. Note that this method does not mount the assembled overlay itself. That happens in Set.Mount().

func (*Item) SetAllowDev

func (i *Item) SetAllowDev(a bool)

SetAllowDev sets whether to allow devices on the mount for this item.

func (*Item) SetAllowSetuid

func (i *Item) SetAllowSetuid(a bool)

SetAllowSetuid sets whether to allow setuid binaries on the mount for this item.

func (*Item) SetParentDir

func (i *Item) SetParentDir(d string)

SetParentDir sets the parent-dir in which to create overlay-specific mount directories.

func (Item) Unmount

func (i Item) Unmount(ctx context.Context) error

Unmount performs the necessary steps to unmount an individual Item. Note that this method does not unmount the overlay itself. That happens in Set.Unmount().

func (Item) Upper

func (i Item) Upper() string

Upper returns the "upper"-subdir of the Item's DirToMount field. Useful for computing options strings for overlay-related mount system calls.

func (Item) Work

func (i Item) Work() string

Work returns the "work"-subdir of the Item's DirToMount field. Useful for computing options strings for overlay-related mount system calls.

type Set

type Set struct {
	// ReadonlyOverlays is a list of directories to be mounted as read-only
	// overlays. The mount point atop which these will be mounted is left
	// implicit, to be chosen by whichever function consumes the Set.
	ReadonlyOverlays []*Item

	// WritableOverlay is the directory to be mounted as a writable overlay. The
	// mount point atop which this will be mounted is left implicit, to be
	// chosen by whichever function consumes the Set. Empty value indicates no
	// writable overlay is to be mounted.
	WritableOverlay *Item
}

Set represents a set of overlay directories which will be overlain on top of some filesystem mount point. The actual mount point atop which these directories will be overlain is not specified in the Set; it is left implicit, to be chosen by whichever function consumes a Set. A Set contains two types of directories: zero or more directories which will be mounted as read-only overlays atop the (implicit) mount point, and one directory which will be mounted as a writable overlay atop all the rest. An empty WritableLoc field indicates that no writable overlay is to be mounted.

func (Set) Mount

func (s Set) Mount(ctx context.Context, rootFsDir string) error

Mount prepares and mounts the entire Set onto the specified rootfs directory.

func (Set) Unmount

func (s Set) Unmount(ctx context.Context, rootFsDir string) error

UnmountOverlay ummounts a Set from a specified rootfs directory.

Jump to

Keyboard shortcuts

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