Merge pull request #8931 from vbatts/vbatts-mount_pid_mountinfo
pkg/mount: mountinfo from specified pid Upstream-commit: 349f67632f47a399a6a97a4a4c684b64ba8c6940 Component: engine
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
// +build linux
|
||||
|
||||
package mount
|
||||
|
||||
import (
|
||||
@ -72,3 +74,14 @@ func parseInfoFile(r io.Reader) ([]*MountInfo, error) {
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// PidMountInfo collects the mounts for a specific Pid
|
||||
func PidMountInfo(pid int) ([]*MountInfo, error) {
|
||||
f, err := os.Open(fmt.Sprintf("/proc/%d/mountinfo", pid))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
return parseInfoFile(f)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user