Skip to content

Commit

Permalink
fix a bug where the oem field shows up as Unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
HikariKnight committed Apr 11, 2023
1 parent a2f4e2a commit e5f95c0
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions pkg/iommu/genoutput.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ import (
func GenDeviceLine(group int, device *pci.Device, pArg *params.Params) string {
var line string
var formated_line []string
var subvendor_name string

// We need to probe some extra info here so we need to use ghw
pci, err := ghw.PCI()
if err != nil {
fmt.Printf("Error getting PCI info: %v", err)
}

// Get the subvendor/OEM
subvendor := pci.Vendors[device.Subsystem.VendorID]

// If subvendor does exist
if subvendor != nil {
// Get the subvendor name
subvendor_name = pci.Vendors[device.Subsystem.VendorID].Name
} else {
// Else slap the vendor name on
subvendor_name = device.Vendor.Name
}

// If we want legacy output (to be output compatible with the bash version)
var iommu_group string
Expand Down Expand Up @@ -52,9 +71,9 @@ func GenDeviceLine(group int, device *pci.Device, pArg *params.Params) string {
case "prod_name:":
formated_line = append(formated_line, fmt.Sprintf("%s:", device.Product.Name))
case "oem":
formated_line = append(formated_line, device.Subsystem.Name)
formated_line = append(formated_line, subvendor_name)
case "oem:":
formated_line = append(formated_line, fmt.Sprintf("%s:", device.Subsystem.Name))
formated_line = append(formated_line, fmt.Sprintf("%s:", subvendor_name))
case "vendor":
formated_line = append(formated_line, device.Vendor.Name)
case "vendor:":
Expand Down

0 comments on commit e5f95c0

Please sign in to comment.