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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-12-08 14:48:04 +01:00
parent 95b83fa54f
commit 7f70ff9672
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C

View File

@ -81,24 +81,25 @@ func getDevices(path, containerPath string) ([]specs.LinuxDevice, error) {
} }
case f.Name() == "console": case f.Name() == "console":
continue continue
} default:
device, err := DeviceFromPath(filepath.Join(path, f.Name())) device, err := DeviceFromPath(filepath.Join(path, f.Name()))
if err != nil { if err != nil {
if err == ErrNotADevice { if err == ErrNotADevice {
continue
}
if os.IsNotExist(err) {
continue
}
return nil, err
}
if device.Type == fifoDevice {
continue continue
} }
if os.IsNotExist(err) { if containerPath != "" {
continue 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 return out, nil
} }