pkg/util: FindDeviceNodes() ignore ENOENT errors

This is racy by design, if you walk a tree and the directory was removed
between listing and then opening we get an ENOENT error. Simply ignore
that case and do not log it.

Fixes #21782

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2024-04-03 16:44:14 +02:00
parent 6b9b85e011
commit 498445871c

View File

@ -37,7 +37,9 @@ func FindDeviceNodes() (map[string]string, error) {
nodes := make(map[string]string)
err := filepath.WalkDir("/dev", func(path string, d fs.DirEntry, err error) error {
if err != nil {
logrus.Warnf("Error descending into path %s: %v", path, err)
if !errors.Is(err, fs.ErrNotExist) {
logrus.Warnf("Error descending into path %s: %v", path, err)
}
return filepath.SkipDir
}