Merge branch 'fix-char-device' into 'main'

Fix assertCharDevice matching on all files

See merge request nvidia/container-toolkit/container-toolkit!155
This commit is contained in:
Evan Lezar 2022-05-20 10:32:51 +00:00
commit f656b5c887
2 changed files with 3 additions and 2 deletions

View File

@ -2,6 +2,7 @@
## v1.10.0-rc.3 ## 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 * [libnvida-container] Fix bug introduced when adding libcudadebugger.so to list of libraries
## v1.10.0-rc.2 ## v1.10.0-rc.2

View File

@ -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. // 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 { func assertCharDevice(filename string) error {
info, err := os.Stat(filename) info, err := os.Lstat(filename)
if err != nil { if err != nil {
return fmt.Errorf("error getting info: %v", err) 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 fmt.Errorf("%v is not a char device", filename)
} }
return nil return nil