Documentation ¶
Overview ¶
Package mount implements mounting, moving, and unmounting file systems.
Index ¶
- Constants
- func FindFileSystem(fstype string) error
- func GetBlockFilesystems() (fstypes []string, err error)
- func MoveMount(oldPath string, newPath string) error
- func SameFilesystem(path1, path2 string) (bool, error)
- func SwitchRoot(newRootDir string, init string) error
- func Unmount(path string, force, lazy bool) error
- type MountPoint
- type Mounter
Constants ¶
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.
const ( MNT_FORCE = unix.MNT_FORCE MNT_DETACH = unix.MNT_DETACH )
Unmount flags.
Variables ¶
This section is empty.
Functions ¶
func FindFileSystem ¶
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 ¶
GetBlockFilesystems returns the supported file systems for block devices.
func MoveMount ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) Unmount ¶
func (mp *MountPoint) Unmount(flags uintptr) error
Unmount unmounts a file system that was previously mounted.
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. |