From 30ff6afe596eddafacf22b1a5b2d1a3d6254ea15 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 15:14:44 +0200 Subject: Adding upstream version 2.36.1. Signed-off-by: Daniel Baumann --- tests/ts/fdisk/mbr-sort | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 tests/ts/fdisk/mbr-sort (limited to 'tests/ts/fdisk/mbr-sort') diff --git a/tests/ts/fdisk/mbr-sort b/tests/ts/fdisk/mbr-sort new file mode 100755 index 0000000..8ae51bf --- /dev/null +++ b/tests/ts/fdisk/mbr-sort @@ -0,0 +1,79 @@ +#!/bin/bash + +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="MBR - sort" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" + +# cmd to changes system id to 0x1 +FDISK_CMD_WRITE_CLOSE="w\nq\n" +FDISK_CMD_CREATE_DOSLABEL="o\n" #create dos label + +FDISK_CMD_CREATE_1PRIMARY="n\np\n1\n4096\n6143\n" +FDISK_CMD_CREATE_2PRIMARY="n\np\n2\n2048\n4095\n" +FDISK_CMD_CREATE_3PRIMARY="n\np\n3\n6144\n8191\n" +FDISK_CMD_CREATE_EXTENDED="n\ne\n\n\n" + +FDISK_CMD_CREATE_1LOGICAL="n\n14336\n16383\n" +FDISK_CMD_CREATE_2LOGICAL="n\n22528\n24575\n" +FDISK_CMD_CREATE_3LOGICAL="n\n18432\n20479\n" +FDISK_CMD_CREATE_4LOGICAL="n\n10240\n12287\n" + +FDISK_CMD_EXPERT_SORT="x\nf\nr\n" + +function print_layout { + echo -ne "\n---layout----------\n" >> $TS_OUTPUT + $TS_CMD_FDISK -l ${TEST_IMAGE_NAME} >> $TS_OUTPUT + echo -ne "-------------------\n\n" >> $TS_OUTPUT +} + +#set -x + +ts_log "Initialize empty image" +TEST_IMAGE_NAME=$(ts_image_init 20) # 20 MiB + +ts_log "Create new DOS partition table" +echo -e "${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK --noauto-pt ${TEST_IMAGE_NAME} &> /dev/null + +print_layout + +ts_log "Create primary partitions" +echo -e "${FDISK_CMD_CREATE_1PRIMARY}${FDISK_CMD_CREATE_2PRIMARY}${FDISK_CMD_CREATE_3PRIMARY}${FDISK_CMD_CREATE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout + + +ts_log "Create logical partitions" +echo -e "${FDISK_CMD_CREATE_1LOGICAL}${FDISK_CMD_CREATE_2LOGICAL}${FDISK_CMD_CREATE_3LOGICAL}${FDISK_CMD_CREATE_4LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout + + +ts_log "Fix order." +echo -e "${FDISK_CMD_EXPERT_SORT}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout + +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize -- cgit v1.2.3