diff --git a/sysfs/class_infiniband.go b/sysfs/class_infiniband.go index 0eab1eb16..be900fa94 100644 --- a/sysfs/class_infiniband.go +++ b/sysfs/class_infiniband.go @@ -251,7 +251,7 @@ func parseInfiniBandCounters(portPath string) (*InfiniBandCounters, error) { name := filepath.Join(path, f.Name()) value, err := util.SysReadFile(name) if err != nil { - if os.IsNotExist(err) || err.Error() == "operation not supported" || err.Error() == "invalid argument" { + if os.IsNotExist(err) || os.IsPermission(err) || err.Error() == "operation not supported" || err.Error() == "invalid argument" { continue } return nil, fmt.Errorf("failed to read file %q: %v", name, err) @@ -334,7 +334,7 @@ func parseInfiniBandCounters(portPath string) (*InfiniBandCounters, error) { name := filepath.Join(path, f.Name()) value, err := util.SysReadFile(name) if err != nil { - if os.IsNotExist(err) || err.Error() == "operation not supported" || err.Error() == "invalid argument" { + if os.IsNotExist(err) || os.IsPermission(err) || err.Error() == "operation not supported" || err.Error() == "invalid argument" { continue } return nil, fmt.Errorf("failed to read file %q: %v", name, err) diff --git a/sysfs/net_class.go b/sysfs/net_class.go index 9aa6b57fb..8f6498774 100644 --- a/sysfs/net_class.go +++ b/sysfs/net_class.go @@ -119,7 +119,7 @@ func (nc NetClass) parseNetClassIface(devicePath string) (*NetClassIface, error) name := filepath.Join(devicePath, f.Name()) value, err := util.SysReadFile(name) if err != nil { - if os.IsNotExist(err) || err.Error() == "operation not supported" || err.Error() == "invalid argument" { + if os.IsNotExist(err) || os.IsPermission(err) || err.Error() == "operation not supported" || err.Error() == "invalid argument" { continue } return nil, fmt.Errorf("failed to read file %q: %v", name, err)