diff --git a/mount/mountinfo.go b/mount/mountinfo.go index 58d1db897..a42238d86 100644 --- a/mount/mountinfo.go +++ b/mount/mountinfo.go @@ -21,11 +21,3 @@ import "github.com/moby/sys/mountinfo" // Info reveals information about a particular mounted filesystem. This // struct is populated from the content in the /proc//mountinfo file. type Info = mountinfo.Info - -func fromMountinfoSlice(infos []*mountinfo.Info) []Info { - out := make([]Info, len(infos)) - for i, v := range infos { - out[i] = *v - } - return out -} diff --git a/mount/mountinfo_bsd.go b/mount/mountinfo_bsd.go index ad5696ad3..5888d0d84 100644 --- a/mount/mountinfo_bsd.go +++ b/mount/mountinfo_bsd.go @@ -26,12 +26,11 @@ import ( ) // Self retrieves a list of mounts for the current running process. -func Self() ([]Info, error) { - m, err := mountinfo.GetMounts(nil) - return fromMountinfoSlice(m), err +func Self() ([]*Info, error) { + return mountinfo.GetMounts(nil) } // PID collects the mounts for a specific process ID. -func PID(pid int) ([]Info, error) { +func PID(pid int) ([]*Info, error) { return nil, fmt.Errorf("mountinfo.PID is not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) } diff --git a/mount/mountinfo_linux.go b/mount/mountinfo_linux.go index 8457f68d1..4273eadd6 100644 --- a/mount/mountinfo_linux.go +++ b/mount/mountinfo_linux.go @@ -23,15 +23,13 @@ import ( ) // Self retrieves a list of mounts for the current running process. -func Self() ([]Info, error) { - m, err := mountinfo.GetMounts(nil) - return fromMountinfoSlice(m), err +func Self() ([]*Info, error) { + return mountinfo.GetMounts(nil) } // PID collects the mounts for a specific process ID. If the process // ID is unknown, it is better to use `Self` which will inspect // "/proc/self/mountinfo" instead. -func PID(pid int) ([]Info, error) { - m, err := mountinfo.PidMountInfo(pid) - return fromMountinfoSlice(m), err +func PID(pid int) ([]*Info, error) { + return mountinfo.PidMountInfo(pid) } diff --git a/mount/mountinfo_unsupported.go b/mount/mountinfo_unsupported.go index ae998db6b..ee3e08764 100644 --- a/mount/mountinfo_unsupported.go +++ b/mount/mountinfo_unsupported.go @@ -24,11 +24,11 @@ import ( ) // Self retrieves a list of mounts for the current running process. -func Self() ([]Info, error) { +func Self() ([]*Info, error) { return nil, fmt.Errorf("mountinfo.Self is not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) } // PID collects the mounts for a specific process ID. -func PID(pid int) ([]Info, error) { +func PID(pid int) ([]*Info, error) { return nil, fmt.Errorf("mountinfo.PID is not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) }