Skip to content

Commit

Permalink
pkg/mount: mountinfo from specified pid
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Batts <vbatts@redhat.com>
  • Loading branch information
vbatts committed Nov 7, 2014
1 parent 0f9f5f3 commit 64e7a17
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/mount/mountinfo_linux.go
@@ -1,3 +1,5 @@
// +build linux

package mount

import (
Expand Down Expand Up @@ -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)
}

0 comments on commit 64e7a17

Please sign in to comment.