summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/expected/fdisk/mbr-nondos-mode195
-rwxr-xr-xtests/ts/fdisk/mbr-nondos-mode135
2 files changed, 330 insertions, 0 deletions
diff --git a/tests/expected/fdisk/mbr-nondos-mode b/tests/expected/fdisk/mbr-nondos-mode
new file mode 100644
index 000000000..088ce67bc
--- /dev/null
+++ b/tests/expected/fdisk/mbr-nondos-mode
@@ -0,0 +1,195 @@
+Initialize empty image
+8f4e33f3dc3e414ff94e5fb6905cba8c mbr-nondos-mode.img
+Create new DOS partition table
+4e23561dcb81678bb1bd678722c7cbb7 mbr-nondos-mode.img
+
+---layout----------
+__ts_dev__: 20 MB, 20971520 bytes, 40960 sectors
+Units = sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+-------------------
+
+Create 1st primary partition
+e21e16b7452d82e2a2810a1de8c3db05 mbr-nondos-mode.img
+
+---layout----------
+__ts_dev__: 20 MB, 20971520 bytes, 40960 sectors
+Units = sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+__ts_dev__1 2048 8191 3072 83 Linux
+-------------------
+
+Set primary partition active
+47f024f3b406598a0159400af7382e2c mbr-nondos-mode.img
+
+---layout----------
+__ts_dev__: 20 MB, 20971520 bytes, 40960 sectors
+Units = sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+__ts_dev__1 * 2048 8191 3072 83 Linux
+-------------------
+
+Re-create 1st primary partition
+a5543ee1e3d2cf79913a56bae893a0f0 mbr-nondos-mode.img
+
+---layout----------
+__ts_dev__: 20 MB, 20971520 bytes, 40960 sectors
+Units = sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+__ts_dev__1 2048 8191 3072 83 Linux
+-------------------
+
+Create 2nd primary partition
+9d31ee977e26e72ebce78e8e543cd4ce mbr-nondos-mode.img
+
+---layout----------
+__ts_dev__: 20 MB, 20971520 bytes, 40960 sectors
+Units = sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+__ts_dev__1 2048 8191 3072 83 Linux
+__ts_dev__2 8192 12287 2048 83 Linux
+-------------------
+
+Create extended partition
+9528631b198e44564f67f8ca97fa51b8 mbr-nondos-mode.img
+
+---layout----------
+__ts_dev__: 20 MB, 20971520 bytes, 40960 sectors
+Units = sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+__ts_dev__1 2048 8191 3072 83 Linux
+__ts_dev__2 8192 12287 2048 83 Linux
+__ts_dev__3 12288 40959 14336 5 Extended
+-------------------
+
+Create logical partitions
+db4406e7bc0773f234fd1db1b58b5997 mbr-nondos-mode.img
+
+---layout----------
+__ts_dev__: 20 MB, 20971520 bytes, 40960 sectors
+Units = sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+__ts_dev__1 2048 8191 3072 83 Linux
+__ts_dev__2 8192 12287 2048 83 Linux
+__ts_dev__3 12288 40959 14336 5 Extended
+__ts_dev__5 14336 18431 2048 83 Linux
+__ts_dev__6 20480 24575 2048 83 Linux
+__ts_dev__7 26624 30719 2048 83 Linux
+__ts_dev__8 32768 36863 2048 83 Linux
+-------------------
+
+Delete logical partitions
+de85b8d74f52f307b9467ea4c33438cb mbr-nondos-mode.img
+
+---layout----------
+__ts_dev__: 20 MB, 20971520 bytes, 40960 sectors
+Units = sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+__ts_dev__1 2048 8191 3072 83 Linux
+__ts_dev__2 8192 12287 2048 83 Linux
+__ts_dev__3 12288 40959 14336 5 Extended
+__ts_dev__5 26624 30719 2048 83 Linux
+-------------------
+
+Create another logical partition
+28d0cbe795535ee025dc7a4781516965 mbr-nondos-mode.img
+
+---layout----------
+__ts_dev__: 20 MB, 20971520 bytes, 40960 sectors
+Units = sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+__ts_dev__1 2048 8191 3072 83 Linux
+__ts_dev__2 8192 12287 2048 83 Linux
+__ts_dev__3 12288 40959 14336 5 Extended
+__ts_dev__5 26624 30719 2048 83 Linux
+__ts_dev__6 14336 18431 2048 83 Linux
+
+Partition table entries are not in disk order
+-------------------
+
+Delete primary partition
+6f1b62718cf8d83602d51de8944cee51 mbr-nondos-mode.img
+
+---layout----------
+__ts_dev__: 20 MB, 20971520 bytes, 40960 sectors
+Units = sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+__ts_dev__2 8192 12287 2048 83 Linux
+__ts_dev__3 12288 40959 14336 5 Extended
+__ts_dev__5 26624 30719 2048 83 Linux
+__ts_dev__6 14336 18431 2048 83 Linux
+
+Partition table entries are not in disk order
+-------------------
+
+Delete primary partition
+7b29a3cda33e990e8a7877b81988b933 mbr-nondos-mode.img
+
+---layout----------
+__ts_dev__: 20 MB, 20971520 bytes, 40960 sectors
+Units = sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+__ts_dev__3 12288 40959 14336 5 Extended
+__ts_dev__5 26624 30719 2048 83 Linux
+__ts_dev__6 14336 18431 2048 83 Linux
+
+Partition table entries are not in disk order
+-------------------
+
+Delete extended partition
+e1ef48d3d42f4ebcfd5bf4baf5e370e9 mbr-nondos-mode.img
+
+---layout----------
+__ts_dev__: 20 MB, 20971520 bytes, 40960 sectors
+Units = sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+-------------------
+
diff --git a/tests/ts/fdisk/mbr-nondos-mode b/tests/ts/fdisk/mbr-nondos-mode
new file mode 100755
index 000000000..9999f1a5d
--- /dev/null
+++ b/tests/ts/fdisk/mbr-nondos-mode
@@ -0,0 +1,135 @@
+#!/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="$(dirname $0)/../.."
+TS_DESC="MBR - non-dos mode"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+# cmd to changes system id to 0x1
+FDISK_CMD_INIT="x\ni\n0x1\nr\n"
+FDISK_CMD_WRITE_CLOSE="w\nq\n"
+FDISK_CMD_CREATE_DOSLABEL="o\n" #create dos label
+FDISK_CMD_CREATE_1PRIMARY="n\np\n\n\n+3M\n" # create primary partition of size 3MiB
+FDISK_CMD_CREATE_2PRIMARY="n\np\n\n\n+2M\n" # create primary partition of size 2MiB
+FDISK_CMD_SET_ACTIVE="a\n1\n" # set first partition active
+FDISK_CMD_CREATE_EXTENDED="n\ne\n\n\n\n" # create extended partition
+FDISK_CMD_CREATE_LOGICAL="n\nl\n\n+2M\n" # create next logical partition of size 10 sectors
+FDISK_CMD_DELETE_LOGICALS="d\n6\nd\n5\nd\n6\d5\n" # delete middle, head, tail, last partitions
+FDISK_CMD_DELETE_1PRIMARY="d\n1\n" # delete first primary
+FDISK_CMD_DELETE_2PRIMARY="d\n2\n" # delete first primary
+FDISK_CMD_DELETE_EXTENDED="d\n3\n" # delete second primary
+
+function print_layout {
+ echo -ne "\n---layout----------" >> $TS_OUTPUT
+ $TS_CMD_FDISK -l ${TEST_IMAGE_NAME} | sed 's/^.*\.img/__ts_dev__/g' >> $TS_OUTPUT 2>&1
+ echo -ne "-------------------\n\n" >> $TS_OUTPUT
+}
+
+#set -x
+
+ts_log "Initialize empty image"
+TEST_IMAGE_NAME=$(ts_image_init 20) # 20 MiB
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+# need to run init twice, to change system ID after new label, otherwise system
+# ID will be random and will screw up md5's
+ts_log "Create new DOS partition table"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_INIT}${FDISK_CMD_WRITE_CLOSE}" \
+ | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Create 1st primary partition"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_CREATE_1PRIMARY}${FDISK_CMD_WRITE_CLOSE}" | \
+ $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Set primary partition active"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_SET_ACTIVE}${FDISK_CMD_WRITE_CLOSE}" | \
+ $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Re-create 1st primary partition"
+echo -e "${FDISK_CMD_INIT}d\n${FDISK_CMD_CREATE_1PRIMARY}${FDISK_CMD_WRITE_CLOSE}" | \
+ $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Create 2nd primary partition"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_CREATE_2PRIMARY}${FDISK_CMD_WRITE_CLOSE}" | \
+ $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Create extended partition"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_CREATE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" | \
+ $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Create logical partitions"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \
+ | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Delete logical partitions"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_DELETE_LOGICALS}${FDISK_CMD_WRITE_CLOSE}" \
+ | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Create another logical partition"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \
+ | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Delete primary partition"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_DELETE_1PRIMARY}${FDISK_CMD_WRITE_CLOSE}" \
+ | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Delete primary partition"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_DELETE_2PRIMARY}${FDISK_CMD_WRITE_CLOSE}" \
+ | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Delete extended partition"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_DELETE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" \
+ | $TS_CMD_FDISK -c=dos -u=cylinders ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_finalize