Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mountinfo: docs nits #52

Merged
merged 2 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions mountinfo/mountinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,38 @@ type Info struct {
// ID is a unique identifier of the mount (may be reused after umount).
ID int

// Parent indicates the ID of the mount parent (or of self for the top of the
// mount tree).
// Parent is the ID of the parent mount (or of self for the root
// of this mount namespace's mount tree).
Parent int

// Major indicates one half of the device ID which identifies the device class.
Major int
// Major and Minor are the major and the minor components of the Dev
// field of unix.Stat_t structure returned by unix.*Stat calls for
// files on this filesystem.
Major, Minor int
Comment on lines +36 to +39
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious; how does the documentation show these combined comments? Does it repeat the same doc for each of them, or does it also should them grouped?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. go doc shows it as is:
	// Major and Minor are the major and the minor components of the Dev
	// field of unix.Stat_t structure returned by unix.*Stat calls for
	// files on this filesystem.
	Major, Minor int
  1. go doc (a webserver) does exactly the same since it's a struct members:
type Info
Info reveals information about a particular mounted filesystem. This struct is populated from the content in the /proc/<pid>/mountinfo file.

type Info struct {
    // ID is a unique identifier of the mount (may be reused after umount).
    ID int

    // Parent is the ID of the parent mount (or of self for the root
    // of this mount namespace's mount tree).
    Parent int

    // Major and Minor are the major and the minor components of the Dev
    // field of unix.Stat_t structure returned by unix.*Stat calls for
    // files on this filesystem.
    Major, Minor int
...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, had wires crossed and thought we were in a var() block 🤦

makes sense


// Minor indicates one half of the device ID which identifies a specific
// instance of device.
Minor int

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

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

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

// Optional represents optional fields.
// 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 indicates the type of filesystem, such as EXT3.
// FSType is the filesystem type in the form "type[.subtype]".
FSType string

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

// VFSOptions represents per super block options.
// VFSOptions is a comma-separated list of superblock options.
VFSOptions string
}
5 changes: 2 additions & 3 deletions mountinfo/mountinfo_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (
// 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 a fake mountinfo data.
// that provide fake mountinfo data, or when a source other
// than /proc/self/mountinfo needs to be read from.
//
// This function is Linux-specific.
func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
Expand Down Expand Up @@ -133,8 +134,6 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
return out, nil
}

// Parse /proc/self/mountinfo because comparing Dev and ino does not work from
// bind mounts
func parseMountTable(filter FilterFunc) ([]*Info, error) {
f, err := os.Open("/proc/self/mountinfo")
if err != nil {
Expand Down