package devicepath import ( "errors" "fmt" "strconv" "strings" ) const pciRootPrefix string = "PciRoot" type PCIRootDevicePath struct { uid int32 } func (prp *PCIRootDevicePath) Type() DeviceNodeType { return ACPIDevicePath } func (prp *PCIRootDevicePath) SubType() DeviceNodeSubType { return ACPISubType } func (prp *PCIRootDevicePath) Bytes() []byte { return nil } func (prp *PCIRootDevicePath) String() string { return fmt.Sprintf("%s(0x%x)", pciRootPrefix, prp.uid) } func (prp *PCIRootDevicePath) ParseString(raw string) error { if !checkStringFormat(raw, pciRootPrefix, -1) { return ErrMalformedString } args := strings.Split(raw[len(pciRootPrefix)+1:len(raw)-1], ",") if len(args) != 1 { return errors.New("unexpected number of arguments") } if uid, err := strconv.ParseInt(args[0], 0, 32); err != nil { return err } else { prp.uid = int32(uid) } return nil }