// 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. func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) { … } var haveProcThreadSelf … var haveProcThreadSelfOnce … func parseMountTable(filter FilterFunc) (_ []*Info, err error) { … } // PidMountInfo retrieves the list of mounts from a given process' mount // namespace. Unless there is a need to get mounts from a mount namespace // different from that of a calling process, use GetMounts. // // This function is Linux-specific. // // Deprecated: this will be removed before v1; use GetMountsFromReader with // opened /proc/<pid>/mountinfo as an argument instead. func PidMountInfo(pid int) ([]*Info, error) { … } // A few specific characters in mountinfo path entries (root and mountpoint) // are escaped using a backslash followed by a character's ascii code in octal. // // space -- as \040 // tab (aka \t) -- as \011 // newline (aka \n) -- as \012 // backslash (aka \\) -- as \134 // // This function converts path from mountinfo back, i.e. it unescapes the above sequences. func unescape(path string) (string, error) { … }