Skip to content

Commit

Permalink
change -r to be look for related devices in the same group and -rr to…
Browse files Browse the repository at this point in the history
… look for group and vendorID
  • Loading branch information
HikariKnight committed Apr 26, 2023
1 parent e5f95c0 commit ffcf6ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions pkg/iommu/iommu.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func MatchSubclass(searchval string, pArg *params.Params) []string {
alldevs := NewIOMMU()

// Make a regex to find devices that will need special exceptions for relative search
specialRelativeExceptions := regexp.MustCompile(`^(SATA|USB) controller`)
//specialRelativeExceptions := regexp.MustCompile(`^(SATA|USB) controller`)

// Iterate through the groups
for id := 0; id < len(alldevs.Groups); id++ {
Expand All @@ -153,15 +153,15 @@ func MatchSubclass(searchval string, pArg *params.Params) []string {
devs = append(devs, line)

// If we want to search for related devices
if pArg.FlagCounter["related"] > 0 && !specialRelativeExceptions.MatchString(searchval) {
// Find relatives and add them to the list
related_list := findRelatedDevices(device.Vendor.ID, pArg.FlagCounter["related"], pArg)
devs = append(devs, related_list...)

} else if pArg.FlagCounter["related"] > 0 && specialRelativeExceptions.MatchString(searchval) {
if pArg.FlagCounter["related"] == 1 {
// Prevent an infinite loop by passing 0 instead of related
other := GetDevicesFromGroups([]int{id}, 0, pArg)
devs = append(devs, other...)

} else if pArg.FlagCounter["related"] == 2 {
// Find relatives and add them to the list
related_list := findRelatedDevices(device.Vendor.ID, pArg.FlagCounter["related"], pArg)
devs = append(devs, related_list...)
}

} else if pArg.Flag["rom"] && pArg.Flag["gpu"] {
Expand Down Expand Up @@ -200,15 +200,15 @@ func MatchSubclass(searchval string, pArg *params.Params) []string {
}

// If we want to search for related devices
if pArg.FlagCounter["related"] > 0 && !specialRelativeExceptions.MatchString(searchval) {
// Find relatives and add them to the list
related_list := findRelatedDevices(device.Vendor.ID, pArg.FlagCounter["related"], pArg)
devs = append(devs, related_list...)

} else if pArg.FlagCounter["related"] > 0 && specialRelativeExceptions.MatchString(searchval) {
if pArg.FlagCounter["related"] == 1 {
// Prevent an infinite loop by passing 0 instead of related
other := GetDevicesFromGroups([]int{id}, 0, pArg)
devs = append(devs, other...)

} else if pArg.FlagCounter["related"] == 2 {
// Find relatives and add them to the list
related_list := findRelatedDevices(device.Vendor.ID, pArg.FlagCounter["related"], pArg)
devs = append(devs, related_list...)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/params/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ func NewParams() *Params {

related := parser.FlagCounter("r", "related", &argparse.Options{
Required: false,
Help: "Attempt to list related devices that share Vendor ID or\n\t\t IOMMU Groups (used with -g -u -i and -n), pass -rr if you want to search using both when used with -g -i or -n\n\t\t Note: -rr can be inaccurate or too broad when many devices share Vendor ID",
Help: "Attempt to list related devices that share IOMMU Groups or\n\t\t Vendor ID (used with -g -u -i -s and -n), pass -rr if you want to search using both when used with -g -i -s or -n\n\t\t Note: -rr can be inaccurate or too broad when many devices share Vendor ID",
})

ignore := parser.StringList("R", "ignore", &argparse.Options{
Required: false,
Help: "Ignores passed VendorID (Left part of : in [VendorID:DeviceID]) outside of the selected IOMMU group when doing a --related search, you can use this to ignore unreliable Vendor IDs when doing related searches. (works with -g -i and -n)",
Help: "Ignores passed VendorID (Left part of : in [VendorID:DeviceID]) outside of the selected IOMMU group when doing a --related search, you can use this to ignore unreliable Vendor IDs when doing related searches. (works with -g -i -u -s and -n)",
})

kernelmodules := parser.Flag("k", "kernel", &argparse.Options{
Expand Down

0 comments on commit ffcf6ba

Please sign in to comment.