Documentation ¶
Index ¶
- Variables
- func AbsOverlay(desc string) (string, error)
- func CheckLower(path string) error
- func CheckRootless() error
- func CheckUpper(path string) error
- func DetachAndDelete(overlayDir string) error
- func DetachMount(ctx context.Context, dir string) error
- func EnsureOverlayDir(dir string, createIfMissing bool, createPerm os.FileMode) error
- func IsIncompatible(err error) bool
- func UnprivOverlaysSupported() (bool, error)
- type Item
- func (i Item) GetMountDir() string
- func (i *Item) GetParentDir() (string, error)
- func (i *Item) Mount(ctx context.Context) error
- func (i *Item) SetAllowDev(a bool)
- func (i *Item) SetAllowSetuid(a bool)
- func (i *Item) SetParentDir(d string)
- func (i Item) Unmount(ctx context.Context) error
- func (i Item) Upper() string
- func (i Item) Work() string
- type Set
Constants ¶
This section is empty.
Variables ¶
var ErrNoRootlessOverlay = errors.New("rootless overlay not supported by kernel")
Functions ¶
func AbsOverlay ¶
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 ¶
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 ¶
CheckUpper checks if the underlying filesystem of the provided path can be used as an upper overlay directory.
func DetachAndDelete ¶
detachAndDelete performs an unmount system call on the specified directory, followed by deletion of the directory and all of its contents.
func DetachMount ¶
DetachMount performs an unmount system call on the specified directory.
func EnsureOverlayDir ¶
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 ¶
IsIncompatible returns if the error corresponds to an incompatible filesystem error.
func UnprivOverlaysSupported ¶
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 ¶
NewItemFromString takes a string argument, as passed to --overlay, and returns an Item struct describing the requested overlay.
func (Item) GetMountDir ¶
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 ¶
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 ¶
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 ¶
SetAllowDev sets whether to allow devices on the mount for this item.
func (*Item) SetAllowSetuid ¶
SetAllowSetuid sets whether to allow setuid binaries on the mount for this item.
func (*Item) SetParentDir ¶
SetParentDir sets the parent-dir in which to create overlay-specific mount directories.
func (Item) Unmount ¶
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().
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.