mount

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MPL-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForceGGroupsV1

func ForceGGroupsV1() bool

ForceGGroupsV1 returns the cgroup version to be used (only for !container mode).

func Mount

func Mount(mountpoints *Points) (err error)

Mount mounts the device(s).

func Move

func Move(mountpoints *Points, prefix string) (err error)

Move moves the device(s). TODO(andrewrynhard): We need to skip calling the move method on mountpoints that are a child of another mountpoint. The kernel will handle moving the child mountpoints for us.

func PrefixMountTargets

func PrefixMountTargets(mountpoints *Points, targetPrefix string) error

PrefixMountTargets prefixes all mountpoints targets with fixed path.

func SafeUnmount added in v1.4.2

func SafeUnmount(ctx context.Context, logger *log.Logger, target string) error

SafeUnmount unmounts the target path, first without force, then with force if the first attempt fails.

It makes sure that unmounting has a finite operation timeout.

func SystemPartitionMount

func SystemPartitionMount(ctx context.Context, r runtime.Runtime, logger *log.Logger, label string, opts ...mountv2.NewPointOption) (err error)

SystemPartitionMount mounts a system partition by the label.

func SystemPartitionUnmount

func SystemPartitionUnmount(r runtime.Runtime, logger *log.Logger, label string) (err error)

SystemPartitionUnmount unmounts a system partition by the label.

func Unmount

func Unmount(mountpoints *Points) (err error)

Unmount unmounts the device(s).

func UnmountAll

func UnmountAll() error

UnmountAll attempts to unmount all the mounted filesystems via "self" mountinfo.

Types

type Flags

type Flags uint

Flags is the mount flags.

const (
	// ReadOnly is a flag for setting the mount point as readonly.
	ReadOnly Flags = 1 << iota
	// Shared is a flag for setting the mount point as shared.
	Shared
	// Resize indicates that a the partition for a given mount point should be
	// resized to the maximum allowed.
	Resize
	// Overlay indicates that a the partition for a given mount point should be
	// mounted using overlayfs.
	Overlay
	// SystemOverlay indicates that overlay directory should be created under tmpfs.
	//
	// SystemOverlay should be combined with Overlay option.
	SystemOverlay
	// ReadonlyOverlay indicates that a the partition for a given mount point should be
	// mounted using multi-layer readonly overlay from multiple partitions given as sources.
	ReadonlyOverlay
	// SkipIfMounted is a flag for skipping mount if the mountpoint is already mounted.
	SkipIfMounted
	// SkipIfNoFilesystem is a flag for skipping formatting and mounting if the mountpoint has not filesystem.
	SkipIfNoFilesystem
	// SkipIfNoDevice is a flag for skipping errors when the device is not found.
	SkipIfNoDevice
)

func (Flags) Check

func (f Flags) Check(flags Flags) bool

Check checks if all provided flags are set.

func (Flags) Intersects

func (f Flags) Intersects(flags Flags) bool

Intersects checks if at least one flag is set.

type Hook

type Hook func(p *Point) error

Hook represents pre/post mount hook.

type Option

type Option func(*Options)

Option is the functional option func.

func WithEncryptionConfig

func WithEncryptionConfig(cfg config.Encryption) Option

WithEncryptionConfig partition encryption configuration.

func WithFlags

func WithFlags(flags Flags) Option

WithFlags is a functional option to set up mount flags.

func WithLogger

func WithLogger(logger *log.Logger) Option

WithLogger sets the logger.

func WithPostUnmountHooks

func WithPostUnmountHooks(hooks ...Hook) Option

WithPostUnmountHooks adds functions to be called after unmounting the partition.

func WithPreMountHooks

func WithPreMountHooks(hooks ...Hook) Option

WithPreMountHooks adds functions to be called before mounting the partition.

func WithPrefix

func WithPrefix(o string) Option

WithPrefix is a functional option for setting the mount point prefix.

func WithProjectQuota added in v1.5.0

func WithProjectQuota(enable bool) Option

WithProjectQuota enables project quota mount option.

func WithSystemInformationGetter added in v1.5.0

func WithSystemInformationGetter(getter helpers.SystemInformationGetter) Option

WithSystemInformationGetter the function to get system information on the node.

type Options

type Options struct {
	Loopback                string
	Prefix                  string
	MountFlags              Flags
	PreMountHooks           []Hook
	PostUnmountHooks        []Hook
	Encryption              config.Encryption
	SystemInformationGetter helpers.SystemInformationGetter
	Logger                  *log.Logger
	ProjectQuota            bool
}

Options is the functional options struct.

func NewDefaultOptions

func NewDefaultOptions(setters ...Option) *Options

NewDefaultOptions initializes a Options struct with default values.

type Point

type Point struct {
	*Options
	// contains filtered or unexported fields
}

Point represents a Linux mount point.

func NewMountPoint

func NewMountPoint(source, target, fstype string, flags uintptr, data string, setters ...Option) *Point

NewMountPoint initializes and returns a Point struct.

func (*Point) Data

func (p *Point) Data() string

Data returns the mount points data field.

func (*Point) Flags

func (p *Point) Flags() uintptr

Flags returns the mount points flags field.

func (*Point) Fstype

func (p *Point) Fstype() string

Fstype returns the mount points fstype field.

func (*Point) GrowFilesystem

func (p *Point) GrowFilesystem() (err error)

GrowFilesystem grows a partition's filesystem to the maximum size allowed. NB: An XFS partition MUST be mounted, or this will fail.

func (*Point) IsMounted

func (p *Point) IsMounted() (bool, error)

IsMounted checks whether mount point is active under /proc/mounts.

func (*Point) Mount

func (p *Point) Mount() (err error)

Mount attempts to retry a mount on EBUSY. It will attempt a retry every 100 milliseconds over the course of 5 seconds.

func (*Point) Move

func (p *Point) Move(prefix string) (err error)

Move moves a mountpoint to a new location with a prefix.

func (*Point) Repair

func (p *Point) Repair() error

Repair repairs a partition's filesystem.

func (*Point) ResizePartition

func (p *Point) ResizePartition() (resized bool, err error)

ResizePartition resizes a partition to the maximum size allowed.

func (*Point) Source

func (p *Point) Source() string

Source returns the mount points source field.

func (*Point) Target

func (p *Point) Target() string

Target returns the mount points target field.

func (*Point) Unmount

func (p *Point) Unmount() (err error)

Unmount attempts to retry an unmount on EBUSY. It will attempt a retry every 100 milliseconds over the course of 5 seconds.

type PointMap

type PointMap = map[string]*Point

PointMap represents a unique set of mount points.

type Points

type Points struct {
	// contains filtered or unexported fields
}

Points represents an ordered set of mount points.

func BPFMountPoints

func BPFMountPoints() (mountpoints *Points, err error)

BPFMountPoints returns the bpf mount points.

func CGroupMountPoints

func CGroupMountPoints() (mountpoints *Points, err error)

CGroupMountPoints returns the cgroup mount points.

func NewMountPoints

func NewMountPoints() *Points

NewMountPoints initializes and returns a Points struct.

func OverlayMountPoints

func OverlayMountPoints() (mountpoints *Points, err error)

OverlayMountPoints returns the mountpoints required to boot the system. These mountpoints are used as overlays on top of the read only rootfs.

func PseudoMountPoints

func PseudoMountPoints() (mountpoints *Points, err error)

PseudoMountPoints returns the mountpoints required to boot the system.

func PseudoSubMountPoints

func PseudoSubMountPoints() (mountpoints *Points, err error)

PseudoSubMountPoints returns the mountpoints required to boot the system.

func SquashfsMountPoints

func SquashfsMountPoints(prefix string) (mountpoints *Points, err error)

SquashfsMountPoints returns the mountpoints required to boot the system.

func (*Points) Get

func (p *Points) Get(key string) (value *Point, ok bool)

Get gets an ordered value.

func (*Points) Iter

func (p *Points) Iter() *PointsIterator

Iter initializes and returns a mount point iterator.

func (*Points) IterRev

func (p *Points) IterRev() *PointsIterator

IterRev initializes and returns a mount point iterator that advances in reverse.

func (*Points) Len

func (p *Points) Len() int

Len returns number of mount points.

func (*Points) Set

func (p *Points) Set(key string, value *Point)

Set sets an ordered value.

type PointsIterator

type PointsIterator struct {
	// contains filtered or unexported fields
}

PointsIterator represents an iteratable group of mount points.

func (*PointsIterator) Err

func (i *PointsIterator) Err() error

Err returns an error.

func (*PointsIterator) Key

func (i *PointsIterator) Key() string

Key returns the current key.

func (*PointsIterator) Next

func (i *PointsIterator) Next() bool

Next advances the iterator to the next value.

func (*PointsIterator) Value

func (i *PointsIterator) Value() *Point

Value returns current mount point.

type RetryFunc

type RetryFunc func(*Point) error

RetryFunc defines the requirements for retrying a mount point operation.

Directories

Path Synopsis
Package mount handles filesystem mount operations.
Package mount handles filesystem mount operations.

Jump to

Keyboard shortcuts

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