-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to print the path to the GPU vbios
- Loading branch information
1 parent
9323125
commit 5c28797
Showing
3 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package iommu | ||
|
||
import ( | ||
"fmt" | ||
"io/fs" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/HikariKnight/ls-iommu/lib/params" | ||
"github.com/jaypipes/ghw/pkg/pci" | ||
) | ||
|
||
// Function to get the vbios path for a device | ||
func GetRomPath(device *pci.Device, pArg *params.Params) []string { | ||
// Make a string slice to contain our paths | ||
var roms []string | ||
|
||
// Walk through /sys/devices/ and add all paths that has a rom file and matches the device.Address to the roms variable | ||
err := filepath.Walk("/sys/devices/", func(path string, info fs.FileInfo, err error) error { | ||
ErrorCheck(err) | ||
|
||
// If the file name is "rom" and the path contains the PCI address for our device | ||
if info.Name() == "rom" && strings.Contains(path, device.Address) { | ||
// Add the filepath to our roms variable | ||
roms = append(roms, fmt.Sprintf("%s\n", path)) | ||
} | ||
return nil | ||
}) | ||
ErrorCheck(err) | ||
|
||
// Return all found rom files | ||
return roms | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters