mount: mount.PID(), mount.Self(): change signature to return pointers
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
fb464b94d3
commit
43578a9d6e
@ -21,11 +21,3 @@ import "github.com/moby/sys/mountinfo"
|
|||||||
// Info reveals information about a particular mounted filesystem. This
|
// Info reveals information about a particular mounted filesystem. This
|
||||||
// struct is populated from the content in the /proc/<pid>/mountinfo file.
|
// struct is populated from the content in the /proc/<pid>/mountinfo file.
|
||||||
type Info = mountinfo.Info
|
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
|
|
||||||
}
|
|
||||||
|
@ -26,12 +26,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Self retrieves a list of mounts for the current running process.
|
// Self retrieves a list of mounts for the current running process.
|
||||||
func Self() ([]Info, error) {
|
func Self() ([]*Info, error) {
|
||||||
m, err := mountinfo.GetMounts(nil)
|
return mountinfo.GetMounts(nil)
|
||||||
return fromMountinfoSlice(m), err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PID collects the mounts for a specific process ID.
|
// 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)
|
return nil, fmt.Errorf("mountinfo.PID is not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
|
||||||
}
|
}
|
||||||
|
@ -23,15 +23,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Self retrieves a list of mounts for the current running process.
|
// Self retrieves a list of mounts for the current running process.
|
||||||
func Self() ([]Info, error) {
|
func Self() ([]*Info, error) {
|
||||||
m, err := mountinfo.GetMounts(nil)
|
return mountinfo.GetMounts(nil)
|
||||||
return fromMountinfoSlice(m), err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PID collects the mounts for a specific process ID. If the process
|
// PID collects the mounts for a specific process ID. If the process
|
||||||
// ID is unknown, it is better to use `Self` which will inspect
|
// ID is unknown, it is better to use `Self` which will inspect
|
||||||
// "/proc/self/mountinfo" instead.
|
// "/proc/self/mountinfo" instead.
|
||||||
func PID(pid int) ([]Info, error) {
|
func PID(pid int) ([]*Info, error) {
|
||||||
m, err := mountinfo.PidMountInfo(pid)
|
return mountinfo.PidMountInfo(pid)
|
||||||
return fromMountinfoSlice(m), err
|
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Self retrieves a list of mounts for the current running process.
|
// 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)
|
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.
|
// 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)
|
return nil, fmt.Errorf("mountinfo.PID is not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user