Skip to content

Commit 43578a9

Browse files
committed
mount: mount.PID(), mount.Self(): change signature to return pointers
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent fb464b9 commit 43578a9

4 files changed

Lines changed: 9 additions & 20 deletions

File tree

mount/mountinfo.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,3 @@ import "github.com/moby/sys/mountinfo"
2121
// Info reveals information about a particular mounted filesystem. This
2222
// struct is populated from the content in the /proc/<pid>/mountinfo file.
2323
type Info = mountinfo.Info
24-
25-
func fromMountinfoSlice(infos []*mountinfo.Info) []Info {
26-
out := make([]Info, len(infos))
27-
for i, v := range infos {
28-
out[i] = *v
29-
}
30-
return out
31-
}

mount/mountinfo_bsd.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ import (
2626
)
2727

2828
// Self retrieves a list of mounts for the current running process.
29-
func Self() ([]Info, error) {
30-
m, err := mountinfo.GetMounts(nil)
31-
return fromMountinfoSlice(m), err
29+
func Self() ([]*Info, error) {
30+
return mountinfo.GetMounts(nil)
3231
}
3332

3433
// PID collects the mounts for a specific process ID.
35-
func PID(pid int) ([]Info, error) {
34+
func PID(pid int) ([]*Info, error) {
3635
return nil, fmt.Errorf("mountinfo.PID is not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
3736
}

mount/mountinfo_linux.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@ import (
2323
)
2424

2525
// Self retrieves a list of mounts for the current running process.
26-
func Self() ([]Info, error) {
27-
m, err := mountinfo.GetMounts(nil)
28-
return fromMountinfoSlice(m), err
26+
func Self() ([]*Info, error) {
27+
return mountinfo.GetMounts(nil)
2928
}
3029

3130
// PID collects the mounts for a specific process ID. If the process
3231
// ID is unknown, it is better to use `Self` which will inspect
3332
// "/proc/self/mountinfo" instead.
34-
func PID(pid int) ([]Info, error) {
35-
m, err := mountinfo.PidMountInfo(pid)
36-
return fromMountinfoSlice(m), err
33+
func PID(pid int) ([]*Info, error) {
34+
return mountinfo.PidMountInfo(pid)
3735
}

mount/mountinfo_unsupported.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ import (
2424
)
2525

2626
// Self retrieves a list of mounts for the current running process.
27-
func Self() ([]Info, error) {
27+
func Self() ([]*Info, error) {
2828
return nil, fmt.Errorf("mountinfo.Self is not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
2929
}
3030

3131
// PID collects the mounts for a specific process ID.
32-
func PID(pid int) ([]Info, error) {
32+
func PID(pid int) ([]*Info, error) {
3333
return nil, fmt.Errorf("mountinfo.PID is not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
3434
}

0 commit comments

Comments
 (0)