disk: change updatePartitionStartPointOffsets() to use entityPath()
Eventually partition.Payload will be an Entity, so we need to use more generic functions that work on the interfaces. Co-Authored-By: Christian Kellner <christian@kellner.me>
This commit is contained in:
parent
491020f9b8
commit
adfed6e0d7
1 changed files with 9 additions and 7 deletions
|
|
@ -313,9 +313,7 @@ func (pt *PartitionTable) ForEachEntity(cb EntityCallback) error {
|
|||
// Will grow the root partition if there is any empty space.
|
||||
// Returns the updated start point.
|
||||
func (pt *PartitionTable) updatePartitionStartPointOffsets(size uint64) uint64 {
|
||||
|
||||
// always reserve one extra sector for the GPT header
|
||||
|
||||
header := pt.SectorsToBytes(1)
|
||||
footer := uint64(0)
|
||||
|
||||
|
|
@ -324,7 +322,7 @@ func (pt *PartitionTable) updatePartitionStartPointOffsets(size uint64) uint64 {
|
|||
// calculate the space we need for
|
||||
parts := len(pt.Partitions)
|
||||
|
||||
// reserver a minimum of 128 partition entires
|
||||
// reserve a minimum of 128 partition entires
|
||||
if parts < 128 {
|
||||
parts = 128
|
||||
}
|
||||
|
|
@ -338,10 +336,10 @@ func (pt *PartitionTable) updatePartitionStartPointOffsets(size uint64) uint64 {
|
|||
size = pt.AlignUp(size)
|
||||
|
||||
var rootIdx = -1
|
||||
for i := range pt.Partitions {
|
||||
partition := &pt.Partitions[i]
|
||||
if partition.Payload != nil && partition.Payload.Mountpoint == "/" {
|
||||
rootIdx = i
|
||||
for idx := range pt.Partitions {
|
||||
partition := &pt.Partitions[idx]
|
||||
if len(entityPath(partition, "/")) != 0 {
|
||||
rootIdx = idx
|
||||
continue
|
||||
}
|
||||
partition.Start = start
|
||||
|
|
@ -349,6 +347,10 @@ func (pt *PartitionTable) updatePartitionStartPointOffsets(size uint64) uint64 {
|
|||
start += partition.Size
|
||||
}
|
||||
|
||||
if rootIdx < 0 {
|
||||
panic("no root filesystem found; this is a programming error")
|
||||
}
|
||||
|
||||
root := &pt.Partitions[rootIdx]
|
||||
root.Start = start
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue