mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
vendor: update to github.com/moby/sys/mountinfo@v0.7.1
The primary change is a switch to using /proc/thread-self, which is needed for when we add a CLONE_FS thread to runc. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
@@ -10,7 +10,7 @@ require (
|
|||||||
github.com/cyphar/filepath-securejoin v0.2.4
|
github.com/cyphar/filepath-securejoin v0.2.4
|
||||||
github.com/docker/go-units v0.5.0
|
github.com/docker/go-units v0.5.0
|
||||||
github.com/godbus/dbus/v5 v5.1.0
|
github.com/godbus/dbus/v5 v5.1.0
|
||||||
github.com/moby/sys/mountinfo v0.6.2
|
github.com/moby/sys/mountinfo v0.7.1
|
||||||
github.com/moby/sys/user v0.1.0
|
github.com/moby/sys/user v0.1.0
|
||||||
github.com/mrunalp/fileutils v0.5.1
|
github.com/mrunalp/fileutils v0.5.1
|
||||||
github.com/opencontainers/runtime-spec v1.1.1-0.20230823135140-4fec88fd00a4
|
github.com/opencontainers/runtime-spec v1.1.1-0.20230823135140-4fec88fd00a4
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
|||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78=
|
github.com/moby/sys/mountinfo v0.7.1 h1:/tTvQaSJRr2FshkhXiIpux6fQ2Zvc4j7tAhMTStAG2g=
|
||||||
github.com/moby/sys/mountinfo v0.6.2/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI=
|
github.com/moby/sys/mountinfo v0.7.1/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI=
|
||||||
github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg=
|
github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg=
|
||||||
github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU=
|
github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU=
|
||||||
github.com/mrunalp/fileutils v0.5.1 h1:F+S7ZlNKnrwHfSwdlgNSkKo67ReVf8o9fel6C3dkm/Q=
|
github.com/mrunalp/fileutils v0.5.1 h1:F+S7ZlNKnrwHfSwdlgNSkKo67ReVf8o9fel6C3dkm/Q=
|
||||||
|
|||||||
+43
-7
@@ -5,15 +5,19 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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 fake mountinfo data, or when a source other
|
// that provide fake mountinfo data, or when a source other
|
||||||
// than /proc/self/mountinfo needs to be read from.
|
// than /proc/thread-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) {
|
||||||
@@ -127,8 +131,40 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseMountTable(filter FilterFunc) ([]*Info, error) {
|
var (
|
||||||
f, err := os.Open("/proc/self/mountinfo")
|
haveProcThreadSelf bool
|
||||||
|
haveProcThreadSelfOnce sync.Once
|
||||||
|
)
|
||||||
|
|
||||||
|
func parseMountTable(filter FilterFunc) (_ []*Info, err error) {
|
||||||
|
haveProcThreadSelfOnce.Do(func() {
|
||||||
|
_, err := os.Stat("/proc/thread-self/mountinfo")
|
||||||
|
haveProcThreadSelf = err == nil
|
||||||
|
})
|
||||||
|
|
||||||
|
// We need to lock ourselves to the current OS thread in order to make sure
|
||||||
|
// that the thread referenced by /proc/thread-self stays alive until we
|
||||||
|
// finish parsing the file.
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
var f *os.File
|
||||||
|
if haveProcThreadSelf {
|
||||||
|
f, err = os.Open("/proc/thread-self/mountinfo")
|
||||||
|
} else {
|
||||||
|
// On pre-3.17 kernels (such as CentOS 7), we don't have
|
||||||
|
// /proc/thread-self/ so we need to manually construct
|
||||||
|
// /proc/self/task/<tid>/ as a fallback.
|
||||||
|
f, err = os.Open("/proc/self/task/" + strconv.Itoa(unix.Gettid()) + "/mountinfo")
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
// If /proc/self/task/... failed, it means that our active pid
|
||||||
|
// namespace doesn't match the pid namespace of the /proc mount. In
|
||||||
|
// this case we just have to make do with /proc/self, since there
|
||||||
|
// is no other way of figuring out our tid in a parent pid
|
||||||
|
// namespace on pre-3.17 kernels.
|
||||||
|
f, err = os.Open("/proc/self/mountinfo")
|
||||||
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -158,10 +194,10 @@ func PidMountInfo(pid int) ([]*Info, error) {
|
|||||||
// A few specific characters in mountinfo path entries (root and mountpoint)
|
// A few specific characters in mountinfo path entries (root and mountpoint)
|
||||||
// are escaped using a backslash followed by a character's ascii code in octal.
|
// are escaped using a backslash followed by a character's ascii code in octal.
|
||||||
//
|
//
|
||||||
// space -- as \040
|
// space -- as \040
|
||||||
// tab (aka \t) -- as \011
|
// tab (aka \t) -- as \011
|
||||||
// newline (aka \n) -- as \012
|
// newline (aka \n) -- as \012
|
||||||
// backslash (aka \\) -- as \134
|
// backslash (aka \\) -- as \134
|
||||||
//
|
//
|
||||||
// This function converts path from mountinfo back, i.e. it unescapes the above sequences.
|
// This function converts path from mountinfo back, i.e. it unescapes the above sequences.
|
||||||
func unescape(path string) (string, error) {
|
func unescape(path string) (string, error) {
|
||||||
|
|||||||
Vendored
+1
-1
@@ -33,7 +33,7 @@ github.com/docker/go-units
|
|||||||
# github.com/godbus/dbus/v5 v5.1.0
|
# github.com/godbus/dbus/v5 v5.1.0
|
||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
github.com/godbus/dbus/v5
|
github.com/godbus/dbus/v5
|
||||||
# github.com/moby/sys/mountinfo v0.6.2
|
# github.com/moby/sys/mountinfo v0.7.1
|
||||||
## explicit; go 1.16
|
## explicit; go 1.16
|
||||||
github.com/moby/sys/mountinfo
|
github.com/moby/sys/mountinfo
|
||||||
# github.com/moby/sys/user v0.1.0
|
# github.com/moby/sys/user v0.1.0
|
||||||
|
|||||||
Reference in New Issue
Block a user