mount

package
v6.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package mount implements mounting, moving, and unmounting file systems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mount

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

Mount attaches the fsType file system at path.

dev is the device to mount (this is often the path of a block device, name of a file, or a dummy string). data usually contains arguments for the specific file system.

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 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(newRootDir string, init string) error

SwitchRoot makes newRootDir the new root directory of the system.

To be exact, it makes newRootDir the new root directory of the calling process's mount namespace.

It 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

Unmount detaches any file system mounted at path.

force forces an unmount regardless of currently open or otherwise used files within the file system to be unmounted.

lazy disallows future uses of any files below path -- i.e. it hides the file system mounted at path, but the file system itself is still active and any currently open files can continue to be used. When all references to files from this file system are gone, the file system will actually be unmounted.

Types

type Mounter

type Mounter interface {
	// Mount mounts the file system at path.
	Mount(path string, flags uintptr) error

	// Unmount unmounts a file system that was previously mounted.
	//
	// Mount must have been previously called on this same object.
	Unmount(flags int) error
}

Mounter is an object that can be mounted.

Jump to

Keyboard shortcuts

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