net-predictable/pci.go
2024-06-14 21:26:46 +00:00

18 lines
344 B
Go

package main
import (
"fmt"
)
func ProcPCI(devpath string) (segment string, err error) {
var (
domain, bus, device, function int
)
if _, err = fmt.Sscanf(devpath, "%x:%x:%x.%x", &domain, &bus, &device, &function); err != nil {
err = ErrInvalidPCIFormat
return
}
segment = fmt.Sprintf("p%ds%df%d", bus, device, function)
return
}