mount

package
v1.10.0-alpha.0 Latest Latest
Warning

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

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

Documentation

Overview

Package mount handles filesystem mount operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 added in v1.9.0

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 added in v1.9.0

func WithData(data string) NewPointOption

WithData sets the mount data.

func WithExtraDirs added in v1.9.0

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 added in v1.9.0

func WithSelinuxLabel(label string) NewPointOption

WithSelinuxLabel sets the mount SELinux label.

func WithShared added in v1.9.0

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 added in v1.9.0

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 added in v1.9.0

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

NewReadonlyOverlay creates a new read-only overlay mount point.

func NewSystemOverlay added in v1.9.0

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

NewSystemOverlay creates a new /system overlay mount point.

func NewVarOverlay added in v1.9.0

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

NewVarOverlay creates a new /var overlay mount point.

func Squashfs added in v1.9.0

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 added in v1.9.0

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 added in v1.9.0

func CGroupMountPoints() Points

CGroupMountPoints returns the cgroup mount points.

func OverlayMountPoints added in v1.9.0

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 added in v1.9.0

func Pseudo() Points

Pseudo returns the mountpoints required to boot the system.

func PseudoLate added in v1.9.0

func PseudoLate() Points

PseudoLate returns the mountpoints mounted later in the boot cycle.

func PseudoSubMountPoints added in v1.9.0

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 added in v1.9.0

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