ソースを参照

vendor: github.com/moby/sys/mount v0.3.0, mountinfo v0.5.0, signal v0.6.0, symlink v0.2.0

full diff: https://github.com/moby/sys/compare/signal/v0.5.0...signal/v0.6.0

Modules:

- github.com/moby/sys/mount v0.3.0
- github.com/moby/sys/mountinfo v0.5.0
- github.com/moby/sys/signal v0.6.0
- github.com/moby/sys/symlink v0.2.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 3 年 前
コミット
ce25968008
30 ファイル変更80 行追加74 行削除
  1. 4 2
      integration/container/kill_test.go
  2. 1 1
      vendor.conf
  3. 1 0
      vendor/github.com/moby/sys/mount/flags_bsd.go
  4. 2 1
      vendor/github.com/moby/sys/mount/flags_unix.go
  5. 3 3
      vendor/github.com/moby/sys/mount/go.mod
  6. 1 0
      vendor/github.com/moby/sys/mount/mount_errors.go
  7. 2 1
      vendor/github.com/moby/sys/mount/mount_unix.go
  8. 1 0
      vendor/github.com/moby/sys/mount/mounter_freebsd.go
  9. 0 1
      vendor/github.com/moby/sys/mount/mounter_linux.go
  10. 1 0
      vendor/github.com/moby/sys/mount/mounter_openbsd.go
  11. 1 0
      vendor/github.com/moby/sys/mount/mounter_unsupported.go
  12. 2 2
      vendor/github.com/moby/sys/mountinfo/go.mod
  13. 5 6
      vendor/github.com/moby/sys/mountinfo/mounted_linux.go
  14. 2 14
      vendor/github.com/moby/sys/mountinfo/mounted_unix.go
  15. 5 4
      vendor/github.com/moby/sys/mountinfo/mountinfo.go
  16. 7 2
      vendor/github.com/moby/sys/mountinfo/mountinfo_bsd.go
  17. 10 17
      vendor/github.com/moby/sys/mountinfo/mountinfo_linux.go
  18. 2 1
      vendor/github.com/moby/sys/mountinfo/mountinfo_unsupported.go
  19. 2 2
      vendor/github.com/moby/sys/signal/go.mod
  20. 2 2
      vendor/github.com/moby/sys/signal/signal.go
  21. 1 1
      vendor/github.com/moby/sys/signal/signal_darwin.go
  22. 1 1
      vendor/github.com/moby/sys/signal/signal_freebsd.go
  23. 1 0
      vendor/github.com/moby/sys/signal/signal_linux.go
  24. 1 0
      vendor/github.com/moby/sys/signal/signal_linux_mipsx.go
  25. 1 2
      vendor/github.com/moby/sys/signal/signal_unix.go
  26. 1 0
      vendor/github.com/moby/sys/signal/signal_unsupported.go
  27. 15 7
      vendor/github.com/moby/sys/signal/signal_windows.go
  28. 1 0
      vendor/github.com/moby/sys/symlink/fs_unix.go
  29. 2 2
      vendor/github.com/moby/sys/symlink/fs_windows.go
  30. 2 2
      vendor/github.com/moby/sys/symlink/go.mod

+ 4 - 2
integration/container/kill_test.go

@@ -21,11 +21,13 @@ func TestKillContainerInvalidSignal(t *testing.T) {
 	id := container.Run(ctx, t, client)
 
 	err := client.ContainerKill(ctx, id, "0")
-	assert.Error(t, err, "Error response from daemon: Invalid signal: 0")
+	assert.ErrorContains(t, err, "Error response from daemon:")
+	assert.ErrorContains(t, err, "nvalid signal: 0") // match "(I|i)nvalid" case-insensitive to allow testing against older daemons.
 	poll.WaitOn(t, container.IsInState(ctx, client, id, "running"), poll.WithDelay(100*time.Millisecond))
 
 	err = client.ContainerKill(ctx, id, "SIG42")
-	assert.Error(t, err, "Error response from daemon: Invalid signal: SIG42")
+	assert.ErrorContains(t, err, "Error response from daemon:")
+	assert.ErrorContains(t, err, "nvalid signal: SIG42") // match "(I|i)nvalid" case-insensitive to allow testing against older daemons.
 	poll.WaitOn(t, container.IsInState(ctx, client, id, "running"), poll.WithDelay(100*time.Millisecond))
 }
 

+ 1 - 1
vendor.conf

@@ -13,7 +13,7 @@ github.com/moby/term                                3f7ff695adc6a35abc925370dd0a
 # modules. Our vendoring tool (vndr) currently does not support submodules / vendoring sub-paths,
 # so we vendor the top-level moby/sys repository (which contains both) and pick the most recent tag,
 # which could be either `mountinfo/vX.Y.Z`, `mount/vX.Y.Z`, `signal/vX.Y.Z`, or `symlink/vX.Y.Z`.
-github.com/moby/sys                                 9b0136d132d8e0d1c116a38d7ec9af70d3a59536 # signal/v0.5.0
+github.com/moby/sys                                 03b9f8d59a07f5206a2264105f4903a222aea964 # signal/v0.6.0
 
 github.com/creack/pty                               2a38352e8b4d7ab6c336eef107e42a55e72e7fbc # v1.1.11
 github.com/sirupsen/logrus                          bdc0db8ead3853c56b7cd1ac2ba4e11b47d7da6b # v1.8.1

+ 1 - 0
vendor/github.com/moby/sys/mount/flags_bsd.go

@@ -1,3 +1,4 @@
+//go:build freebsd || openbsd
 // +build freebsd openbsd
 
 package mount

+ 2 - 1
vendor/github.com/moby/sys/mount/flags_unix.go

@@ -1,3 +1,4 @@
+//go:build !darwin && !windows
 // +build !darwin,!windows
 
 package mount
@@ -101,7 +102,7 @@ func MergeTmpfsOptions(options []string) ([]string, error) {
 		}
 		opt := strings.SplitN(option, "=", 2)
 		if len(opt) != 2 || !validFlags[opt[0]] {
-			return nil, fmt.Errorf("Invalid tmpfs option %q", opt)
+			return nil, fmt.Errorf("invalid tmpfs option %q", opt)
 		}
 		if !dataCollisions[opt[0]] {
 			// We prepend the option and add to collision map

+ 3 - 3
vendor/github.com/moby/sys/mount/go.mod

@@ -1,8 +1,8 @@
 module github.com/moby/sys/mount
 
-go 1.14
+go 1.16
 
 require (
-	github.com/moby/sys/mountinfo v0.4.1
-	golang.org/x/sys v0.0.0-20200922070232-aee5d888a860
+	github.com/moby/sys/mountinfo v0.5.0
+	golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359
 )

+ 1 - 0
vendor/github.com/moby/sys/mount/mount_errors.go

@@ -1,3 +1,4 @@
+//go:build !windows
 // +build !windows
 
 package mount

+ 2 - 1
vendor/github.com/moby/sys/mount/mount_unix.go

@@ -1,3 +1,4 @@
+//go:build !darwin && !windows
 // +build !darwin,!windows
 
 package mount
@@ -22,7 +23,7 @@ func Mount(device, target, mType, options string) error {
 // a normal unmount. If target is not a mount point, no error is returned.
 func Unmount(target string) error {
 	err := unix.Unmount(target, mntDetach)
-	if err == nil || err == unix.EINVAL {
+	if err == nil || err == unix.EINVAL { //nolint:errorlint // unix errors are bare
 		// Ignore "not mounted" error here. Note the same error
 		// can be returned if flags are invalid, so this code
 		// assumes that the flags value is always correct.

+ 1 - 0
vendor/github.com/moby/sys/mount/mounter_freebsd.go

@@ -1,3 +1,4 @@
+//go:build freebsd && cgo
 // +build freebsd,cgo
 
 package mount

+ 0 - 1
vendor/github.com/moby/sys/mount/mounter_linux.go

@@ -65,7 +65,6 @@ func mount(device, target, mType string, flags uintptr, data string) error {
 				flags:  oflags | unix.MS_REMOUNT,
 				err:    err,
 			}
-
 		}
 	}
 

+ 1 - 0
vendor/github.com/moby/sys/mount/mounter_openbsd.go

@@ -1,3 +1,4 @@
+//go:build openbsd && cgo
 // +build openbsd,cgo
 
 /*

+ 1 - 0
vendor/github.com/moby/sys/mount/mounter_unsupported.go

@@ -1,3 +1,4 @@
+//go:build (!linux && !freebsd && !openbsd && !windows) || (freebsd && !cgo) || (openbsd && !cgo)
 // +build !linux,!freebsd,!openbsd,!windows freebsd,!cgo openbsd,!cgo
 
 package mount

+ 2 - 2
vendor/github.com/moby/sys/mountinfo/go.mod

@@ -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

+ 5 - 6
vendor/github.com/moby/sys/mountinfo/mounted_linux.go

@@ -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 {

+ 2 - 14
vendor/github.com/moby/sys/mountinfo/mounted_unix.go

@@ -1,9 +1,9 @@
-// +build linux freebsd,cgo openbsd,cgo
+//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

+ 5 - 4
vendor/github.com/moby/sys/mountinfo/mountinfo.go

@@ -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) {

+ 7 - 2
vendor/github.com/moby/sys/mountinfo/mountinfo_bsd.go

@@ -1,4 +1,5 @@
-// +build freebsd,cgo openbsd,cgo
+//go:build (freebsd && cgo) || (openbsd && cgo) || (darwin && cgo)
+// +build freebsd,cgo openbsd,cgo darwin,cgo
 
 package mountinfo
 
@@ -21,7 +22,7 @@ func parseMountTable(filter FilterFunc) ([]*Info, error) {
 
 	count := int(C.getmntinfo(&rawEntries, C.MNT_WAIT))
 	if count == 0 {
-		return nil, fmt.Errorf("Failed to call getmntinfo")
+		return nil, fmt.Errorf("failed to call getmntinfo")
 	}
 
 	var entries []C.struct_statfs
@@ -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)

+ 10 - 17
vendor/github.com/moby/sys/mountinfo/mountinfo_linux.go

@@ -52,7 +52,7 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
 		numFields := len(fields)
 		if numFields < 10 {
 			// should be at least 10 fields
-			return nil, fmt.Errorf("Parsing '%s' failed: not enough fields (%d)", text, numFields)
+			return nil, fmt.Errorf("parsing '%s' failed: not enough fields (%d)", text, numFields)
 		}
 
 		// separator field
@@ -67,7 +67,7 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
 		for fields[sepIdx] != "-" {
 			sepIdx--
 			if sepIdx == 5 {
-				return nil, fmt.Errorf("Parsing '%s' failed: missing - separator", text)
+				return nil, fmt.Errorf("parsing '%s' failed: missing - separator", text)
 			}
 		}
 
@@ -75,46 +75,39 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
 
 		p.Mountpoint, err = unescape(fields[4])
 		if err != nil {
-			return nil, fmt.Errorf("Parsing '%s' failed: mount point: %w", fields[4], err)
+			return nil, fmt.Errorf("parsing '%s' failed: mount point: %w", fields[4], err)
 		}
 		p.FSType, err = unescape(fields[sepIdx+1])
 		if err != nil {
-			return nil, fmt.Errorf("Parsing '%s' failed: fstype: %w", fields[sepIdx+1], err)
+			return nil, fmt.Errorf("parsing '%s' failed: fstype: %w", fields[sepIdx+1], err)
 		}
 		p.Source, err = unescape(fields[sepIdx+2])
 		if err != nil {
-			return nil, fmt.Errorf("Parsing '%s' failed: source: %w", fields[sepIdx+2], err)
+			return nil, fmt.Errorf("parsing '%s' failed: source: %w", fields[sepIdx+2], err)
 		}
 		p.VFSOptions = fields[sepIdx+3]
 
 		// ignore any numbers parsing errors, as there should not be any
 		p.ID, _ = strconv.Atoi(fields[0])
 		p.Parent, _ = strconv.Atoi(fields[1])
-		mm := strings.Split(fields[2], ":")
+		mm := strings.SplitN(fields[2], ":", 3)
 		if len(mm) != 2 {
-			return nil, fmt.Errorf("Parsing '%s' failed: unexpected minor:major pair %s", text, mm)
+			return nil, fmt.Errorf("parsing '%s' failed: unexpected major:minor pair %s", text, mm)
 		}
 		p.Major, _ = strconv.Atoi(mm[0])
 		p.Minor, _ = strconv.Atoi(mm[1])
 
 		p.Root, err = unescape(fields[3])
 		if err != nil {
-			return nil, fmt.Errorf("Parsing '%s' failed: root: %w", fields[3], err)
+			return nil, fmt.Errorf("parsing '%s' failed: root: %w", fields[3], err)
 		}
 
 		p.Options = fields[5]
 
 		// zero or more optional fields
-		switch {
-		case sepIdx == 6:
-			// zero, do nothing
-		case sepIdx == 7:
-			p.Optional = fields[6]
-		default:
-			p.Optional = strings.Join(fields[6:sepIdx-1], " ")
-		}
+		p.Optional = strings.Join(fields[6:sepIdx], " ")
 
-		// Run the filter after parsing all of the fields.
+		// Run the filter after parsing all fields.
 		var skip, stop bool
 		if filter != nil {
 			skip, stop = filter(p)

+ 2 - 1
vendor/github.com/moby/sys/mountinfo/mountinfo_unsupported.go

@@ -1,4 +1,5 @@
-// +build !windows,!linux,!freebsd,!openbsd freebsd,!cgo openbsd,!cgo
+//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
 

+ 2 - 2
vendor/github.com/moby/sys/signal/go.mod

@@ -1,5 +1,5 @@
 module github.com/moby/sys/signal
 
-go 1.13
+go 1.16
 
-require golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
+require golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359

+ 2 - 2
vendor/github.com/moby/sys/signal/signal.go

@@ -39,13 +39,13 @@ func ParseSignal(rawSignal string) (syscall.Signal, error) {
 	s, err := strconv.Atoi(rawSignal)
 	if err == nil {
 		if s == 0 {
-			return -1, fmt.Errorf("Invalid signal: %s", rawSignal)
+			return -1, fmt.Errorf("invalid signal: %s", rawSignal)
 		}
 		return syscall.Signal(s), nil
 	}
 	signal, ok := SignalMap[strings.TrimPrefix(strings.ToUpper(rawSignal), "SIG")]
 	if !ok {
-		return -1, fmt.Errorf("Invalid signal: %s", rawSignal)
+		return -1, fmt.Errorf("invalid signal: %s", rawSignal)
 	}
 	return signal, nil
 }

+ 1 - 1
vendor/github.com/moby/sys/signal/signal_darwin.go

@@ -8,7 +8,7 @@ import (
 var SignalMap = map[string]syscall.Signal{
 	"ABRT":   syscall.SIGABRT,
 	"ALRM":   syscall.SIGALRM,
-	"BUG":    syscall.SIGBUS,
+	"BUS":    syscall.SIGBUS,
 	"CHLD":   syscall.SIGCHLD,
 	"CONT":   syscall.SIGCONT,
 	"EMT":    syscall.SIGEMT,

+ 1 - 1
vendor/github.com/moby/sys/signal/signal_freebsd.go

@@ -8,7 +8,7 @@ import (
 var SignalMap = map[string]syscall.Signal{
 	"ABRT":   syscall.SIGABRT,
 	"ALRM":   syscall.SIGALRM,
-	"BUF":    syscall.SIGBUS,
+	"BUS":    syscall.SIGBUS,
 	"CHLD":   syscall.SIGCHLD,
 	"CONT":   syscall.SIGCONT,
 	"EMT":    syscall.SIGEMT,

+ 1 - 0
vendor/github.com/moby/sys/signal/signal_linux.go

@@ -1,3 +1,4 @@
+//go:build !mips && !mipsle && !mips64 && !mips64le
 // +build !mips,!mipsle,!mips64,!mips64le
 
 package signal

+ 1 - 0
vendor/github.com/moby/sys/signal/signal_linux_mipsx.go

@@ -1,3 +1,4 @@
+//go:build linux && (mips || mipsle || mips64 || mips64le)
 // +build linux
 // +build mips mipsle mips64 mips64le
 

+ 1 - 2
vendor/github.com/moby/sys/signal/signal_unix.go

@@ -1,3 +1,4 @@
+//go:build !windows
 // +build !windows
 
 package signal
@@ -16,6 +17,4 @@ const (
 	SIGWINCH = syscall.SIGWINCH
 	// SIGPIPE is a signal sent to a process when a pipe is written to before the other end is open for reading
 	SIGPIPE = syscall.SIGPIPE
-	// DefaultStopSignal is the syscall signal used to stop a container in unix systems.
-	DefaultStopSignal = "SIGTERM"
 )

+ 1 - 0
vendor/github.com/moby/sys/signal/signal_unsupported.go

@@ -1,3 +1,4 @@
+//go:build !linux && !darwin && !freebsd && !windows
 // +build !linux,!darwin,!freebsd,!windows
 
 package signal

+ 15 - 7
vendor/github.com/moby/sys/signal/signal_windows.go

@@ -2,6 +2,8 @@ package signal
 
 import (
 	"syscall"
+
+	"golang.org/x/sys/windows"
 )
 
 // Signals used in cli/command (no windows equivalent, use
@@ -10,17 +12,23 @@ const (
 	SIGCHLD  = syscall.Signal(0xff)
 	SIGWINCH = syscall.Signal(0xff)
 	SIGPIPE  = syscall.Signal(0xff)
-	// DefaultStopSignal is the syscall signal used to stop a container in windows systems.
-	DefaultStopSignal = "15"
 )
 
 // SignalMap is a map of "supported" signals. As per the comment in GOLang's
 // ztypes_windows.go: "More invented values for signals". Windows doesn't
 // really support signals in any way, shape or form that Unix does.
-//
-// We have these so that docker kill can be used to gracefully (TERM) and
-// forcibly (KILL) terminate a container on Windows.
 var SignalMap = map[string]syscall.Signal{
-	"KILL": syscall.SIGKILL,
-	"TERM": syscall.SIGTERM,
+	"ABRT": syscall.Signal(windows.SIGABRT),
+	"ALRM": syscall.Signal(windows.SIGALRM),
+	"BUS":  syscall.Signal(windows.SIGBUS),
+	"FPE":  syscall.Signal(windows.SIGFPE),
+	"HUP":  syscall.Signal(windows.SIGHUP),
+	"ILL":  syscall.Signal(windows.SIGILL),
+	"INT":  syscall.Signal(windows.SIGINT),
+	"KILL": syscall.Signal(windows.SIGKILL),
+	"PIPE": syscall.Signal(windows.SIGPIPE),
+	"QUIT": syscall.Signal(windows.SIGQUIT),
+	"SEGV": syscall.Signal(windows.SIGSEGV),
+	"TERM": syscall.Signal(windows.SIGTERM),
+	"TRAP": syscall.Signal(windows.SIGTRAP),
 }

+ 1 - 0
vendor/github.com/moby/sys/symlink/fs_unix.go

@@ -1,3 +1,4 @@
+//go:build !windows
 // +build !windows
 
 package symlink

+ 2 - 2
vendor/github.com/moby/sys/symlink/fs_windows.go

@@ -89,7 +89,7 @@ func walkSymlinks(path string) (string, error) {
 	var b bytes.Buffer
 	for n := 0; path != ""; n++ {
 		if n > maxIter {
-			return "", errors.New("EvalSymlinks: too many links in " + originalPath)
+			return "", errors.New("too many links in " + originalPath)
 		}
 
 		// A path beginning with `\\?\` represents the root, so automatically
@@ -101,7 +101,7 @@ func walkSymlinks(path string) (string, error) {
 		}
 
 		// find next path component, p
-		var i = -1
+		i := -1
 		for j, c := range path {
 			if c < utf8RuneSelf && os.IsPathSeparator(uint8(c)) {
 				i = j

+ 2 - 2
vendor/github.com/moby/sys/symlink/go.mod

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