go.mod: github.com/moby/sys/mountinfo v0.5.0
full diff: https://github.com/moby/sys/compare/95edfa939201...mountinfo/v0.5.0 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
		
							
								
								
									
										4
									
								
								vendor/github.com/moby/sys/mountinfo/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/moby/sys/mountinfo/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
module github.com/moby/sys/mountinfo
 | 
			
		||||
 | 
			
		||||
go 1.14
 | 
			
		||||
go 1.16
 | 
			
		||||
 | 
			
		||||
require golang.org/x/sys v0.0.0-20200909081042-eff7692f9009
 | 
			
		||||
require golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								vendor/github.com/moby/sys/mountinfo/go.sum
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/moby/sys/mountinfo/go.sum
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,2 +1,2 @@
 | 
			
		||||
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 h1:W0lCpv29Hv0UaM1LXb9QlBHLNP8UFfcKjblhVCWftOM=
 | 
			
		||||
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
			
		||||
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 h1:2B5p2L5IfGiD7+b9BOoRMC6DgObAVZV+Fsp050NqXik=
 | 
			
		||||
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								vendor/github.com/moby/sys/mountinfo/mounted_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								vendor/github.com/moby/sys/mountinfo/mounted_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -16,9 +16,6 @@ func mountedByOpenat2(path string) (bool, error) {
 | 
			
		||||
		Flags: unix.O_PATH | unix.O_CLOEXEC,
 | 
			
		||||
	})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if err == unix.ENOENT { // not a mount
 | 
			
		||||
			return false, nil
 | 
			
		||||
		}
 | 
			
		||||
		return false, &os.PathError{Op: "openat2", Path: dir, Err: err}
 | 
			
		||||
	}
 | 
			
		||||
	fd, err := unix.Openat2(dirfd, last, &unix.OpenHow{
 | 
			
		||||
@@ -26,20 +23,22 @@ func mountedByOpenat2(path string) (bool, error) {
 | 
			
		||||
		Resolve: unix.RESOLVE_NO_XDEV,
 | 
			
		||||
	})
 | 
			
		||||
	_ = unix.Close(dirfd)
 | 
			
		||||
	switch err {
 | 
			
		||||
	switch err { //nolint:errorlint // unix errors are bare
 | 
			
		||||
	case nil: // definitely not a mount
 | 
			
		||||
		_ = unix.Close(fd)
 | 
			
		||||
		return false, nil
 | 
			
		||||
	case unix.EXDEV: // definitely a mount
 | 
			
		||||
		return true, nil
 | 
			
		||||
	case unix.ENOENT: // not a mount
 | 
			
		||||
		return false, nil
 | 
			
		||||
	}
 | 
			
		||||
	// not sure
 | 
			
		||||
	return false, &os.PathError{Op: "openat2", Path: path, Err: err}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func mounted(path string) (bool, error) {
 | 
			
		||||
	path, err := normalizePath(path)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false, err
 | 
			
		||||
	}
 | 
			
		||||
	// Try a fast path, using openat2() with RESOLVE_NO_XDEV.
 | 
			
		||||
	mounted, err := mountedByOpenat2(path)
 | 
			
		||||
	if err == nil {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								vendor/github.com/moby/sys/mountinfo/mounted_unix.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								vendor/github.com/moby/sys/mountinfo/mounted_unix.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,9 +1,9 @@
 | 
			
		||||
//go:build linux || (freebsd && cgo) || (openbsd && cgo) || (darwin && cgo)
 | 
			
		||||
// +build linux freebsd,cgo openbsd,cgo darwin,cgo
 | 
			
		||||
 | 
			
		||||
package mountinfo
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
@@ -15,10 +15,6 @@ func mountedByStat(path string) (bool, error) {
 | 
			
		||||
	var st unix.Stat_t
 | 
			
		||||
 | 
			
		||||
	if err := unix.Lstat(path, &st); err != nil {
 | 
			
		||||
		if err == unix.ENOENT {
 | 
			
		||||
			// Treat ENOENT as "not mounted".
 | 
			
		||||
			return false, nil
 | 
			
		||||
		}
 | 
			
		||||
		return false, &os.PathError{Op: "stat", Path: path, Err: err}
 | 
			
		||||
	}
 | 
			
		||||
	dev := st.Dev
 | 
			
		||||
@@ -49,14 +45,6 @@ func normalizePath(path string) (realPath string, err error) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func mountedByMountinfo(path string) (bool, error) {
 | 
			
		||||
	path, err := normalizePath(path)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if errors.Is(err, unix.ENOENT) {
 | 
			
		||||
			// treat ENOENT as "not mounted"
 | 
			
		||||
			return false, nil
 | 
			
		||||
		}
 | 
			
		||||
		return false, err
 | 
			
		||||
	}
 | 
			
		||||
	entries, err := GetMounts(SingleEntryFilter(path))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false, err
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								vendor/github.com/moby/sys/mountinfo/mountinfo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								vendor/github.com/moby/sys/mountinfo/mountinfo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -10,11 +10,12 @@ func GetMounts(f FilterFunc) ([]*Info, error) {
 | 
			
		||||
	return parseMountTable(f)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Mounted determines if a specified path is a mount point.
 | 
			
		||||
// Mounted determines if a specified path is a mount point. In case of any
 | 
			
		||||
// error, false (and an error) is returned.
 | 
			
		||||
//
 | 
			
		||||
// The argument must be an absolute path, with all symlinks resolved, and clean.
 | 
			
		||||
// One way to ensure it is to process the path using filepath.Abs followed by
 | 
			
		||||
// filepath.EvalSymlinks before calling this function.
 | 
			
		||||
// The non-existent path returns an error. If a caller is not interested
 | 
			
		||||
// in this particular error, it should handle it separately using e.g.
 | 
			
		||||
// errors.Is(err, os.ErrNotExist).
 | 
			
		||||
func Mounted(path string) (bool, error) {
 | 
			
		||||
	// root is always mounted
 | 
			
		||||
	if path == string(os.PathSeparator) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								vendor/github.com/moby/sys/mountinfo/mountinfo_bsd.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								vendor/github.com/moby/sys/mountinfo/mountinfo_bsd.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,3 +1,4 @@
 | 
			
		||||
//go:build (freebsd && cgo) || (openbsd && cgo) || (darwin && cgo)
 | 
			
		||||
// +build freebsd,cgo openbsd,cgo darwin,cgo
 | 
			
		||||
 | 
			
		||||
package mountinfo
 | 
			
		||||
@@ -55,6 +56,10 @@ func parseMountTable(filter FilterFunc) ([]*Info, error) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func mounted(path string) (bool, error) {
 | 
			
		||||
	path, err := normalizePath(path)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return false, err
 | 
			
		||||
	}
 | 
			
		||||
	// Fast path: compare st.st_dev fields.
 | 
			
		||||
	// This should always work for FreeBSD and OpenBSD.
 | 
			
		||||
	mounted, err := mountedByStat(path)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								vendor/github.com/moby/sys/mountinfo/mountinfo_unsupported.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/github.com/moby/sys/mountinfo/mountinfo_unsupported.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,3 +1,4 @@
 | 
			
		||||
//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
 | 
			
		||||
 | 
			
		||||
package mountinfo
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user