From 55c1d7c256bc879b963ea23978b75d51534e61d8 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Fri, 20 May 2022 09:57:41 +0200 Subject: [PATCH] Fix assertCharDevice matching on all files Signed-off-by: Evan Lezar --- CHANGELOG.md | 1 + internal/lookup/device.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9445d9f..537f98d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## v1.10.0-rc.3 +* Fix bug where links to devices were detected as devices * [libnvida-container] Fix bug introduced when adding libcudadebugger.so to list of libraries ## v1.10.0-rc.2 diff --git a/internal/lookup/device.go b/internal/lookup/device.go index 1cfc7ea2..29738cc7 100644 --- a/internal/lookup/device.go +++ b/internal/lookup/device.go @@ -42,11 +42,11 @@ func NewCharDeviceLocator(logger *logrus.Logger, root string) Locator { // assertCharDevice checks whether the specified path is a char device and returns an error if this is not the case. func assertCharDevice(filename string) error { - info, err := os.Stat(filename) + info, err := os.Lstat(filename) if err != nil { return fmt.Errorf("error getting info: %v", err) } - if info.Mode()|os.ModeCharDevice == 0 { + if info.Mode()&os.ModeCharDevice == 0 { return fmt.Errorf("%v is not a char device", filename) } return nil