From 2f091187472f7b6007af50dbab07596c858db6a6 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Fri, 31 Oct 2014 16:28:20 -0400 Subject: [PATCH] pkg/mount: mountinfo from specified pid Signed-off-by: Vincent Batts --- mount/mountinfo_linux.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mount/mountinfo_linux.go b/mount/mountinfo_linux.go index 84bf551..68f4e9f 100644 --- a/mount/mountinfo_linux.go +++ b/mount/mountinfo_linux.go @@ -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) +}