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 SafeMakeDir(subdir string, base string, perm os.FileMode) 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) 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 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 ¶
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) 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) // 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.