go.mod: github.com/moby/sys/mountinfo v0.6.2
https://github.com/moby/sys/compare/mountinfo/v0.6.0...mountinfo/v0.6.2 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
		
							
								
								
									
										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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user