mount

package
v5.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2019 License: BSD-3-Clause Imports: 6 Imported by: 342

Documentation

Overview

The mount package implements functions for mounting and unmounting file systems and defines the mount interface.

The mount package implements functions for mounting and unmounting file systems and defines the mount interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSpecialMounts added in v0.5.0

func AddSpecialMounts(newRoot string) error

AddSpecialMounts moves the 'special' mounts to the given target path

'special' in this context refers to the following non-blockdevice backed mounts that are almost always used: /dev, /proc, /sys, and /run. This function will create the target directories, if necessary. If the target directories already exist, they must be empty. This function skips missing mounts.

func DirIsEmpty added in v0.5.0

func DirIsEmpty(name string) (bool, error)

DirIsEmpty returns true if the directory with the given path is empty.

func ExecInit added in v0.5.0

func ExecInit(init string) error

Function ExecInit is generally only useful as part of SwitchRoot or similar. It exec's the given binary in place of the current binary, necessary so that the new binary can be pid 1.

func Mount

func Mount(dev, path, fsType, data string, flags uintptr) error

func MoveMount

func MoveMount(oldPath string, newPath string) error

MoveMount moves a mount from oldPath to newPath.

This function is just a wrapper around the MOUNT syscall with the MOVE flag supplied.

func NewRoot added in v0.5.0

func NewRoot(newRoot string) error

NewRoot is the "first half" of SwitchRoot - that is, it creates special mounts in newRoot, chroot's there, and RECURSIVELY DELETES everything in the old root.

func RecursiveDelete added in v0.5.0

func RecursiveDelete(fd int) error

RecursiveDelete deletes a directory identified by `fd` and everything in it.

This function allows deleting directories no longer referenceable by any file name. This function does not descend into mounts.

func SameFilesystem

func SameFilesystem(path1, path2 string) (bool, error)

SameFilesystem returns true if both paths reside in the same filesystem. This is achieved by comparing Stat_t.Dev, which contains the fs device's major/minor numbers.

func SwitchRoot

func SwitchRoot(newRoot string, init string) error

SwitchRoot moves special mounts (dev, proc, sys, run) to the new directory, then does a chroot, moves the root mount to the new directory and finally DELETES EVERYTHING in the old root and execs the given init.

func Unmount

func Unmount(path string, force, lazy bool) error

Types

type Mounter

type Mounter interface {
	Mount() error
	Unmount(flags int) error
}

Jump to

Keyboard shortcuts

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