24 lines
485 B
Go
24 lines
485 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
func (i *iface) ProcPCI(devpath string) (seg 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
|
|
}
|
|
var name strings.Builder
|
|
if domain != 0 {
|
|
name.WriteString(fmt.Sprintf("P%d", domain))
|
|
}
|
|
name.WriteString(fmt.Sprintf("p%ds%df%d", bus, device, function))
|
|
seg = name.String()
|
|
return
|
|
}
|