Documentation
¶
Overview ¶
Package mount handles filesystem mount operations.
Index ¶
- func BindReadonly(src, dst string) error
- func BindReadonlyFd(dfd int, dst string) error
- func FilterSelinuxLabelErrors(target, fstype string, err error) 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 WithDisableAccessTime() 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 WithRecursiveUnmount() ManagerOption
- func WithSecure() 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) SetDisableAccessTime(disable bool) error
- func (p *Point) SetSecure(secure bool) error
- 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 FilterSelinuxLabelErrors ¶ added in v1.13.0
FilterSelinuxLabelErrors filters out certain errors when setting the SELinux label on the mount point.
- ENOTSUP is ignored for all filesystems, as it indicates that the filesystem does not support extended attributes.
- EROFS is ignored for virtiofs, as it indicates that the underlying filesystem is read-only and does not support setting labels.
- EPERM is ignored for virtiofs, as setting security.selinux xattrs may be blocked by the host or virtiofsd even though the mount is otherwise functional.
func SafeUnmount ¶
func SafeUnmount(ctx context.Context, printer func(string, ...any), target string, recursive bool) 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. If recursive is true, it will first unmount all child mounts under target.
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 WithDisableAccessTime ¶ added in v1.13.0
func WithDisableAccessTime() ManagerOption
WithDisableAccessTime sets MOUNT_ATTR_NOATIME.
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 WithRecursiveUnmount ¶ added in v1.13.0
func WithRecursiveUnmount() ManagerOption
WithRecursiveUnmount enables recursive unmounting of all child mounts before unmounting the target.
func WithSecure ¶ added in v1.13.0
func WithSecure() ManagerOption
WithSecure sets MOUNT_ATTR_NOSUID and MOUNT_ATTR_NODEV.
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) SetDisableAccessTime ¶ added in v1.13.0
SetDisableAccessTime sets or clears the noatime mount attribute.
func (*Point) SetSecure ¶ added in v1.13.0
SetSecure sets or clears the nosuid and nodev mount attributes.
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.