disk: return the correct ptr from RootPartition

When we iterate over the partitions to find the root partition,
we are getting the partition by value so even if we return a
pointer to that then, it is actually a pointer duplicated object.
Return the pointer to the actual partition object instead.
This commit is contained in:
Christian Kellner 2021-11-09 15:44:29 +00:00 committed by Tom Gundersen
parent c8efc7d282
commit 6333d54091

View file

@ -107,13 +107,13 @@ func (pt PartitionTable) FSTabStageOptionsV2() *osbuild2.FSTabStageOptions {
// a mountpoint) of the partition table. Nil is returned if there's no such
// partition.
func (pt PartitionTable) RootPartition() *Partition {
for _, p := range pt.Partitions {
for idx, p := range pt.Partitions {
if p.Filesystem == nil {
continue
}
if p.Filesystem.Mountpoint == "/" {
return &p
return &pt.Partitions[idx]
}
}