mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
source/usb: scan host sysfs
Scan the mounted host sysfs instead of hard coded /sys mount point. Currently, sysfs devices subdir is not namespaced in Linux (containers have the same view as the host) so this wasn't an issue in practice. However, this change should make the code more future proof and align usb with other sysfs detection in nfd.
This commit is contained in:
parent
a65ee959b9
commit
bdbf96d7d4
1 changed files with 2 additions and 1 deletions
|
@ -26,6 +26,7 @@ import (
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
nfdv1alpha1 "sigs.k8s.io/node-feature-discovery/pkg/apis/nfd/v1alpha1"
|
nfdv1alpha1 "sigs.k8s.io/node-feature-discovery/pkg/apis/nfd/v1alpha1"
|
||||||
|
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
|
||||||
)
|
)
|
||||||
|
|
||||||
var devAttrs = []string{"class", "vendor", "device", "serial"}
|
var devAttrs = []string{"class", "vendor", "device", "serial"}
|
||||||
|
@ -106,7 +107,7 @@ func detectUsb() ([]nfdv1alpha1.InstanceFeature, error) {
|
||||||
// Unlike PCI, the USB sysfs interface includes entries not just for
|
// Unlike PCI, the USB sysfs interface includes entries not just for
|
||||||
// devices. We work around this by globbing anything that includes a
|
// devices. We work around this by globbing anything that includes a
|
||||||
// valid product ID.
|
// valid product ID.
|
||||||
const devPathGlob = "/sys/bus/usb/devices/*/idProduct"
|
devPathGlob := hostpath.SysfsDir.Path("bus/usb/devices/*/idProduct")
|
||||||
devPaths, err := filepath.Glob(devPathGlob)
|
devPaths, err := filepath.Glob(devPathGlob)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue