mountinfo

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilterFunc

type FilterFunc func(*Info) (skip, stop bool)

func FSTypeFilter

func FSTypeFilter(fstype ...string) FilterFunc

FSTypeFilter returns all entries that match provided fstype(s).

func ParentsFilter

func ParentsFilter(path string) FilterFunc

ParentsFilter returns all entries whose mount points can be parents of a path specified, discarding others.

For example, given /var/lib/docker/something, entries like /var/lib/docker, /var and / are returned.

func PrefixFilter

func PrefixFilter(prefix string) FilterFunc

PrefixFilter discards all entries whose mount points do not start with, or are equal to the path specified in prefix. The prefix path must be absolute, have all symlinks resolved, and cleaned (i.e. no extra slashes or dots).

PrefixFilter treats prefix as a path, not a partial prefix, which means that given "/foo", "/foo/bar" and "/foobar" entries, PrefixFilter("/foo") returns "/foo" and "/foo/bar", and discards "/foobar".

func SingleEntryFilter

func SingleEntryFilter(mp string) FilterFunc

SingleEntryFilter looks for a specific entry.

type Info

type Info struct {
	// ID是挂载的唯一标识符(可以在umount之后重复使用)。
	ID int

	// Parent是父挂载的ID(或者对于此挂载命名空间的挂载树根来说,是其自身的ID)。
	Parent int

	// 在Unix系统中,`unix.Stat_t`结构体通过`unix.*Stat`系列调用返回的文件信息中,
	// Major和Minor是Dev字段的主要和次要组成部分。
	Major, Minor int

	// Root is the pathname of the directory in the filesystem which forms
	// the root of this mount.
	Root string

	// Mountpoint is the pathname of the mount point relative to the
	// process's root directory.
	Mountpoint string

	// Options is a comma-separated list of mount options.
	Options string

	// Optional are zero or more fields of the form "tag[:value]",
	// separated by a space.  Currently, the possible optional fields are
	// "shared", "master", "propagate_from", and "unbindable". For more
	// information, see mount_namespaces(7) Linux man page.
	Optional string

	// FSType is the filesystem type in the form "type[.subtype]".
	FSType string

	// Source is filesystem-specific information, or "none".
	Source string

	// VFSOptions is a comma-separated list of superblock options.
	VFSOptions string
}

信息揭示了关于特定挂载文件系统的详情。该结构体是从/proc/<pid>/mountinfo文件的内容中填充的。

func GetMounts

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

func GetMountsFromReader

func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error)

GetMountsFromReader retrieves a list of mounts from the reader provided, with an optional filter applied (use nil for no filter). This can be useful in tests or benchmarks that provide fake mountinfo data, or when a source other than /proc/thread-self/mountinfo needs to be read from.

This function is Linux-specific.

Jump to

Keyboard shortcuts

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