18 lines
344 B
Go
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
|
|
}
|