From: Martin Jungblut Schreiner Date: Mon, 29 Dec 2025 23:46:39 +0000 (-0300) Subject: tests: fdisk: add regression test for missing EBR gap between logical partitions X-Git-Tag: v2.43-devel~141^2~3^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bf3d4aeec708fae7aa30530a1bf42ee1d35366f8;p=thirdparty%2Futil-linux.git tests: fdisk: add regression test for missing EBR gap between logical partitions Add a DOS/MBR test case where the first logical partition starts at 6145 (extended start 2048). In the regressed behaviour fdisk allows the next logical partition to start at prev_end+1, which would place its EBR (start - 2048) inside the previous logical partition. The expected behaviour is to require the next starting sector to be at least prev_end + 2048 + 1 (e.g. 790528 in the testcase). Closes issue #3925. --- diff --git a/tests/expected/fdisk/mbr-logical-ebr-gap b/tests/expected/fdisk/mbr-logical-ebr-gap new file mode 100644 index 0000000000..c25b9be7a8 --- /dev/null +++ b/tests/expected/fdisk/mbr-logical-ebr-gap @@ -0,0 +1,15 @@ + +---layout---------- +Disk : 1 GiB, 1073741824 bytes, 2097152 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / bytes +Disklabel type: dos +Disk identifier: + +Device Boot Start End Sectors Id Type Start-C/H/S End-C/H/S Attrs +1 2048 2097151 2095104 5 Extended 0/32/33 130/138/8 +5 6145 788479 782335 83 Linux 0/97/35 49/20/35 +6 2097151 2097151 1 83 Linux 130/138/8 130/138/8 +------------------- + diff --git a/tests/ts/fdisk/mbr-logical-ebr-gap b/tests/ts/fdisk/mbr-logical-ebr-gap new file mode 100755 index 0000000000..ffc9f96bc3 --- /dev/null +++ b/tests/ts/fdisk/mbr-logical-ebr-gap @@ -0,0 +1,35 @@ +#!/bin/bash +TS_TOPDIR="${0%/*}/../.." +TS_DESC="MBR: default start for logical must reserve EBR gap" +. "$TS_TOPDIR"/functions.sh +ts_init "$*" +ts_check_test_command "$TS_CMD_FDISK" + +# 1GiB image => 2097152 sectors @ 512B +TEST_IMAGE_NAME=$(ts_image_init 1024) + +# key assertion is in the resulting layout: L2 must not start at 788480, +# but at 790528 (= 788480 + 2048), leaving room for the EBR. +echo -e \ +"o +n +e +1 +2048 +2097151 +n +6145 +788479 +n +788480 +2097151 +w +q +" | $TS_CMD_FDISK --noauto-pt "$TEST_IMAGE_NAME" &> /dev/null + +echo -ne "\n---layout----------\n" >> "$TS_OUTPUT" +$TS_CMD_FDISK -x "$TEST_IMAGE_NAME" >> "$TS_OUTPUT" +echo -ne "-------------------\n\n" >> "$TS_OUTPUT" +ts_fdisk_clean "$TEST_IMAGE_NAME" + +ts_finalize