mount

package
v1.8.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: MPL-2.0 Imports: 11 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.

Types

type NewPointOption

type NewPointOption func(*Point)

NewPointOption is a mount point option.

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.

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 NewPoint

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

NewPoint creates a new mount point.

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) 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 (Points) Mount

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

Mount all mount points.

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