vendor: github.com/moby/sys mountinfo/v0.4.1

full diff: 1bc8673b57...b0f1fd7235

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-06-21 12:29:20 +02:00
parent f445637470
commit d6c55a105f
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
8 changed files with 109 additions and 25 deletions

View File

@ -48,7 +48,7 @@ github.com/Microsoft/hcsshim 5bc557dd210ff2caf615e6e22d39
github.com/miekg/pkcs11 210dc1e16747c5ba98a03bcbcf728c38086ea357 # v1.0.3 github.com/miekg/pkcs11 210dc1e16747c5ba98a03bcbcf728c38086ea357 # v1.0.3
github.com/mitchellh/mapstructure d16e9488127408e67948eb43b6d3fbb9f222da10 # v1.3.2 github.com/mitchellh/mapstructure d16e9488127408e67948eb43b6d3fbb9f222da10 # v1.3.2
github.com/moby/buildkit 8142d66b5ebde79846b869fba30d9d30633e74aa # v0.8.1 github.com/moby/buildkit 8142d66b5ebde79846b869fba30d9d30633e74aa # v0.8.1
github.com/moby/sys 1bc8673b57550ddf85262eb0fed0aac651a37dab # symlink/v0.1.0 (latest tag, either mount/vXXX, mountinfo/vXXX or symlink/vXXX) github.com/moby/sys b0f1fd7235275d01bd35cc4421e884e522395f45 # mountinfo/v0.4.1 (latest tag, either mount/vXXX, mountinfo/vXXX or symlink/vXXX)
github.com/moby/term 3f7ff695adc6a35abc925370dd0a4dafb48ec64d github.com/moby/term 3f7ff695adc6a35abc925370dd0a4dafb48ec64d
github.com/modern-go/concurrent bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94 # 1.0.3 github.com/modern-go/concurrent bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94 # 1.0.3
github.com/modern-go/reflect2 4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd # 1.0.1 github.com/modern-go/reflect2 4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd # 1.0.1

View File

@ -3,6 +3,6 @@ module github.com/moby/sys/mount
go 1.14 go 1.14
require ( require (
github.com/moby/sys/mountinfo v0.3.1 github.com/moby/sys/mountinfo v0.4.0
golang.org/x/sys v0.0.0-20200922070232-aee5d888a860 golang.org/x/sys v0.0.0-20200922070232-aee5d888a860
) )

View File

@ -1,4 +1,4 @@
// +build freebsd,cgo openbsd,cgo // +build freebsd,cgo
package mount package mount

77
vendor/github.com/moby/sys/mount/mounter_openbsd.go generated vendored Normal file
View File

@ -0,0 +1,77 @@
// +build openbsd,cgo
/*
Due to how OpenBSD mount(2) works, filesystem types need to be
supported explicitly since it uses separate structs to pass
filesystem-specific arguments.
For now only UFS/FFS is supported as it's the default fs
on OpenBSD systems.
See: https://man.openbsd.org/mount.2
*/
package mount
/*
#include <sys/types.h>
#include <sys/mount.h>
*/
import "C"
import (
"fmt"
"syscall"
"unsafe"
)
func createExportInfo(readOnly bool) C.struct_export_args {
exportFlags := C.int(0)
if readOnly {
exportFlags = C.MNT_EXRDONLY
}
out := C.struct_export_args{
ex_root: 0,
ex_flags: exportFlags,
}
return out
}
func createUfsArgs(device string, readOnly bool) unsafe.Pointer {
out := &C.struct_ufs_args{
fspec: C.CString(device),
export_info: createExportInfo(readOnly),
}
return unsafe.Pointer(out)
}
func mount(device, target, mType string, flag uintptr, data string) error {
readOnly := flag&RDONLY != 0
var fsArgs unsafe.Pointer
switch mType {
case "ffs":
fsArgs = createUfsArgs(device, readOnly)
default:
return &mountError{
op: "mount",
source: device,
target: target,
flags: flag,
err: fmt.Errorf("unsupported file system type: %s", mType),
}
}
if errno := C.mount(C.CString(mType), C.CString(target), C.int(flag), fsArgs); errno != 0 {
return &mountError{
op: "mount",
source: device,
target: target,
flags: flag,
err: syscall.Errno(errno),
}
}
return nil
}

View File

@ -29,35 +29,38 @@ type Info struct {
// ID is a unique identifier of the mount (may be reused after umount). // ID is a unique identifier of the mount (may be reused after umount).
ID int ID int
// Parent indicates the ID of the mount parent (or of self for the top of the // Parent is the ID of the parent mount (or of self for the root
// mount tree). // of this mount namespace's mount tree).
Parent int Parent int
// Major indicates one half of the device ID which identifies the device class. // Major and Minor are the major and the minor components of the Dev
Major int // field of unix.Stat_t structure returned by unix.*Stat calls for
// files on this filesystem.
Major, Minor int
// Minor indicates one half of the device ID which identifies a specific // Root is the pathname of the directory in the filesystem which forms
// instance of device. // the root of this mount.
Minor int
// Root of the mount within the filesystem.
Root string Root string
// Mountpoint indicates the mount point relative to the process's root. // Mountpoint is the pathname of the mount point relative to the
// process's root directory.
Mountpoint string Mountpoint string
// Options represents mount-specific options. // Options is a comma-separated list of mount options.
Options string Options string
// Optional represents optional fields. // Optional are zero or more fields of the form "tag[:value]",
// separated by a space. Currently, the possible optional fields are
// "shared", "master", "propagate_from", and "unbindable". For more
// information, see mount_namespaces(7) Linux man page.
Optional string Optional string
// FSType indicates the type of filesystem, such as EXT3. // FSType is the filesystem type in the form "type[.subtype]".
FSType string FSType string
// Source indicates filesystem specific information or "none". // Source is filesystem-specific information, or "none".
Source string Source string
// VFSOptions represents per super block options. // VFSOptions is a comma-separated list of superblock options.
VFSOptions string VFSOptions string
} }

View File

@ -14,11 +14,16 @@ import "strings"
// stop: true if parsing should be stopped after the entry. // stop: true if parsing should be stopped after the entry.
type FilterFunc func(*Info) (skip, stop bool) type FilterFunc func(*Info) (skip, stop bool)
// PrefixFilter discards all entries whose mount points // PrefixFilter discards all entries whose mount points do not start with, or
// do not start with a specific prefix. // are equal to the path specified in prefix. The prefix path must be absolute,
// have all symlinks resolved, and cleaned (i.e. no extra slashes or dots).
//
// PrefixFilter treats prefix as a path, not a partial prefix, which means that
// given "/foo", "/foo/bar" and "/foobar" entries, PrefixFilter("/foo") returns
// "/foo" and "/foo/bar", and discards "/foobar".
func PrefixFilter(prefix string) FilterFunc { func PrefixFilter(prefix string) FilterFunc {
return func(m *Info) (bool, bool) { return func(m *Info) (bool, bool) {
skip := !strings.HasPrefix(m.Mountpoint, prefix) skip := !strings.HasPrefix(m.Mountpoint+"/", prefix+"/")
return skip, false return skip, false
} }
} }

View File

@ -12,7 +12,8 @@ import (
// GetMountsFromReader retrieves a list of mounts from the // GetMountsFromReader retrieves a list of mounts from the
// reader provided, with an optional filter applied (use nil // reader provided, with an optional filter applied (use nil
// for no filter). This can be useful in tests or benchmarks // for no filter). This can be useful in tests or benchmarks
// that provide a fake mountinfo data. // that provide fake mountinfo data, or when a source other
// than /proc/self/mountinfo needs to be read from.
// //
// This function is Linux-specific. // This function is Linux-specific.
func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) { func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
@ -133,8 +134,6 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
return out, nil return out, nil
} }
// Parse /proc/self/mountinfo because comparing Dev and ino does not work from
// bind mounts
func parseMountTable(filter FilterFunc) ([]*Info, error) { func parseMountTable(filter FilterFunc) ([]*Info, error) {
f, err := os.Open("/proc/self/mountinfo") f, err := os.Open("/proc/self/mountinfo")
if err != nil { if err != nil {

View File

@ -1,5 +1,5 @@
module github.com/moby/sys/symlink module github.com/moby/sys/symlink
go 1.13 go 1.14
require golang.org/x/sys v0.0.0-20200922070232-aee5d888a860 require golang.org/x/sys v0.0.0-20200922070232-aee5d888a860