From b7b7524f5f53913fb8600ab0f2720f5f7a146293 Mon Sep 17 00:00:00 2001 From: Alejandro Ojeda Date: Fri, 24 Oct 2014 20:04:20 +0200 Subject: [PATCH] modified devices: filter /dev/console out of... Applied crosbymichael's suggested changes Signed-off-by: Alejandro Ojeda --- devices/devices.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/devices/devices.go b/devices/devices.go index d9a2181b..5bf80e8c 100644 --- a/devices/devices.go +++ b/devices/devices.go @@ -100,7 +100,8 @@ func getDeviceNodes(path string) ([]*Device, error) { out := []*Device{} for _, f := range files { - if f.IsDir() { + switch { + case f.IsDir(): switch f.Name() { case "pts", "shm", "fd": continue @@ -113,21 +114,18 @@ func getDeviceNodes(path string) ([]*Device, error) { out = append(out, sub...) continue } + case f.Name() == "console": + continue } - switch f.Name() { - case "console": - continue - default: - device, err := GetDevice(filepath.Join(path, f.Name()), "rwm") - if err != nil { - if err == ErrNotADeviceNode { - continue - } - return nil, err + device, err := GetDevice(filepath.Join(path, f.Name()), "rwm") + if err != nil { + if err == ErrNotADeviceNode { + continue } - out = append(out, device) + return nil, err } + out = append(out, device) } return out, nil