Browse Source

Merge pull request #8931 from vbatts/vbatts-mount_pid_mountinfo

pkg/mount: mountinfo from specified pid
Alexandr Morozov 10 years ago
parent
commit
349f67632f
1 changed files with 13 additions and 0 deletions
  1. 13 0
      pkg/mount/mountinfo_linux.go

+ 13 - 0
pkg/mount/mountinfo_linux.go

@@ -1,3 +1,5 @@
+// +build linux
+
 package mount
 package mount
 
 
 import (
 import (
@@ -72,3 +74,14 @@ func parseInfoFile(r io.Reader) ([]*MountInfo, error) {
 	}
 	}
 	return out, nil
 	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)
+}