Documentation ¶
Index ¶
- func DoMakeRShared(path string, mountInfoFilename string) error
- func ExclusiveOpenFailsOnDevice(pathname string) (bool, error)
- func GetModeLinux(pathname string) (os.FileMode, error)
- func GetOwnerLinux(pathname string) (int64, int64, error)
- func GetSELinux(path string, mountInfoFilename string, selinuxEnabled seLinuxEnabledFunc) (bool, error)
- type FakeHostUtil
- func (hu *FakeHostUtil) DeviceOpened(pathname string) (bool, error)
- func (hu *FakeHostUtil) EvalHostSymlinks(pathname string) (string, error)
- func (hu *FakeHostUtil) GetDeviceNameFromMount(mounter mount.Interface, mountPath, pluginMountDir string) (string, error)
- func (hu *FakeHostUtil) GetFileType(pathname string) (FileType, error)
- func (hu *FakeHostUtil) GetMode(pathname string) (os.FileMode, error)
- func (hu *FakeHostUtil) GetOwner(pathname string) (int64, int64, error)
- func (hu *FakeHostUtil) GetSELinuxSupport(pathname string) (bool, error)
- func (hu *FakeHostUtil) MakeRShared(path string) error
- func (hu *FakeHostUtil) PathExists(pathname string) (bool, error)
- func (hu *FakeHostUtil) PathIsDevice(pathname string) (bool, error)
- type FileType
- type HostUtil
- func (hu *HostUtil) DeviceOpened(pathname string) (bool, error)
- func (hu *HostUtil) EvalHostSymlinks(pathname string) (string, error)
- func (hu *HostUtil) FindMountInfo(path string) (mount.MountInfo, error)
- func (hu *HostUtil) GetDeviceNameFromMount(mounter mount.Interface, mountPath, pluginMountDir string) (string, error)
- func (hu *HostUtil) GetFileType(pathname string) (FileType, error)
- func (hu *HostUtil) GetMode(pathname string) (os.FileMode, error)
- func (hu *HostUtil) GetOwner(pathname string) (int64, int64, error)
- func (hu *HostUtil) GetSELinuxSupport(pathname string) (bool, error)
- func (hu *HostUtil) MakeRShared(path string) error
- func (hu *HostUtil) PathExists(pathname string) (bool, error)
- func (hu *HostUtil) PathIsDevice(pathname string) (bool, error)
- type HostUtils
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoMakeRShared ¶
DoMakeRShared is common implementation of MakeRShared on Linux. It checks if path is shared and bind-mounts it as rshared if needed. mountCmd and mountArgs are expected to contain mount-like command, DoMakeRShared will add '--bind <path> <path>' and '--make-rshared <path>' to mountArgs.
func ExclusiveOpenFailsOnDevice ¶
ExclusiveOpenFailsOnDevice is shared with NsEnterMounter
func GetModeLinux ¶
GetModeLinux is shared between Linux and NsEnterMounter
func GetOwnerLinux ¶
GetOwnerLinux is shared between Linux and NsEnterMounter pathname must already be evaluated for symlinks
Types ¶
type FakeHostUtil ¶
type FakeHostUtil struct { MountPoints []mount.MountPoint Filesystem map[string]FileType // contains filtered or unexported fields }
FakeHostUtil is a fake HostUtils implementation for testing
func NewFakeHostUtil ¶
func NewFakeHostUtil(fs map[string]FileType) *FakeHostUtil
NewFakeHostUtil returns a struct that implements the HostUtils interface for testing TODO: no callers were initializing the struct with any MountPoints. Check if those are still being used by any callers and if MountPoints still need to be a part of the struct.
func (*FakeHostUtil) DeviceOpened ¶
func (hu *FakeHostUtil) DeviceOpened(pathname string) (bool, error)
DeviceOpened checks if block device referenced by pathname is in use by checking if is listed as a device in the in-memory mountpoint table.
func (*FakeHostUtil) EvalHostSymlinks ¶
func (hu *FakeHostUtil) EvalHostSymlinks(pathname string) (string, error)
EvalHostSymlinks returns the path name after evaluating symlinks. No-op for testing
func (*FakeHostUtil) GetDeviceNameFromMount ¶
func (hu *FakeHostUtil) GetDeviceNameFromMount(mounter mount.Interface, mountPath, pluginMountDir string) (string, error)
GetDeviceNameFromMount given a mount point, find the volume id
func (*FakeHostUtil) GetFileType ¶
func (hu *FakeHostUtil) GetFileType(pathname string) (FileType, error)
GetFileType checks for file/directory/socket/block/character devices. Defaults to Directory if otherwise unspecified.
func (*FakeHostUtil) GetMode ¶
func (hu *FakeHostUtil) GetMode(pathname string) (os.FileMode, error)
GetMode returns permissions of pathname. Not implemented for testing
func (*FakeHostUtil) GetOwner ¶
func (hu *FakeHostUtil) GetOwner(pathname string) (int64, int64, error)
GetOwner returns the integer ID for the user and group of the given path Not implemented for testing
func (*FakeHostUtil) GetSELinuxSupport ¶
func (hu *FakeHostUtil) GetSELinuxSupport(pathname string) (bool, error)
GetSELinuxSupport tests if pathname is on a mount that supports SELinux. Not implemented for testing
func (*FakeHostUtil) MakeRShared ¶
func (hu *FakeHostUtil) MakeRShared(path string) error
MakeRShared checks if path is shared and bind-mounts it as rshared if needed. No-op for testing
func (*FakeHostUtil) PathExists ¶
func (hu *FakeHostUtil) PathExists(pathname string) (bool, error)
PathExists checks if pathname exists.
func (*FakeHostUtil) PathIsDevice ¶
func (hu *FakeHostUtil) PathIsDevice(pathname string) (bool, error)
PathIsDevice always returns true
type FileType ¶
type FileType string
FileType enumerates the known set of possible file types.
const ( // FileTypeBlockDev defines a constant for the block device FileType. FileTypeBlockDev FileType = "BlockDevice" // FileTypeCharDev defines a constant for the character device FileType. FileTypeCharDev FileType = "CharDevice" // FileTypeDirectory defines a constant for the directory FileType. FileTypeDirectory FileType = "Directory" // FileTypeFile defines a constant for the file FileType. FileTypeFile FileType = "File" // FileTypeSocket defines a constant for the socket FileType. FileTypeSocket FileType = "Socket" // FileTypeUnknown defines a constant for an unknown FileType. FileTypeUnknown FileType = "" )
type HostUtil ¶
type HostUtil struct { }
HostUtil implements HostUtils for Linux platforms.
func NewHostUtil ¶
func NewHostUtil() *HostUtil
NewHostUtil returns a struct that implements the HostUtils interface on linux platforms
func (*HostUtil) DeviceOpened ¶
DeviceOpened checks if block device in use by calling Open with O_EXCL flag. If pathname is not a device, log and return false with nil error. If open returns errno EBUSY, return true with nil error. If open returns nil, return false with nil error. Otherwise, return false with error
func (*HostUtil) EvalHostSymlinks ¶
EvalHostSymlinks returns the path name after evaluating symlinks. TODO once the nsenter implementation is removed, this method can be removed from the interface and filepath.EvalSymlinks used directly
func (*HostUtil) FindMountInfo ¶ added in v1.19.0
FindMountInfo returns the mount info on the given path.
func (*HostUtil) GetDeviceNameFromMount ¶
func (hu *HostUtil) GetDeviceNameFromMount(mounter mount.Interface, mountPath, pluginMountDir string) (string, error)
GetDeviceNameFromMount given a mount point, find the device name from its global mount point
func (*HostUtil) GetFileType ¶
GetFileType checks for file/directory/socket/block/character devices.
func (*HostUtil) GetOwner ¶
GetOwner returns the integer ID for the user and group of the given path
func (*HostUtil) GetSELinuxSupport ¶
GetSELinuxSupport returns true if given path is on a mount that supports SELinux.
func (*HostUtil) MakeRShared ¶
MakeRShared checks that given path is on a mount with 'rshared' mount propagation. If not, it bind-mounts the path as rshared.
func (*HostUtil) PathExists ¶
PathExists tests if the given path already exists Error is returned on any other error than "file not found".
type HostUtils ¶
type HostUtils interface { // DeviceOpened determines if the device (e.g. /dev/sdc) is in use elsewhere // on the system, i.e. still mounted. DeviceOpened(pathname string) (bool, error) // PathIsDevice determines if a path is a device. PathIsDevice(pathname string) (bool, error) // GetDeviceNameFromMount finds the device name by checking the mount path // to get the global mount path within its plugin directory. GetDeviceNameFromMount(mounter mount.Interface, mountPath, pluginMountDir string) (string, error) // propagation. If not, it bind-mounts the path as rshared. MakeRShared(path string) error // GetFileType checks for file/directory/socket/block/character devices. GetFileType(pathname string) (FileType, error) // PathExists tests if the given path already exists // Error is returned on any other error than "file not found". PathExists(pathname string) (bool, error) // EvalHostSymlinks returns the path name after evaluating symlinks. EvalHostSymlinks(pathname string) (string, error) // GetOwner returns the integer ID for the user and group of the given path GetOwner(pathname string) (int64, int64, error) // GetSELinuxSupport returns true if given path is on a mount that supports // SELinux. GetSELinuxSupport(pathname string) (bool, error) // GetMode returns permissions of the path. GetMode(pathname string) (os.FileMode, error) }
HostUtils defines the set of methods for interacting with paths on a host.