nfs

package
v1.1.3-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHostUtil

func NewHostUtil(ne *NsEnter) hostutil.HostUtils

NewHostUtil returns a new mount.HostUtils implementation that works for kubelet running in a container

Types

type Mounter

type Mounter struct {
	// contains filtered or unexported fields
}

Mounter implements mount.Interface Currently, all docker containers receive their own mount namespaces. Mounter works by executing nsenter to run commands in the host's mount namespace.

func NewMounter

func NewMounter(ne *NsEnter) *Mounter

NewMounter creates a new nsenter mounter that operates in the host namespace

func (*Mounter) GetMountRefs

func (n *Mounter) GetMountRefs(pathname string) ([]string, error)

GetMountRefs finds all mount references to the path, returns a list of paths. Path could be a mountpoint path, device or a normal directory (for bind mount).

func (*Mounter) IsLikelyNotMountPoint

func (n *Mounter) IsLikelyNotMountPoint(file string) (bool, error)

IsLikelyNotMountPoint determines whether a path is a mountpoint by calling findmnt in the host's root mount namespace.

func (*Mounter) IsMountPointMatch

func (*Mounter) IsMountPointMatch(mp mount.MountPoint, dir string) bool

IsMountPointMatch tests if dir and mp are the same path

func (*Mounter) List

func (*Mounter) List() ([]mount.MountPoint, error)

List returns a list of all mounted filesystems in the host's mount namespace.

func (*Mounter) Mount

func (n *Mounter) Mount(source string, target string, fstype string, options []string) error

Mount runs mount(8) in the host's root mount namespace. Aside from this aspect, Mount has the same semantics as the mounter returned by mount.New()

func (*Mounter) Unmount

func (n *Mounter) Unmount(target string) error

Unmount runs umount(8) in the host's mount namespace.

type NsEnter

type NsEnter struct {
	// contains filtered or unexported fields
}

func NewNsEnter

func NewNsEnter() (*NsEnter, error)

func (*NsEnter) AbsHostPath

func (ne *NsEnter) AbsHostPath(command string) string

AbsHostPath returns the absolute runnable path for a specified command

func (*NsEnter) Command

func (ne *NsEnter) Command(cmd string, args ...string) exec.Cmd

Command returns a command wrapped with nsenter

func (*NsEnter) CommandContext

func (ne *NsEnter) CommandContext(ctx context.Context, cmd string, args ...string) exec.Cmd

CommandContext returns a CommandContext wrapped with nsenter

func (*NsEnter) ContainerPath

func (ne *NsEnter) ContainerPath(pathname string) string

ContainerPath TODO: remove this once the direct syscalls of stat are replaced with invocations of the namespaced stat command

func (ne *NsEnter) EvalSymlinks(pathname string, mustExist bool) (string, error)

EvalSymlinks returns the path name on the host after evaluating symlinks on the host. mustExist makes EvalSymlinks to return error when the path does not exist. When it's false, it evaluates symlinks of the existing part and blindly adds the non-existing part: pathname: /mnt/volume/non/existing/directory

/mnt/volume exists
           non/existing/directory does not exist

-> It resolves symlinks in /mnt/volume to say /mnt/foo and returns

/mnt/foo/non/existing/directory.

BEWARE! EvalSymlinks is not able to detect symlink looks with mustExist=false! If /tmp/link is symlink to /tmp/link, EvalSymlinks(/tmp/link/foo) returns /tmp/link/foo.

func (*NsEnter) Exec

func (ne *NsEnter) Exec(cmd string, args []string) exec.Cmd

Exec executes nsenter commands in host mount namespace

func (*NsEnter) LookPath

func (ne *NsEnter) LookPath(file string) (string, error)

LookPath returns a LookPath wrapped with nsenter

func (*NsEnter) SupportsSystemd

func (ne *NsEnter) SupportsSystemd() (string, bool)

SupportsSystemd checks whether command systemd-run exists

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL