Repository navigation
capture: look up partitions by exact name in movePartition() - #190
Merged
Merged
Conversation
movePartition() found each partition in the sfdisk dump with a substring grep. Debian and Ubuntu cloud images carry sda1, sda14 and sda15, so `grep /dev/sda1` returned three lines. The start and size went multi-line, calculate() failed, and the empty result read as 0. FOS then tried to move sda14 to sector 0, the capture aborted, and the source disk stayed shrunk. Match the first field of the dump exactly with awk. With the fix, the Debian layout moves nothing, because sda14 and sda15 sit before sda1. tests/checks/move-partition.sh runs movePartition() over two real `sfdisk -d` dumps. On the old code it fails with the reporter's awk error. Fixes #189 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #189.
Problem
A resizable capture of a Debian or Ubuntu cloud image fails at "Moving Partitions". The source disk stays shrunk.
Cause
movePartition()finds each partition in thesfdisk -ddump with a substringgrep. The disk carriessda1,sda14andsda15, sogrep /dev/sda1returns three lines.calculate()gets a multi-line expression and fails. The empty result reads as 0, so FOS tries to movesda14to sector 0.Fix
Match the first field of the dump exactly:
awk -v p="$part" '$1 == p'. An exact field match has no regex characters to escape. The reporter's proposedgrep -E "^${part}[[:space:]]"gives the same result.Test
tests/checks/move-partition.shrunsmovePartition()infog.upload's order over two realsfdisk -ddumps:sda14,sda15beforesda1): no move, no error.sda1shrunk, thensda10,sda11:sda10moves to sector 1050624, the end ofsda1. Nothing else moves.On the old code both cases fail with the reporter's error (
awk: … unexpected newline or end of string). All other harnesses pass, and the golden output is byte-identical.The reporter tested the same change on 1.5.10.2482 with init
20261005. The capture completed, and the image deployed onto a smaller disk.🤖 Generated with Claude Code