diff --git a/internal/statemachine/state_machine.go b/internal/statemachine/state_machine.go index 8dbdd5cc..d751e2f9 100644 --- a/internal/statemachine/state_machine.go +++ b/internal/statemachine/state_machine.go @@ -226,6 +226,7 @@ func (stateMachine *StateMachine) postProcessGadgetYaml() error { var rootfsSeen bool = false var farthestOffset quantity.Offset = 0 var lastOffset quantity.Offset = 0 + farthestOffsetUnknown := false var lastVolumeName string for _, volumeName := range stateMachine.VolumeOrder { volume := stateMachine.GadgetInfo.Volumes[volumeName] @@ -283,10 +284,14 @@ func (stateMachine *StateMachine) postProcessGadgetYaml() error { } // update farthestOffset if needed - offset := *structure.Offset - lastOffset = offset + quantity.Offset(structure.Size) - farthestOffset = maxOffset(lastOffset, farthestOffset) - structure.Offset = &offset + if structure.Offset == nil { + farthestOffsetUnknown = true + } else { + offset := *structure.Offset + lastOffset = offset + quantity.Offset(structure.Size) + farthestOffset = maxOffset(lastOffset, farthestOffset) + structure.Offset = &offset + } // system-data and system-seed do not always have content defined. // this makes Content be a nil slice and lead copyStructureContent() skip the rootfs copying later. @@ -301,7 +306,7 @@ func (stateMachine *StateMachine) postProcessGadgetYaml() error { } } - if !rootfsSeen && len(stateMachine.GadgetInfo.Volumes) == 1 { + if !farthestOffsetUnknown && !rootfsSeen && len(stateMachine.GadgetInfo.Volumes) == 1 { // We still need to handle the case of unspecified system-data // partition where we simply attach the rootfs at the end of the // partition list.