make device node list public

This commit is contained in:
Melora Hugues 2023-09-18 14:07:03 +02:00
parent 8ab8ae3c7f
commit 3a210984eb

View file

@ -48,24 +48,24 @@ type DevicePathNode interface {
var ErrPathComplete = errors.New("device path already complete") var ErrPathComplete = errors.New("device path already complete")
type DevicePath struct { type DevicePath struct {
nodes []DevicePathNode Nodes []DevicePathNode
} }
func (dp *DevicePath) complete() bool { func (dp *DevicePath) complete() bool {
return len(dp.nodes) > 0 && dp.nodes[len(dp.nodes)-1].Type() == EndOfHardwareDevicePath return len(dp.Nodes) > 0 && dp.Nodes[len(dp.Nodes)-1].Type() == EndOfHardwareDevicePath
} }
func (dp *DevicePath) PushNode(node DevicePathNode) error { func (dp *DevicePath) PushNode(node DevicePathNode) error {
if dp.complete() { if dp.complete() {
return ErrPathComplete return ErrPathComplete
} }
dp.nodes = append(dp.nodes, node) dp.Nodes = append(dp.Nodes, node)
return nil return nil
} }
func (dp *DevicePath) String() string { func (dp *DevicePath) String() string {
var res []string var res []string
for _, node := range dp.nodes { for _, node := range dp.Nodes {
if node.String() != "" { if node.String() != "" {
res = append(res, node.String()) res = append(res, node.String())
} }