mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
vendor: github.com/moby/sys/mountinfo v0.6.2
full diff: https://github.com/moby/sys/compare/mountinfo/v0.6.0...mountinfo/v0.6.2 - update golang.org/x/sys v0.0.0-20220412211240-33da011f77ad - mountinfo: BSDs no longer need cgo nor reflect - mountinfo: update doc to use fs.ErrNotExist - Bump x/sys/unix Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
53aefba7f3
commit
4178caade6
10 changed files with 52 additions and 43 deletions
|
@ -54,7 +54,7 @@ require (
|
|||
github.com/moby/locker v1.0.1
|
||||
github.com/moby/swarmkit/v2 v2.0.0-20220420172245-6068d1894d46
|
||||
github.com/moby/sys/mount v0.3.1
|
||||
github.com/moby/sys/mountinfo v0.6.0
|
||||
github.com/moby/sys/mountinfo v0.6.2
|
||||
github.com/moby/sys/signal v0.7.0
|
||||
github.com/moby/sys/symlink v0.2.0
|
||||
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
|
||||
|
|
|
@ -741,8 +741,9 @@ github.com/moby/sys/mount v0.3.1/go.mod h1:6IZknFQiqjLpwuYJD5Zk0qYEuJiws36M88MIX
|
|||
github.com/moby/sys/mountinfo v0.4.0/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A=
|
||||
github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A=
|
||||
github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU=
|
||||
github.com/moby/sys/mountinfo v0.6.0 h1:gUDhXQx58YNrpHlK4nSL+7y2pxFZkUcXqzFDKWdC0Oo=
|
||||
github.com/moby/sys/mountinfo v0.6.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU=
|
||||
github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78=
|
||||
github.com/moby/sys/mountinfo v0.6.2/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI=
|
||||
github.com/moby/sys/signal v0.6.0/go.mod h1:GQ6ObYZfqacOwTtlXvcmh9A26dVRul/hbOZn88Kg8Tg=
|
||||
github.com/moby/sys/signal v0.7.0 h1:25RW3d5TnQEoKvRbEKUGay6DCQ46IxAVTT9CUMgmsSI=
|
||||
github.com/moby/sys/signal v0.7.0/go.mod h1:GQ6ObYZfqacOwTtlXvcmh9A26dVRul/hbOZn88Kg8Tg=
|
||||
|
|
2
vendor/github.com/moby/sys/mountinfo/mounted_linux.go
generated
vendored
2
vendor/github.com/moby/sys/mountinfo/mounted_linux.go
generated
vendored
|
@ -15,7 +15,7 @@ import (
|
|||
//
|
||||
// If a non-existent path is specified, an appropriate error is returned.
|
||||
// In case the caller is not interested in this particular error, it should
|
||||
// be handled separately using e.g. errors.Is(err, os.ErrNotExist).
|
||||
// be handled separately using e.g. errors.Is(err, fs.ErrNotExist).
|
||||
//
|
||||
// This function is only available on Linux. When available (since kernel
|
||||
// v5.6), openat2(2) syscall is used to reliably detect all mounts. Otherwise,
|
||||
|
|
11
vendor/github.com/moby/sys/mountinfo/mounted_unix.go
generated
vendored
11
vendor/github.com/moby/sys/mountinfo/mounted_unix.go
generated
vendored
|
@ -1,10 +1,9 @@
|
|||
//go:build linux || (freebsd && cgo) || (openbsd && cgo) || (darwin && cgo)
|
||||
// +build linux freebsd,cgo openbsd,cgo darwin,cgo
|
||||
//go:build linux || freebsd || openbsd || darwin
|
||||
// +build linux freebsd openbsd darwin
|
||||
|
||||
package mountinfo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
|
@ -33,13 +32,13 @@ func mountedByStat(path string) (bool, error) {
|
|||
|
||||
func normalizePath(path string) (realPath string, err error) {
|
||||
if realPath, err = filepath.Abs(path); err != nil {
|
||||
return "", fmt.Errorf("unable to get absolute path for %q: %w", path, err)
|
||||
return "", err
|
||||
}
|
||||
if realPath, err = filepath.EvalSymlinks(realPath); err != nil {
|
||||
return "", fmt.Errorf("failed to canonicalise path for %q: %w", path, err)
|
||||
return "", err
|
||||
}
|
||||
if _, err := os.Stat(realPath); err != nil {
|
||||
return "", fmt.Errorf("failed to stat target of %q: %w", path, err)
|
||||
return "", err
|
||||
}
|
||||
return realPath, nil
|
||||
}
|
||||
|
|
2
vendor/github.com/moby/sys/mountinfo/mountinfo.go
generated
vendored
2
vendor/github.com/moby/sys/mountinfo/mountinfo.go
generated
vendored
|
@ -15,7 +15,7 @@ func GetMounts(f FilterFunc) ([]*Info, error) {
|
|||
//
|
||||
// If a non-existent path is specified, an appropriate error is returned.
|
||||
// In case the caller is not interested in this particular error, it should
|
||||
// be handled separately using e.g. errors.Is(err, os.ErrNotExist).
|
||||
// be handled separately using e.g. errors.Is(err, fs.ErrNotExist).
|
||||
func Mounted(path string) (bool, error) {
|
||||
// root is always mounted
|
||||
if path == string(os.PathSeparator) {
|
||||
|
|
44
vendor/github.com/moby/sys/mountinfo/mountinfo_bsd.go
generated
vendored
44
vendor/github.com/moby/sys/mountinfo/mountinfo_bsd.go
generated
vendored
|
@ -1,53 +1,37 @@
|
|||
//go:build (freebsd && cgo) || (openbsd && cgo) || (darwin && cgo)
|
||||
// +build freebsd,cgo openbsd,cgo darwin,cgo
|
||||
//go:build freebsd || openbsd || darwin
|
||||
// +build freebsd openbsd darwin
|
||||
|
||||
package mountinfo
|
||||
|
||||
/*
|
||||
#include <sys/param.h>
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/mount.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
// parseMountTable returns information about mounted filesystems
|
||||
func parseMountTable(filter FilterFunc) ([]*Info, error) {
|
||||
var rawEntries *C.struct_statfs
|
||||
|
||||
count := int(C.getmntinfo(&rawEntries, C.MNT_WAIT))
|
||||
if count == 0 {
|
||||
return nil, fmt.Errorf("failed to call getmntinfo")
|
||||
count, err := unix.Getfsstat(nil, unix.MNT_WAIT)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var entries []C.struct_statfs
|
||||
header := (*reflect.SliceHeader)(unsafe.Pointer(&entries))
|
||||
header.Cap = count
|
||||
header.Len = count
|
||||
header.Data = uintptr(unsafe.Pointer(rawEntries))
|
||||
entries := make([]unix.Statfs_t, count)
|
||||
_, err = unix.Getfsstat(entries, unix.MNT_WAIT)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var out []*Info
|
||||
for _, entry := range entries {
|
||||
var mountinfo Info
|
||||
var skip, stop bool
|
||||
mountinfo.Mountpoint = C.GoString(&entry.f_mntonname[0])
|
||||
mountinfo.FSType = C.GoString(&entry.f_fstypename[0])
|
||||
mountinfo.Source = C.GoString(&entry.f_mntfromname[0])
|
||||
mountinfo := getMountinfo(&entry)
|
||||
|
||||
if filter != nil {
|
||||
// filter out entries we're not interested in
|
||||
skip, stop = filter(&mountinfo)
|
||||
skip, stop = filter(mountinfo)
|
||||
if skip {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
out = append(out, &mountinfo)
|
||||
out = append(out, mountinfo)
|
||||
if stop {
|
||||
break
|
||||
}
|
||||
|
|
14
vendor/github.com/moby/sys/mountinfo/mountinfo_freebsdlike.go
generated
vendored
Normal file
14
vendor/github.com/moby/sys/mountinfo/mountinfo_freebsdlike.go
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
//go:build freebsd || darwin
|
||||
// +build freebsd darwin
|
||||
|
||||
package mountinfo
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
func getMountinfo(entry *unix.Statfs_t) *Info {
|
||||
return &Info{
|
||||
Mountpoint: unix.ByteSliceToString(entry.Mntonname[:]),
|
||||
FSType: unix.ByteSliceToString(entry.Fstypename[:]),
|
||||
Source: unix.ByteSliceToString(entry.Mntfromname[:]),
|
||||
}
|
||||
}
|
11
vendor/github.com/moby/sys/mountinfo/mountinfo_openbsd.go
generated
vendored
Normal file
11
vendor/github.com/moby/sys/mountinfo/mountinfo_openbsd.go
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
package mountinfo
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
func getMountinfo(entry *unix.Statfs_t) *Info {
|
||||
return &Info{
|
||||
Mountpoint: unix.ByteSliceToString(entry.F_mntonname[:]),
|
||||
FSType: unix.ByteSliceToString(entry.F_fstypename[:]),
|
||||
Source: unix.ByteSliceToString(entry.F_mntfromname[:]),
|
||||
}
|
||||
}
|
4
vendor/github.com/moby/sys/mountinfo/mountinfo_unsupported.go
generated
vendored
4
vendor/github.com/moby/sys/mountinfo/mountinfo_unsupported.go
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
//go:build (!windows && !linux && !freebsd && !openbsd && !darwin) || (freebsd && !cgo) || (openbsd && !cgo) || (darwin && !cgo)
|
||||
// +build !windows,!linux,!freebsd,!openbsd,!darwin freebsd,!cgo openbsd,!cgo darwin,!cgo
|
||||
//go:build !windows && !linux && !freebsd && !openbsd && !darwin
|
||||
// +build !windows,!linux,!freebsd,!openbsd,!darwin
|
||||
|
||||
package mountinfo
|
||||
|
||||
|
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -658,7 +658,7 @@ github.com/moby/swarmkit/v2/xnet
|
|||
# github.com/moby/sys/mount v0.3.1
|
||||
## explicit; go 1.16
|
||||
github.com/moby/sys/mount
|
||||
# github.com/moby/sys/mountinfo v0.6.0
|
||||
# github.com/moby/sys/mountinfo v0.6.2
|
||||
## explicit; go 1.16
|
||||
github.com/moby/sys/mountinfo
|
||||
# github.com/moby/sys/signal v0.7.0
|
||||
|
|
Loading…
Add table
Reference in a new issue