From 7f70ff96727761092c2b07a53b65d1cc5c137c6c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 8 Dec 2021 14:48:04 +0100 Subject: [PATCH] oci.getDevices(): move "non-dir, non '/dev/console'" case into switch This makes it slightly clearer that these are all part of the same logic. Signed-off-by: Sebastiaan van Stijn --- oci/utils_unix.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/oci/utils_unix.go b/oci/utils_unix.go index 7d42901e3..7063184ea 100644 --- a/oci/utils_unix.go +++ b/oci/utils_unix.go @@ -81,24 +81,25 @@ func getDevices(path, containerPath string) ([]specs.LinuxDevice, error) { } case f.Name() == "console": continue - } - device, err := DeviceFromPath(filepath.Join(path, f.Name())) - if err != nil { - if err == ErrNotADevice { + default: + device, err := DeviceFromPath(filepath.Join(path, f.Name())) + if err != nil { + if err == ErrNotADevice { + continue + } + if os.IsNotExist(err) { + continue + } + return nil, err + } + if device.Type == fifoDevice { continue } - if os.IsNotExist(err) { - continue + if containerPath != "" { + device.Path = filepath.Join(containerPath, filepath.Base(f.Name())) } - return nil, err + out = append(out, *device) } - if device.Type == fifoDevice { - continue - } - if containerPath != "" { - device.Path = filepath.Join(containerPath, filepath.Base(f.Name())) - } - out = append(out, *device) } return out, nil }