summaryrefslogtreecommitdiff
path: root/vendor/github.com/opencontainers/runc/libcontainer/devices
diff options
context:
space:
mode:
authorTomSweeneyRedHat <tsweeney@redhat.com>2019-09-13 11:22:10 -0400
committerTomSweeneyRedHat <tsweeney@redhat.com>2019-09-13 11:22:14 -0400
commit440392d37beac78f66b5b35e0d8582b89c17a48d (patch)
treeab3131fc54b36ea773f20a7717dc55819108de3f /vendor/github.com/opencontainers/runc/libcontainer/devices
parent5c09c4d2947a759724f9d5aef6bac04317e03f7e (diff)
downloadpodman-440392d37beac78f66b5b35e0d8582b89c17a48d.tar.gz
podman-440392d37beac78f66b5b35e0d8582b89c17a48d.tar.bz2
podman-440392d37beac78f66b5b35e0d8582b89c17a48d.zip
Vendor Bulidah 1.11.2
Vendor in Buildah 1.11.2 into libpod/Podman Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Diffstat (limited to 'vendor/github.com/opencontainers/runc/libcontainer/devices')
-rw-r--r--vendor/github.com/opencontainers/runc/libcontainer/devices/devices.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/vendor/github.com/opencontainers/runc/libcontainer/devices/devices.go b/vendor/github.com/opencontainers/runc/libcontainer/devices/devices.go
index 5e2ab0581..5dabe06ce 100644
--- a/vendor/github.com/opencontainers/runc/libcontainer/devices/devices.go
+++ b/vendor/github.com/opencontainers/runc/libcontainer/devices/devices.go
@@ -7,11 +7,11 @@ import (
"path/filepath"
"github.com/opencontainers/runc/libcontainer/configs"
-
"golang.org/x/sys/unix"
)
var (
+ // ErrNotADevice denotes that a file is not a valid linux device.
ErrNotADevice = errors.New("not a device node")
)
@@ -21,7 +21,8 @@ var (
ioutilReadDir = ioutil.ReadDir
)
-// Given the path to a device and its cgroup_permissions(which cannot be easily queried) look up the information about a linux device and return that information as a Device struct.
+// Given the path to a device and its cgroup_permissions(which cannot be easily queried) look up the
+// information about a linux device and return that information as a Device struct.
func DeviceFromPath(path, permissions string) (*configs.Device, error) {
var stat unix.Stat_t
err := unixLstat(path, &stat)
@@ -60,25 +61,29 @@ func DeviceFromPath(path, permissions string) (*configs.Device, error) {
}, nil
}
+// HostDevices returns all devices that can be found under /dev directory.
func HostDevices() ([]*configs.Device, error) {
- return getDevices("/dev")
+ return GetDevices("/dev")
}
-func getDevices(path string) ([]*configs.Device, error) {
+// GetDevices recursively traverses a directory specified by path
+// and returns all devices found there.
+func GetDevices(path string) ([]*configs.Device, error) {
files, err := ioutilReadDir(path)
if err != nil {
return nil, err
}
- out := []*configs.Device{}
+ var out []*configs.Device
for _, f := range files {
switch {
case f.IsDir():
switch f.Name() {
// ".lxc" & ".lxd-mounts" added to address https://github.com/lxc/lxd/issues/2825
- case "pts", "shm", "fd", "mqueue", ".lxc", ".lxd-mounts":
+ // ".udev" added to address https://github.com/opencontainers/runc/issues/2093
+ case "pts", "shm", "fd", "mqueue", ".lxc", ".lxd-mounts", ".udev":
continue
default:
- sub, err := getDevices(filepath.Join(path, f.Name()))
+ sub, err := GetDevices(filepath.Join(path, f.Name()))
if err != nil {
return nil, err
}