kubernetes: k8s.io/kubernetes/pkg/volume/util/hostutil Index | Files

package hostutil

import "k8s.io/kubernetes/pkg/volume/util/hostutil"

Index

Package Files

fake_hostutil.go hostutil.go hostutil_linux.go

func DoMakeRShared Uses

func DoMakeRShared(path string, mountInfoFilename string) error

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 Uses

func ExclusiveOpenFailsOnDevice(pathname string) (bool, error)

ExclusiveOpenFailsOnDevice is shared with NsEnterMounter

func GetModeLinux Uses

func GetModeLinux(pathname string) (os.FileMode, error)

GetModeLinux is shared between Linux and NsEnterMounter

func GetOwnerLinux Uses

func GetOwnerLinux(pathname string) (int64, int64, error)

GetOwnerLinux is shared between Linux and NsEnterMounter pathname must already be evaluated for symlinks

func GetSELinux Uses

func GetSELinux(path string, mountInfoFilename string) (bool, error)

GetSELinux is common implementation of GetSELinuxSupport on Linux.

type FakeHostUtil Uses

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 Uses

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 Uses

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 (hu *FakeHostUtil) EvalHostSymlinks(pathname string) (string, error)

EvalHostSymlinks returns the path name after evaluating symlinks. No-op for testing

func (*FakeHostUtil) GetDeviceNameFromMount Uses

func (hu *FakeHostUtil) GetDeviceNameFromMount(mounter mount.Interface, mountPath, pluginMountDir string) (string, error)

GetDeviceNameFromMount given a mount point, find the volume id

func (*FakeHostUtil) GetFileType Uses

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 Uses

func (hu *FakeHostUtil) GetMode(pathname string) (os.FileMode, error)

GetMode returns permissions of pathname. Not implemented for testing

func (*FakeHostUtil) GetOwner Uses

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 Uses

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 Uses

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 Uses

func (hu *FakeHostUtil) PathExists(pathname string) (bool, error)

PathExists checks if pathname exists.

func (*FakeHostUtil) PathIsDevice Uses

func (hu *FakeHostUtil) PathIsDevice(pathname string) (bool, error)

PathIsDevice always returns true

type FileType Uses

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 Uses

type HostUtil struct {
}

HostUtil implements HostUtils for Linux platforms.

func NewHostUtil Uses

func NewHostUtil() *HostUtil

NewHostUtil returns a struct that implements the HostUtils interface on linux platforms

func (*HostUtil) DeviceOpened Uses

func (hu *HostUtil) DeviceOpened(pathname string) (bool, error)

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 (hu *HostUtil) EvalHostSymlinks(pathname string) (string, error)

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) GetDeviceNameFromMount Uses

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 Uses

func (hu *HostUtil) GetFileType(pathname string) (FileType, error)

GetFileType checks for file/directory/socket/block/character devices.

func (*HostUtil) GetMode Uses

func (hu *HostUtil) GetMode(pathname string) (os.FileMode, error)

GetMode returns permissions of the path.

func (*HostUtil) GetOwner Uses

func (hu *HostUtil) GetOwner(pathname string) (int64, int64, error)

GetOwner returns the integer ID for the user and group of the given path

func (*HostUtil) GetSELinuxSupport Uses

func (hu *HostUtil) GetSELinuxSupport(pathname string) (bool, error)

GetSELinuxSupport returns true if given path is on a mount that supports SELinux.

func (*HostUtil) MakeRShared Uses

func (hu *HostUtil) MakeRShared(path string) error

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 Uses

func (hu *HostUtil) PathExists(pathname string) (bool, error)

PathExists tests if the given path already exists Error is returned on any other error than "file not found".

func (*HostUtil) PathIsDevice Uses

func (hu *HostUtil) PathIsDevice(pathname string) (bool, error)

PathIsDevice uses FileInfo returned from os.Stat to check if path refers to a device.

type HostUtils Uses

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)
    // MakeRShared checks that given path is on a mount with 'rshared' mount
    // 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.

Package hostutil imports 12 packages (graph) and is imported by 47 packages. Updated 2019-11-12. Refresh now. Tools for package owners.