mount

package
v1.9.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package mount handles filesystem mount operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForceCGroupsV1

func ForceCGroupsV1() bool

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

func SafeUnmount

func SafeUnmount(ctx context.Context, printer func(string, ...any), 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 UnmountAll

func UnmountAll() error

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

Types

type NewPointOption

type NewPointOption func(*Point)

NewPointOption is a mount point option.

func WithData

func WithData(data string) NewPointOption

WithData sets the mount data.

func WithExtraDirs

func WithExtraDirs(dirs ...string) NewPointOption

WithExtraDirs sets the extra directories to be created on mount.

func WithFlags

func WithFlags(flags uintptr) NewPointOption

WithFlags sets the mount flags.

func WithProjectQuota

func WithProjectQuota(enabled bool) NewPointOption

WithProjectQuota sets the project quota flag.

func WithReadonly

func WithReadonly() NewPointOption

WithReadonly sets the read-only flag.

func WithSelinuxLabel

func WithSelinuxLabel(label string) NewPointOption

WithSelinuxLabel sets the mount SELinux label.

func WithShared

func WithShared() NewPointOption

WithShared sets the shared flag.

type OperationOption

type OperationOption func(*OperationOptions)

OperationOption is a mount option.

func WithMountPrinter

func WithMountPrinter(printer func(string, ...any)) OperationOption

WithMountPrinter sets the printer.

func WithSkipIfMounted

func WithSkipIfMounted() OperationOption

WithSkipIfMounted sets the skip if mounted flag.

type OperationOptions

type OperationOptions struct {
	PrinterOptions

	SkipIfMounted bool

	TargetMode os.FileMode
}

OperationOptions are mount options.

type Point

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

Point represents a mount point.

func NewOverlayWithBasePath

func NewOverlayWithBasePath(sources []string, target, basePath string, opts ...NewPointOption) *Point

NewOverlayWithBasePath creates a new overlay mount point with a base path.

func NewPoint

func NewPoint(source, target, fstype string, opts ...NewPointOption) *Point

NewPoint creates a new mount point.

func NewReadonlyOverlay

func NewReadonlyOverlay(sources []string, target string, opts ...NewPointOption) *Point

NewReadonlyOverlay creates a new read-only overlay mount point.

func NewSystemOverlay

func NewSystemOverlay(sources []string, target string, opts ...NewPointOption) *Point

NewSystemOverlay creates a new /system overlay mount point.

func NewVarOverlay

func NewVarOverlay(sources []string, target string, opts ...NewPointOption) *Point

NewVarOverlay creates a new /var overlay mount point.

func Squashfs

func Squashfs(target, squashfsFile string) (*Point, error)

Squashfs binds the squashfs to the loop device and returns the mountpoint for it to the specified target.

func (*Point) IsMounted

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

IsMounted checks if the mount point is mounted by checking the mount on the target.

func (*Point) Mount

func (p *Point) Mount(opts ...OperationOption) (unmounter func() error, err error)

Mount the mount point.

Mount returns an unmounter function to unmount the mount point.

func (*Point) Move

func (p *Point) Move(newTarget string) error

Move the mount point to a new target.

func (*Point) Unmount

func (p *Point) Unmount(opts ...UnmountOption) error

Unmount the mount point.

type Points

type Points []*Point

Points is a list of mount points.

func CGroupMountPoints

func CGroupMountPoints() Points

CGroupMountPoints returns the cgroup mount points.

func OverlayMountPoints

func OverlayMountPoints() Points

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

func Pseudo

func Pseudo() Points

Pseudo returns the mountpoints required to boot the system.

func PseudoLate

func PseudoLate() Points

PseudoLate returns the mountpoints mounted later in the boot cycle.

func PseudoSubMountPoints

func PseudoSubMountPoints() Points

PseudoSubMountPoints returns the sub-mountpoints under Pseudo().

func (Points) Mount

func (points Points) Mount(opts ...OperationOption) (unmounter func() error, err error)

Mount all mount points.

func (Points) Move

func (points Points) Move(prefix string) error

Move all mount points to a new prefix.

func (Points) Unmount

func (points Points) Unmount() error

Unmount all mount points.

type PrinterOptions

type PrinterOptions struct {
	Printer func(string, ...any)
}

PrinterOptions are printer options.

func (PrinterOptions) Printf

func (o PrinterOptions) Printf(format string, args ...any)

Printf prints a formatted string (or skips if printer is nil).

type UnmountOption

type UnmountOption func(*UnmountOptions)

UnmountOption is an unmount option.

func WithUnmountPrinter

func WithUnmountPrinter(printer func(string, ...any)) UnmountOption

WithUnmountPrinter sets the printer.

type UnmountOptions

type UnmountOptions struct {
	PrinterOptions
}

UnmountOptions is unmount options.

Jump to

Keyboard shortcuts

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