Documentation
¶
Overview ¶
Package mount defines an interface to mounting filesystems.
Index ¶
- Constants
- func AddSystemdScope(systemdRunPath, mountName, command string, args []string) (string, []string)
- func CleanupMountPoint(mountPath string, mounter Interface, extensiveMountPointCheck bool) error
- func GetDeviceNameFromMount(mounter Interface, mountPath string) (string, int, error)
- func IsCorruptedMnt(err error) bool
- func IsNotMountPoint(mounter Interface, file string) (bool, error)
- func MakeBindOpts(options []string) (bool, []string, []string)
- func MakeMountArgs(source, target, fstype string, options []string) []string
- func PathExists(path string) (bool, error)
- func PathWithinBase(fullPath, basePath string) bool
- func SearchMountPoints(hostSource, mountInfoPath string) ([]string, error)
- func StartsWithBackstep(rel string) bool
- type FakeAction
- type FakeMounter
- func (f *FakeMounter) GetLog() []FakeAction
- func (f *FakeMounter) GetMountRefs(pathname string) ([]string, error)
- func (f *FakeMounter) IsLikelyNotMountPoint(file string) (bool, error)
- func (f *FakeMounter) List() ([]MountPoint, error)
- func (f *FakeMounter) Mount(source string, target string, fstype string, options []string) error
- func (f *FakeMounter) ResetLog()
- func (f *FakeMounter) Unmount(target string) error
- type Interface
- type MountInfo
- type MountPoint
- type Mounter
- func (mounter *Mounter) GetMountRefs(pathname string) ([]string, error)
- func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error)
- func (*Mounter) List() ([]MountPoint, error)
- func (mounter *Mounter) Mount(source string, target string, fstype string, options []string) error
- func (mounter *Mounter) Unmount(target string) error
- type SafeFormatAndMount
- type UnmountFunc
Constants ¶
const ( // FakeActionMount is the string for specifying mount as FakeAction.Action FakeActionMount = "mount" // FakeActionUnmount is the string for specifying unmount as FakeAction.Action FakeActionUnmount = "unmount" )
Variables ¶
This section is empty.
Functions ¶
func AddSystemdScope ¶
AddSystemdScope adds "system-run --scope" to given command line implementation is shared with NsEnterMounter
func CleanupMountPoint ¶
CleanupMountPoint unmounts the given path and deletes the remaining directory if successful. If extensiveMountPointCheck is true IsNotMountPoint will be called instead of IsLikelyNotMountPoint. IsNotMountPoint is more expensive but properly handles bind mounts within the same fs.
func GetDeviceNameFromMount ¶
GetDeviceNameFromMount given a mnt point, find the device from /proc/mounts returns the device name, reference count, and error code.
func IsCorruptedMnt ¶
IsCorruptedMnt return true if err is about corrupted mount point
func IsNotMountPoint ¶
IsNotMountPoint determines if a directory is a mountpoint. It should return ErrNotExist when the directory does not exist. IsNotMountPoint is more expensive than IsLikelyNotMountPoint. IsNotMountPoint detects bind mounts in linux. IsNotMountPoint enumerates all the mountpoints using List() and the list of mountpoints may be large, then it uses isMountPointMatch to evaluate whether the directory is a mountpoint.
func MakeBindOpts ¶
MakeBindOpts detects whether a bind mount is being requested and makes the remount options to use in case of bind mount, due to the fact that bind mount doesn't respect mount options. The list equals:
options - 'bind' + 'remount' (no duplicate)
func MakeMountArgs ¶
MakeMountArgs makes the arguments to the mount(8) command. Implementation is shared with NsEnterMounter
func PathExists ¶
PathExists returns true if the specified path exists. TODO: clean this up to use pkg/util/file/FileExists
func PathWithinBase ¶
PathWithinBase checks if give path is within given base directory.
func SearchMountPoints ¶
SearchMountPoints finds all mount references to the source, returns a list of mountpoints. The source can be a mount point or a normal directory (bind mount). We didn't support device because there is no use case by now. Some filesystems may share a source name, e.g. tmpfs. And for bind mounting, it's possible to mount a non-root path of a filesystem, so we need to use root path and major:minor to represent mount source uniquely. This implementation is shared between Linux and NsEnterMounter
Types ¶
type FakeAction ¶
type FakeAction struct {
Action string // "mount" or "unmount"
Target string // applies to both mount and unmount actions
Source string // applies only to "mount" actions
FSType string // applies only to "mount" actions
}
FakeAction objects are logged every time a fake mount or unmount is called.