mount

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImplemented = errors.New("not implemented")

ErrNotImplemented is returned when a platform does not implement the contextual function.

Functions

func BindMount

func BindMount(source, target string, options ...string) error

BindMount behaves like Mount was called with a "bind" flag set in the options list.

func EvalSymlinks(symPath *string) error

EvalSymlinks evaluates the provided path and updates it to remove any symlinks in its structure, replacing them with the actual path components.

func FormatAndMount

func FormatAndMount(source, target, fsType string, options ...string) error

FormatAndMount uses unix utils to format and mount the given disk.

func GetDiskFormat

func GetDiskFormat(disk string) (string, error)

GetDiskFormat uses 'lsblk' to see if the given disk is unformatted.

func Mount

func Mount(source, target, fsType string, options ...string) error

Mount mounts source to target as fstype with given options.

The parameters 'source' and 'fstype' must be empty strings in case they are not required, e.g. for remount, or for an auto filesystem type where the kernel handles fstype automatically.

The 'options' parameter is a list of options. Please see mount(8) for more information. If no options are required then please invoke Mount with an empty or nil argument.

func Unmount

func Unmount(target string) error

Unmount unmounts the target.

Types

type Info

type Info struct {
	// Device is the device on which the filesystem is mounted.
	Device string

	// Path is the filesystem path to which the device is mounted.
	Path string

	// Source may be set to one of two values:
	//
	//   1. If this is a bind mount created with "bindfs" then Source
	//      is set to the filesystem path bind mounted to Path.
	//
	//   2. If this is any other type of mount then Source is set to
	//      a concatenation of the mount source and the root of
	//      the mount within the file system (fields 10 & 4 from
	//      the section on /proc/<pid>/mountinfo at
	//      https://www.kernel.org/doc/Documentation/filesystems/proc.txt).
	//
	// It is not possible to diffentiate a native bind mount from a
	// non-bind mount after the native bind mount has been created.
	// Therefore, while the Source field will be set to the filesystem
	// path bind mounted to Path for native bind mounts, the value of
	// the Source field can in no way be used to determine *if* a mount
	// is a bind mount.
	Source string

	// Type is the filesystem type.
	Type string

	// Opts are the mount options used to create this mount point.
	Opts []string
}

Info is information about a single mount point.

func GetDevMounts

func GetDevMounts(dev string) ([]*Info, error)

GetDevMounts returns a slice of all mounts for dev

func GetMounts

func GetMounts() ([]*Info, error)

GetMounts returns a slice of all the mounted filesystems.

* Linux hosts use mount_namespaces to obtain mount information.

Support for mount_namespaces was introduced to the Linux kernel
in 2.2.26 (http://man7.org/linux/man-pages/man5/proc.5.html) on
2004/02/04.

The kernel documents the contents of "/proc/<pid>/mountinfo" at
https://www.kernel.org/doc/Documentation/filesystems/proc.txt.
  • Darwin hosts parse the output of the "mount" command to obtain mount information.

Jump to

Keyboard shortcuts

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