diff options
Diffstat (limited to 'vendor/github.com/moby/sys')
-rw-r--r-- | vendor/github.com/moby/sys/mount/doc.go | 4 | ||||
-rw-r--r-- | vendor/github.com/moby/sys/mount/flags_bsd.go (renamed from vendor/github.com/moby/sys/mount/flags_freebsd.go) | 17 | ||||
-rw-r--r-- | vendor/github.com/moby/sys/mount/flags_unix.go (renamed from vendor/github.com/moby/sys/mount/flags.go) | 2 | ||||
-rw-r--r-- | vendor/github.com/moby/sys/mount/flags_unsupported.go | 30 | ||||
-rw-r--r-- | vendor/github.com/moby/sys/mount/go.mod | 4 | ||||
-rw-r--r-- | vendor/github.com/moby/sys/mount/go.sum | 9 | ||||
-rw-r--r-- | vendor/github.com/moby/sys/mount/mount_unix.go (renamed from vendor/github.com/moby/sys/mount/mount.go) | 36 | ||||
-rw-r--r-- | vendor/github.com/moby/sys/mount/mounter_bsd.go (renamed from vendor/github.com/moby/sys/mount/mounter_freebsd.go) | 2 | ||||
-rw-r--r-- | vendor/github.com/moby/sys/mount/mounter_unsupported.go | 4 | ||||
-rw-r--r-- | vendor/github.com/moby/sys/mount/unmount_unix.go | 26 | ||||
-rw-r--r-- | vendor/github.com/moby/sys/mount/unmount_unsupported.go | 11 |
11 files changed, 52 insertions, 93 deletions
diff --git a/vendor/github.com/moby/sys/mount/doc.go b/vendor/github.com/moby/sys/mount/doc.go new file mode 100644 index 000000000..86c2e01bb --- /dev/null +++ b/vendor/github.com/moby/sys/mount/doc.go @@ -0,0 +1,4 @@ +// Package mount provides a set of functions to mount and unmount mounts. +// +// Currently it supports Linux. For historical reasons, there is also some support for FreeBSD. +package mount diff --git a/vendor/github.com/moby/sys/mount/flags_freebsd.go b/vendor/github.com/moby/sys/mount/flags_bsd.go index 69c50680d..27d8440aa 100644 --- a/vendor/github.com/moby/sys/mount/flags_freebsd.go +++ b/vendor/github.com/moby/sys/mount/flags_bsd.go @@ -1,28 +1,25 @@ -// +build freebsd,cgo +// +build freebsd openbsd package mount -/* -#include <sys/mount.h> -*/ -import "C" +import "golang.org/x/sys/unix" const ( // RDONLY will mount the filesystem as read-only. - RDONLY = C.MNT_RDONLY + RDONLY = unix.MNT_RDONLY // NOSUID will not allow set-user-identifier or set-group-identifier bits to // take effect. - NOSUID = C.MNT_NOSUID + NOSUID = unix.MNT_NOSUID // NOEXEC will not allow execution of any binaries on the mounted file system. - NOEXEC = C.MNT_NOEXEC + NOEXEC = unix.MNT_NOEXEC // SYNCHRONOUS will allow any I/O to the file system to be done synchronously. - SYNCHRONOUS = C.MNT_SYNCHRONOUS + SYNCHRONOUS = unix.MNT_SYNCHRONOUS // NOATIME will not update the file access time when reading from a file. - NOATIME = C.MNT_NOATIME + NOATIME = unix.MNT_NOATIME ) // These flags are unsupported. diff --git a/vendor/github.com/moby/sys/mount/flags.go b/vendor/github.com/moby/sys/mount/flags_unix.go index d514a9d8e..995d72807 100644 --- a/vendor/github.com/moby/sys/mount/flags.go +++ b/vendor/github.com/moby/sys/mount/flags_unix.go @@ -1,3 +1,5 @@ +// +build !darwin,!windows + package mount import ( diff --git a/vendor/github.com/moby/sys/mount/flags_unsupported.go b/vendor/github.com/moby/sys/mount/flags_unsupported.go deleted file mode 100644 index e1d64f6b9..000000000 --- a/vendor/github.com/moby/sys/mount/flags_unsupported.go +++ /dev/null @@ -1,30 +0,0 @@ -// +build !linux,!freebsd freebsd,!cgo - -package mount - -// These flags are unsupported. -const ( - BIND = 0 - DIRSYNC = 0 - MANDLOCK = 0 - NOATIME = 0 - NODEV = 0 - NODIRATIME = 0 - NOEXEC = 0 - NOSUID = 0 - UNBINDABLE = 0 - RUNBINDABLE = 0 - PRIVATE = 0 - RPRIVATE = 0 - SHARED = 0 - RSHARED = 0 - SLAVE = 0 - RSLAVE = 0 - RBIND = 0 - RELATIME = 0 - REMOUNT = 0 - STRICTATIME = 0 - SYNCHRONOUS = 0 - RDONLY = 0 - mntDetach = 0 -) diff --git a/vendor/github.com/moby/sys/mount/go.mod b/vendor/github.com/moby/sys/mount/go.mod index 21cef0a95..e1e03a376 100644 --- a/vendor/github.com/moby/sys/mount/go.mod +++ b/vendor/github.com/moby/sys/mount/go.mod @@ -3,6 +3,6 @@ module github.com/moby/sys/mount go 1.14 require ( - github.com/moby/sys/mountinfo v0.1.0 - golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae + github.com/moby/sys/mountinfo v0.4.0 + golang.org/x/sys v0.0.0-20200922070232-aee5d888a860 ) diff --git a/vendor/github.com/moby/sys/mount/go.sum b/vendor/github.com/moby/sys/mount/go.sum index ae99f8596..7c39d597b 100644 --- a/vendor/github.com/moby/sys/mount/go.sum +++ b/vendor/github.com/moby/sys/mount/go.sum @@ -1,4 +1,5 @@ -github.com/moby/sys/mountinfo v0.1.0 h1:r8vMRbMAFEAfiNptYVokP+nfxPJzvRuia5e2vzXtENo= -github.com/moby/sys/mountinfo v0.1.0/go.mod h1:w2t2Avltqx8vE7gX5l+QiBKxODu2TX0+Syr3h52Tw4o= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +github.com/moby/sys/mountinfo v0.4.0 h1:1KInV3Huv18akCu58V7lzNlt+jFmqlu1EaErnEHE/VM= +github.com/moby/sys/mountinfo v0.4.0/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= +golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200922070232-aee5d888a860 h1:YEu4SMq7D0cmT7CBbXfcH0NZeuChAXwsHe/9XueUO6o= +golang.org/x/sys v0.0.0-20200922070232-aee5d888a860/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/vendor/github.com/moby/sys/mount/mount.go b/vendor/github.com/moby/sys/mount/mount_unix.go index 4a7bb27b1..a250bfc80 100644 --- a/vendor/github.com/moby/sys/mount/mount.go +++ b/vendor/github.com/moby/sys/mount/mount_unix.go @@ -1,4 +1,4 @@ -// +build go1.13 +// +build !darwin,!windows package mount @@ -7,6 +7,7 @@ import ( "sort" "github.com/moby/sys/mountinfo" + "golang.org/x/sys/unix" ) // Mount will mount filesystem according to the specified configuration. @@ -18,9 +19,22 @@ func Mount(device, target, mType, options string) error { } // Unmount lazily unmounts a filesystem on supported platforms, otherwise does -// a normal unmount. If target is not a mount point, no error is returned. +// a normal unmount. If target is not a mount point, no error is returned. func Unmount(target string) error { - return unmount(target, mntDetach) + err := unix.Unmount(target, mntDetach) + if err == nil || err == unix.EINVAL { + // 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. + return nil + } + + return &mountError{ + op: "umount", + target: target, + flags: uintptr(mntDetach), + err: err, + } } // RecursiveUnmount unmounts the target and all mounts underneath, starting @@ -32,7 +46,7 @@ func RecursiveUnmount(target string) error { // platforms, if there are submounts, we'll get EBUSY (and fall back // to the slow path). NOTE we do not ignore EINVAL here as target might // not be a mount point itself (but there can be mounts underneath). - if err := unmountBare(target, mntDetach); err == nil { + if err := unix.Unmount(target, mntDetach); err == nil { return nil } @@ -47,12 +61,18 @@ func RecursiveUnmount(target string) error { return len(mounts[i].Mountpoint) > len(mounts[j].Mountpoint) }) - var suberr error + var ( + suberr error + lastMount = len(mounts) - 1 + ) for i, m := range mounts { - err = unmount(m.Mountpoint, mntDetach) + err = Unmount(m.Mountpoint) if err != nil { - if i == len(mounts)-1 { // last mount - return fmt.Errorf("%w (possible cause: %s)", err, suberr) + if i == lastMount { + if suberr != nil { + return fmt.Errorf("%w (possible cause: %s)", err, suberr) + } + return err } // This is a submount, we can ignore the error for now, // the final unmount will fail if this is a real problem. diff --git a/vendor/github.com/moby/sys/mount/mounter_freebsd.go b/vendor/github.com/moby/sys/mount/mounter_bsd.go index 3964af4f7..656b762fe 100644 --- a/vendor/github.com/moby/sys/mount/mounter_freebsd.go +++ b/vendor/github.com/moby/sys/mount/mounter_bsd.go @@ -1,3 +1,5 @@ +// +build freebsd,cgo openbsd,cgo + package mount /* diff --git a/vendor/github.com/moby/sys/mount/mounter_unsupported.go b/vendor/github.com/moby/sys/mount/mounter_unsupported.go index 15380671c..e7ff5bd9f 100644 --- a/vendor/github.com/moby/sys/mount/mounter_unsupported.go +++ b/vendor/github.com/moby/sys/mount/mounter_unsupported.go @@ -1,7 +1,7 @@ -// +build !linux,!freebsd freebsd,!cgo +// +build !linux,!freebsd,!openbsd,!windows freebsd,!cgo openbsd,!cgo package mount func mount(device, target, mType string, flag uintptr, data string) error { - panic("Not implemented") + panic("cgo required on freebsd and openbsd") } diff --git a/vendor/github.com/moby/sys/mount/unmount_unix.go b/vendor/github.com/moby/sys/mount/unmount_unix.go deleted file mode 100644 index 924d059a7..000000000 --- a/vendor/github.com/moby/sys/mount/unmount_unix.go +++ /dev/null @@ -1,26 +0,0 @@ -// +build !windows - -package mount - -import "golang.org/x/sys/unix" - -func unmountBare(target string, flags int) error { - return unix.Unmount(target, flags) -} - -func unmount(target string, flags int) error { - err := unmountBare(target, flags) - if err == nil || err == unix.EINVAL { - // 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. - return nil - } - - return &mountError{ - op: "umount", - target: target, - flags: uintptr(flags), - err: err, - } -} diff --git a/vendor/github.com/moby/sys/mount/unmount_unsupported.go b/vendor/github.com/moby/sys/mount/unmount_unsupported.go deleted file mode 100644 index 4d6073ec6..000000000 --- a/vendor/github.com/moby/sys/mount/unmount_unsupported.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build windows - -package mount - -func unmountBare(_ string, _ int) error { - panic("Not implemented") -} - -func unmount(_ string, _ int) error { - panic("Not implemented") -} |