mount

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFstabFile      = "/etc/fstab"
	DefaultProcMountsFile = "/proc/mounts"
)

Variables

This section is empty.

Functions

func GetMountsUnderPath added in v0.9.0

func GetMountsUnderPath(pathPrefix string) ([]string, error)

GetMountsUnderPath returns all mount points under the given path prefix by reading /proc/mounts. Returns mounts sorted deepest-first (longest paths first), which is the correct order for unmounting nested mounts.

func IsBindMountedWithFstab

func IsBindMountedWithFstab(mount BindMount) (alreadyMounted bool, fstabEntryAlreadyAdded bool, err error)

IsBindMountedWithFstab checks if the bind mount is currently mounted and if the fstab entry exists

func RemoveBindMountsWithFstab

func RemoveBindMountsWithFstab(mount BindMount) error

RemoveBindMountsWithFstab undoes bind mount setup It unmounts the bind mount and removes the entry from /etc/fstab

func SetupBindMountsWithFstab

func SetupBindMountsWithFstab(mount BindMount) error

SetupBindMountsWithFstab sets up a bind mount for the given target It adds an entry to /etc/fstab and performs the mount

func UnmountPath added in v0.9.0

func UnmountPath(target string) error

UnmountPath unmounts the given path using lazy detach flag (MNT_DETACH). This is a lower-level function that does not check if the path is mounted. Use this when you already know the path is mounted (e.g., from reading /proc/mounts).

Note: We use MNT_DETACH (lazy unmount) without MNT_FORCE. MNT_FORCE is primarily useful for NFS mounts that have become unreachable. For local bind mounts (which is the primary use case here - sandbox mounts, overlay storage, namespace mounts), MNT_DETACH alone is sufficient and safer.

Types

type BindMount

type BindMount struct {
	Source string
	Target string
}

Jump to

Keyboard shortcuts

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