Documentation ¶
Index ¶
- func GetMountOptions(volumes *csi.VolumeCapability_MountVolume) []string
- func IsCorruptedMount(err error) bool
- func IsMountPathAllowed(whitelist []string, path string) bool
- func ListProcMounts(mountFilePath string) ([]mount.MountPoint, error)
- func MakeDir(path string) error
- func MakeMountArgsSensitive(source, sourceMasked, target, fstype string, options []string, ...) (mountArgs []string, mountArgsLogStr string)
- func MountBind(mounter Mounter, sourcePath string, mntOptions []string, targetPath string) error
- func PathExists(path string) (bool, error)
- func SearchMountPoints(hostSource, mountInfoPath string) ([]string, error)
- type MountInfo
- type Mounter
- type NodeMounter
- func (mounter *NodeMounter) FuseUnmount(target string, lazy bool) error
- func (mounter *NodeMounter) GetDeviceName(mountPath string) (string, int, error)
- func (mounter *NodeMounter) GetMountRefs(pathname string) ([]string, error)
- func (mounter *NodeMounter) IsLikelyNotMountPoint(file string) (bool, error)
- func (mounter *NodeMounter) List() ([]mount.MountPoint, error)
- func (mounter *NodeMounter) Mount(source string, target string, fstype string, options []string) error
- func (mounter *NodeMounter) MountSensitive(source string, target string, fstype string, options []string, ...) error
- func (mounter *NodeMounter) MountSensitive2(source string, sourceMasked string, target string, fstype string, ...) error
- func (mounter *NodeMounter) UnmountLazy(target string, lazy bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMountOptions ¶
func GetMountOptions(volumes *csi.VolumeCapability_MountVolume) []string
GetMountOptions returns mount options from VolumeCapability_MountVolume
func IsCorruptedMount ¶
IsCorruptedMount return true if err is about corrupted mount point
func IsMountPathAllowed ¶
IsMountPathAllowed checks if given path is allowed to mount
func ListProcMounts ¶
func ListProcMounts(mountFilePath string) ([]mount.MountPoint, error)
ListProcMounts is shared with NsEnterMounter
func MakeMountArgsSensitive ¶
func MakeMountArgsSensitive(source, sourceMasked, target, fstype string, options []string, sensitiveOptions []string) (mountArgs []string, mountArgsLogStr string)
MakeMountArgsSensitive makes the arguments to the mount(8) command. sensitiveOptions is an extension of options except they will not be logged (because they may contain sensitive material)
func PathExists ¶
PathExists returns true if the specified path exists.
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 MountInfo ¶
type MountInfo struct { // Unique ID for the mount (maybe reused after umount). ID int // The ID of the parent mount (or of self for the root of this mount namespace's mount tree). ParentID int // Major indicates one half of the device ID which identifies the device class // (parsed from `st_dev` for files on this filesystem). Major int // Minor indicates one half of the device ID which identifies a specific // instance of device (parsed from `st_dev` for files on this filesystem). Minor int // The pathname of the directory in the filesystem which forms the root of this mount. Root string // Mount source, filesystem-specific information. e.g. device, tmpfs name. Source string // Mount point, the pathname of the mount point. MountPoint string // Optional fieds, zero or more fields of the form "tag[:value]". OptionalFields []string // The filesystem type in the form "type[.subtype]". FsType string // Per-mount options. MountOptions []string // Per-superblock options. SuperOptions []string }
MountInfo represents a single line in /proc/<pid>/mountinfo.
func ParseMountInfo ¶
ParseMountInfo parses /proc/xxx/mountinfo.
type Mounter ¶
type Mounter interface { mount.Interface GetDeviceName(mountPath string) (string, int, error) MountSensitive2(source string, sourceMasked string, target string, fstype string, options []string, sensitiveOptions []string, stdinValues []string) error UnmountLazy(target string, lazy bool) error FuseUnmount(target string, lazy bool) error }
func NewNodeMounter ¶
func NewNodeMounter() Mounter
type NodeMounter ¶
func (*NodeMounter) FuseUnmount ¶ added in v0.9.4
func (mounter *NodeMounter) FuseUnmount(target string, lazy bool) error
FuseUnmount unmounts the fuse target.
func (*NodeMounter) GetDeviceName ¶
func (mounter *NodeMounter) GetDeviceName(mountPath string) (string, int, error)
func (*NodeMounter) GetMountRefs ¶
func (mounter *NodeMounter) GetMountRefs(pathname string) ([]string, error)
GetMountRefs finds all mount references to pathname, returns a list of paths. Path could be a mountpoint or a normal directory (for bind mount).
func (*NodeMounter) IsLikelyNotMountPoint ¶
func (mounter *NodeMounter) IsLikelyNotMountPoint(file string) (bool, error)
IsLikelyNotMountPoint determines if a directory is not a mountpoint. It is fast but not necessarily ALWAYS correct. If the path is in fact a bind mount from one part of a mount to another it will not be detected. It also can not distinguish between mountpoints and symbolic links. mkdir /tmp/a /tmp/b; mount --bind /tmp/a /tmp/b; IsLikelyNotMountPoint("/tmp/b") will return true. When in fact /tmp/b is a mount point. If this situation is of interest to you, don't use this function...
func (*NodeMounter) List ¶
func (mounter *NodeMounter) List() ([]mount.MountPoint, error)
List returns a list of all mounted filesystems.
func (*NodeMounter) Mount ¶
func (mounter *NodeMounter) Mount(source string, target string, fstype string, options []string) error
Mount mounts source to target as fstype with given options. 'source' and 'fstype' must be an empty string in case it's not required, e.g. for remount, or for auto filesystem type, where kernel handles fstype for you. The mount 'options' is a list of options, currently come from mount(8), e.g. "ro", "remount", "bind", etc. If no more option is required, call Mount with an empty string list or nil.
func (*NodeMounter) MountSensitive ¶
func (mounter *NodeMounter) MountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string) error
MountSensitive is the same as Mount() but this method allows sensitiveOptions to be passed in a separate parameter from the normal mount options and ensures the sensitiveOptions are never logged. This method should be used by callers that pass sensitive material (like passwords) as mount options.
func (*NodeMounter) MountSensitive2 ¶
func (*NodeMounter) UnmountLazy ¶ added in v0.10.1
func (mounter *NodeMounter) UnmountLazy(target string, lazy bool) error
UnmountLazy unmounts the target.