Documentation
¶
Overview ¶
Package mount handles filesystem mount operations.
Index ¶
- func BindReadonly(src, dst string) error
- func BindReadonlyFd(dfd int, dst string) error
- func SafeUnmount(ctx context.Context, printer func(string, ...any), target string) error
- func UnmountAll() error
- type Manager
- func NewCgroup2() *Manager
- func NewManager(opts ...ManagerOption) *Manager
- func NewOverlayWithBasePath(sources []string, target, basePath string, printer func(string, ...any), ...) *Manager
- func NewReadOnlyOverlay(sources []string, target string, printer func(string, ...any), ...) *Manager
- func NewSystemOverlay(sources []string, target string, printer func(string, ...any), ...) *Manager
- func NewVarOverlay(sources []string, target string, printer func(string, ...any), ...) *Manager
- func Squashfs(target, squashfsFile string, printer func(string, ...any)) (*Manager, error)
- type ManagerOption
- func WithDetached() ManagerOption
- func WithExtraDirs(dirs ...string) ManagerOption
- func WithExtraUnmountCallbacks(callbacks ...func(m *Manager)) ManagerOption
- func WithFsopen(fstype string, opts ...fsopen.Option) ManagerOption
- func WithKeepOpenAfterMount() ManagerOption
- func WithMountAttributes(flags int) ManagerOption
- func WithOpentreeFromPath(path string) ManagerOption
- func WithPrinter(printer func(string, ...any)) ManagerOption
- func WithReadOnly() ManagerOption
- func WithSelinuxLabel(label string) ManagerOption
- func WithShared() ManagerOption
- func WithSkipIfMounted() ManagerOption
- func WithTarget(target string) ManagerOption
- type Managers
- type Options
- type Point
- func (p *Point) FSType() string
- func (p *Point) IsMounted() (bool, error)
- func (p *Point) Mount(opts Options) error
- func (p *Point) Move(newTarget string) error
- func (p *Point) Release(force bool) error
- func (p *Point) RemountReadOnly() error
- func (p *Point) RemountReadWrite() error
- func (p *Point) Root() xfs.Root
- func (p *Point) Share() error
- func (p *Point) Source() string
- func (p *Point) Target() string
- func (p *Point) Unmount(opts UnmountOptions) error
- type UnmountOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindReadonly ¶
BindReadonly creates a common way to create a readonly bind mounted destination.
func BindReadonlyFd ¶
BindReadonlyFd creates a common way to create a readonly bind mounted destination.
func SafeUnmount ¶
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 Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the filesystem manager for mounting and unmounting filesystems.
func NewManager ¶
func NewManager(opts ...ManagerOption) *Manager
NewManager creates a new Manager with the given options.
func NewOverlayWithBasePath ¶
func NewOverlayWithBasePath(sources []string, target, basePath string, printer func(string, ...any), options ...ManagerOption) *Manager
NewOverlayWithBasePath creates a new overlay filesystem with a base path.
func NewReadOnlyOverlay ¶
func NewReadOnlyOverlay(sources []string, target string, printer func(string, ...any), options ...ManagerOption) *Manager
NewReadOnlyOverlay creates a new read-only overlay filesystem.
func NewSystemOverlay ¶
func NewSystemOverlay(sources []string, target string, printer func(string, ...any), options ...ManagerOption) *Manager
NewSystemOverlay creates a new /system overlay filesystem.
func NewVarOverlay ¶
func NewVarOverlay(sources []string, target string, printer func(string, ...any), options ...ManagerOption) *Manager
NewVarOverlay creates a new /var overlay filesystem.
func Squashfs ¶
Squashfs binds the squashfs to the loop device and returns the mountpoint for it to the specified target.
type ManagerOption ¶
type ManagerOption struct {
// contains filtered or unexported fields
}
ManagerOption is an option for configuring the Manager.
func WithExtraDirs ¶
func WithExtraDirs(dirs ...string) ManagerOption
WithExtraDirs adds extra dirs to the manager that should be created prior to mounting the filesystem.
func WithExtraUnmountCallbacks ¶
func WithExtraUnmountCallbacks(callbacks ...func(m *Manager)) ManagerOption
WithExtraUnmountCallbacks adds extra callbacks to the unmount operation. Those need to handle errors by themselves.
func WithFsopen ¶
func WithFsopen(fstype string, opts ...fsopen.Option) ManagerOption
WithFsopen sets the filesystem opener with the given type and options.
func WithKeepOpenAfterMount ¶
func WithKeepOpenAfterMount() ManagerOption
WithKeepOpenAfterMount assesses if the mountpoint fd should be kept open after the Mount.
func WithMountAttributes ¶
func WithMountAttributes(flags int) ManagerOption
WithMountAttributes sets the mount attributes.
func WithOpentreeFromPath ¶
func WithOpentreeFromPath(path string) ManagerOption
WithOpentreeFromPath sets the opentree opener with the path.
func WithPrinter ¶
func WithPrinter(printer func(string, ...any)) ManagerOption
WithPrinter sets the printer function for logging.
func WithSelinuxLabel ¶
func WithSelinuxLabel(label string) ManagerOption
WithSelinuxLabel sets the mount SELinux label.
func WithSkipIfMounted ¶
func WithSkipIfMounted() ManagerOption
WithSkipIfMounted sets the option to skip mounting if already mounted.
func WithTarget ¶
func WithTarget(target string) ManagerOption
WithTarget sets the target mount point.
type Managers ¶
type Managers []*Manager
Managers is a list of mount managers.
func PseudoLate ¶
PseudoLate creates late pseudo filesystem mountpoint managers.
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point represents a mount point in the filesystem.
func (*Point) IsMounted ¶
IsMounted checks if the mount point is mounted by checking the mount on the target.
func (*Point) RemountReadOnly ¶
RemountReadOnly remounts the mount point as read-only.
func (*Point) RemountReadWrite ¶
RemountReadWrite remounts the mount point as read-write.
func (*Point) Unmount ¶
func (p *Point) Unmount(opts UnmountOptions) error
Unmount unmounts the mount point, retrying on certain errors.
type UnmountOptions ¶
UnmountOptions represents options for unmounting a mount point.