mount

package
v7.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: BSD-3-Clause Imports: 8 Imported by: 328

Documentation

Overview

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

Index

Constants

View Source
const (
	MS_RDONLY   = unix.MS_RDONLY
	MS_BIND     = unix.MS_BIND
	MS_LAZYTIME = unix.MS_LAZYTIME
	MS_NOEXEC   = unix.MS_NOEXEC
	MS_NOSUID   = unix.MS_NOSUID
	MS_NOUSER   = unix.MS_NOUSER
	MS_RELATIME = unix.MS_RELATIME
	MS_SYNC     = unix.MS_SYNC
	MS_NOATIME  = unix.MS_NOATIME

	ReadOnly = unix.MS_RDONLY | unix.MS_NOATIME
)

Most commonly used mount flags.

View Source
const (
	MNT_FORCE  = unix.MNT_FORCE
	MNT_DETACH = unix.MNT_DETACH
)

Unmount flags.

Variables

This section is empty.

Functions

func FindFileSystem

func FindFileSystem(fstype string) error

FindFileSystem returns nil if a file system is available for use.

It rereads /proc/filesystems each time as the supported file systems can change as modules are added and removed.

func GetBlockFilesystems

func GetBlockFilesystems() (fstypes []string, err error)

GetBlockFilesystems returns the supported file systems for block devices.

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 MountPoint

type MountPoint struct {
	Path   string
	Device string
	FSType string
	Flags  uintptr
	Data   string
}

MountPoint represents a mounted file system.

func Mount

func Mount(dev, path, fsType, data string, flags uintptr) (*MountPoint, 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 placeholder string). data usually contains arguments for the specific file system.

func TryMount

func TryMount(device, path, data string, flags uintptr) (*MountPoint, error)

TryMount tries to mount a device on the given mountpoint, trying in order the supported block device file systems on the system.

func (*MountPoint) String

func (mp *MountPoint) String() string

String implements fmt.Stringer.

func (*MountPoint) Unmount

func (mp *MountPoint) Unmount(flags uintptr) error

Unmount unmounts a file system that was previously mounted.

type Mounter

type Mounter interface {
	// Mount attaches the device at path.
	Mount(path string, flags uintptr) (*MountPoint, error)
}

Mounter is a device that can be attached at a file system path.

Directories

Path Synopsis
Package block finds, mounts, and modifies block devices on Linux systems.
Package block finds, mounts, and modifies block devices on Linux systems.
Package gpt implements reading and writing of GUID Partition tables.
Package gpt implements reading and writing of GUID Partition tables.
Package loop provides an interface to interacting with Linux loop devices.
Package loop provides an interface to interacting with Linux loop devices.
Chips are made by vendors, and an individual vendor is defined by a 1 to 8 byte vendor id stored in the chip.
Chips are made by vendors, and an individual vendor is defined by a 1 to 8 byte vendor id stored in the chip.
Package scuzz supports direct access to SCSI or SATA devices.
Package scuzz supports direct access to SCSI or SATA devices.

Jump to

Keyboard shortcuts

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