Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: make sure busybox's fdisk output parsing is not positional, support qemu and fix debug output #1884

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tlaurion
Copy link
Collaborator

@tlaurion tlaurion commented Jan 6, 2025

This is mitigation for #1883

…upport qemu and fix debug output

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
return 0

# Check for partition entries in the fdisk output
if echo "$DISK_DATA" | grep -q "^/dev"; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, this will break on a device directly formatted FAT32 without being partitioned. (That's what I wrote above - in that case, fdisk prints out a partition table but with no partitions. The FAT32 "volume boot record" is essentially the same as a master boot record.)

Instead I'd suggest looking for the heading, then checking if there are any partition lines following it. awk would be a good fit for this.

If you don't beat me to it, I can suggest a solution here after I get through my post-holidays inbox 😁

@tlaurion tlaurion marked this pull request as draft January 6, 2025 16:18
@tlaurion
Copy link
Collaborator Author

tlaurion commented Jan 6, 2025

I couldn't replicate under qemu with resized disk (mbr though)

https://matrix.to/#/!pAlHOfxQNPXOgFGTmo:matrix.org/$SjUpbwplho4wCQWscmHZUjX1tYTqYpoc7OMfkCqMLrs?via=matrix.org&via=nitro.chat&via=envs.net

# fdisk -l
fdisk: device has more than 2^32 sectors, can't use all of them
Disk /dev/vda: 2048 GB, 2199023255040 bytes, 4294967295 sectors
8421504 cylinders, 255 heads, 2 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/vda1 *  4,4,1       1023,254,2        2048    1953791    1951744  953M 83 Linux
/dev/vda2    1023,254,2  1023,254,2    39944190   41940991    1996802  975M  5 Extended
/dev/vda3    1023,254,2  1023,254,2     1953792   39942143   37988352 18.1G 83 Linux
/dev/vda5    1023,254,2  1023,254,2    39944192   41940991    1996800  975M 82 Linux swap

Partition table entries are not in disk order
~ # echo $?
0

Marking this PR as draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants