Skip to content

Commit

Permalink
Fixed incorrect path construction for lspci kernel driver lookup
Browse files Browse the repository at this point in the history
Fixed incorrect path construction for PCI device kernel driver lookup in lspci command.
  • Loading branch information
TimRots committed Jan 18, 2024
1 parent 0d44b4a commit 60b1cca
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pci/pci.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ func readFromFile(f string, w, start, end int) (string, error) {
return "", errors.New("invalid start:end")
}
return ret[start:end], nil
} else {
return ret, nil
}
}
}
Expand All @@ -78,13 +76,15 @@ func readFromFile(f string, w, start, end int) (string, error) {

func ParsePciDevices() (PciDevices []PciDevice, err error) {
var devices []string
var path string

read := func(bus, filename string, start, end int) (string, error) {
return readFromFile(filepath.Join(PATH_SYS_BUS_PCI_DEVICES, bus, filename), 1, start, end)
}

lookupKernelDriver := func(bus string) (string, error) {
read, err := readFromFile(filepath.Join(PATH_SYS_DEVICES_PCI+bus[0:7], bus, "uevent"), 1, 0, 0)
path = filepath.Join(PATH_SYS_BUS_PCI_DEVICES, bus, "uevent")
read, err := readFromFile(path, 1, 0, 0)
if err != nil {
return "", err
}
Expand Down

0 comments on commit 60b1cca

Please sign in to comment.