]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: add new fdisk bsd test
authorKarel Zak <kzak@redhat.com>
Wed, 16 Mar 2016 12:42:08 +0000 (13:42 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 16 Mar 2016 13:01:23 +0000 (14:01 +0100)
New BDS test based on hexdump, this commit provides:

bsd_0_64.BE - generated on ppc64
bsd_0_64.LE - generated on ppc64le
bsd_1_0.LE - generated on x86_64
bsd_1_0.BE - generated on s390

the last missing is Alpha where all is different :-)

Signed-off-by: Karel Zak <kzak@redhat.com>
tests/expected/fdisk/bsd_0_64.BE [new file with mode: 0644]
tests/expected/fdisk/bsd_0_64.LE [new file with mode: 0644]
tests/expected/fdisk/bsd_1_0.BE [new file with mode: 0644]
tests/expected/fdisk/bsd_1_0.LE [new file with mode: 0644]
tests/ts/fdisk/bsd [new file with mode: 0755]

diff --git a/tests/expected/fdisk/bsd_0_64.BE b/tests/expected/fdisk/bsd_0_64.BE
new file mode 100644 (file)
index 0000000..3a79c49
--- /dev/null
@@ -0,0 +1,213 @@
+BSD_LABELSECTOR=0
+BSD_LABELOFFSET=64
+BSD_EXTRA=
+BYTE_ORDER=BE
+
+Initialize empty image
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+Create new DOS partition table
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 00  |................|
+000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+Disk <removed>: 10 MiB, 10485760 bytes, 20480 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+-------------------
+
+Create 1st primary partition
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 00  |!..A............|
+000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+Disk <removed>: 10 MiB, 10485760 bytes, 20480 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1       2048  4095    2048   1M 83 Linux
+-------------------
+
+Create 2st primary partition
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e 83 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+Set 2nd partition type
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e a5 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+Disk <removed>: 10 MiB, 10485760 bytes, 20480 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1       2048  4095    2048   1M 83 Linux
+<removed>2       4096 20479   16384   8M a5 FreeBSD
+-------------------
+
+Create default BSD
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e a5 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00200040  82 56 45 57 00 06 00 00  00 00 00 00 00 00 00 00  |.VEW............|
+00200050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+00200060  00 00 00 00 00 00 00 00  00 00 02 00 00 00 00 3f  |...............?|
+00200070  00 00 00 ff 00 00 00 01  00 00 3e c1 00 00 3e c1  |..........>...>.|
+00200080  00 00 00 00 00 00 00 00  0e 10 00 01 00 00 00 00  |................|
+00200090  00 00 00 00 00 00 00 00  00 00 00 20 00 00 00 00  |........... ....|
+002000a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+002000c0  00 00 00 00 82 56 45 57  62 33 00 04 00 00 20 00  |.....VEWb3.... .|
+002000d0  00 00 20 00 00 00 00 00  00 00 00 00 00 00 00 00  |.. .............|
+002000e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+002000f0  00 00 00 00 00 00 40 00  00 00 10 00 00 00 00 00  |......@.........|
+00200100  00 00 00 00 00 00 3e c1  00 00 00 00 00 00 00 00  |......>.........|
+00200110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+
+Welcome to fdisk <removed>.
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help): Entering nested BSD disklabel.
+
+Command (m for help): Disk <removed>2: 10 MiB, 10485760 bytes, 20480 sectors
+Geometry: 255 heads, 63 sectors/track, 1 cylinders
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: bsd
+
+Slice Start   End Sectors  Size Type     Fsize Bsize Cpg
+c      4096 20479   16384    8M unused       0     0   0
+d         0 16064   16065  7.9M unused       0     0   0
+
+Partition table entries are not in disk order.
+
+Command (m for help): Leaving nested disklabel.
+
+Command (m for help): 
+-------------------
+
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e a5 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00200040  82 56 45 57 00 06 00 00  00 00 00 00 00 00 00 00  |.VEW............|
+00200050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+00200060  00 00 00 00 00 00 00 00  00 00 02 00 00 00 00 3f  |...............?|
+00200070  00 00 00 ff 00 00 00 01  00 00 3e c1 00 00 3e c1  |..........>...>.|
+00200080  00 00 00 00 00 00 00 00  0e 10 00 01 00 00 00 00  |................|
+00200090  00 00 00 00 00 00 00 00  00 00 00 20 00 00 00 00  |........... ....|
+002000a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+002000c0  00 00 00 00 82 56 45 57  7d 32 00 04 00 00 20 00  |.....VEW}2.... .|
+002000d0  00 00 20 00 00 00 08 01  00 00 10 00 00 00 00 00  |.. .............|
+002000e0  07 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+002000f0  00 00 00 00 00 00 40 00  00 00 10 00 00 00 00 00  |......@.........|
+00200100  00 00 00 00 00 00 3e c1  00 00 00 00 00 00 00 00  |......>.........|
+00200110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+
+Welcome to fdisk <removed>.
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help): Entering nested BSD disklabel.
+
+Command (m for help): Disk <removed>2: 10 MiB, 10485760 bytes, 20480 sectors
+Geometry: 255 heads, 63 sectors/track, 1 cylinders
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: bsd
+
+Slice Start   End Sectors  Size Type     Fsize Bsize Cpg
+a      4096  6144    2049    1M 4.2BSD       0     0   0
+c      4096 20479   16384    8M unused       0     0   0
+d         0 16064   16065  7.9M unused       0     0   0
+
+Partition table entries are not in disk order.
+
+Command (m for help): Leaving nested disklabel.
+
+Command (m for help): 
+-------------------
+
+
+
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help): Entering nested BSD disklabel.
+
+Command (m for help): 
+ 0  unused           5  4.1BSD           9  4.4LFS           d  boot           
+ 1  swap             6  Eighth Edition   a  unknown          e  ADOS           
+ 2  Version 6        7  4.2BSD           b  HPFS             f  HFS            
+ 3  Version 7        8  MS-DOS           c  ISO-9660        10  AdvFS          
+ 4  System V       
+
+Command (m for help): 
diff --git a/tests/expected/fdisk/bsd_0_64.LE b/tests/expected/fdisk/bsd_0_64.LE
new file mode 100644 (file)
index 0000000..d673d04
--- /dev/null
@@ -0,0 +1,213 @@
+BSD_LABELSECTOR=0
+BSD_LABELOFFSET=64
+BSD_EXTRA=
+BYTE_ORDER=LE
+
+Initialize empty image
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+Create new DOS partition table
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 00  |................|
+000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+Disk <removed>: 10 MiB, 10485760 bytes, 20480 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+-------------------
+
+Create 1st primary partition
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 00  |!..A............|
+000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+Disk <removed>: 10 MiB, 10485760 bytes, 20480 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1       2048  4095    2048   1M 83 Linux
+-------------------
+
+Create 2st primary partition
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e 83 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+Set 2nd partition type
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e a5 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+Disk <removed>: 10 MiB, 10485760 bytes, 20480 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1       2048  4095    2048   1M 83 Linux
+<removed>2       4096 20479   16384   8M a5 FreeBSD
+-------------------
+
+Create default BSD
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e a5 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00200040  57 45 56 82 06 00 00 00  00 00 00 00 00 00 00 00  |WEV.............|
+00200050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+00200060  00 00 00 00 00 00 00 00  00 02 00 00 3f 00 00 00  |............?...|
+00200070  ff 00 00 00 01 00 00 00  c1 3e 00 00 c1 3e 00 00  |.........>...>..|
+00200080  00 00 00 00 00 00 00 00  10 0e 01 00 00 00 00 00  |................|
+00200090  00 00 00 00 00 00 00 00  20 00 00 00 00 00 00 00  |........ .......|
+002000a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+002000c0  00 00 00 00 57 45 56 82  33 62 04 00 00 20 00 00  |....WEV.3b... ..|
+002000d0  00 20 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |. ..............|
+002000e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+002000f0  00 00 00 00 00 40 00 00  00 10 00 00 00 00 00 00  |.....@..........|
+00200100  00 00 00 00 c1 3e 00 00  00 00 00 00 00 00 00 00  |.....>..........|
+00200110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+
+Welcome to fdisk <removed>.
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help): Entering nested BSD disklabel.
+
+Command (m for help): Disk <removed>2: 10 MiB, 10485760 bytes, 20480 sectors
+Geometry: 255 heads, 63 sectors/track, 1 cylinders
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: bsd
+
+Slice Start   End Sectors  Size Type     Fsize Bsize Cpg
+c      4096 20479   16384    8M unused       0     0   0
+d         0 16064   16065  7.9M unused       0     0   0
+
+Partition table entries are not in disk order.
+
+Command (m for help): Leaving nested disklabel.
+
+Command (m for help): 
+-------------------
+
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e a5 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00200040  57 45 56 82 06 00 00 00  00 00 00 00 00 00 00 00  |WEV.............|
+00200050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+00200060  00 00 00 00 00 00 00 00  00 02 00 00 3f 00 00 00  |............?...|
+00200070  ff 00 00 00 01 00 00 00  c1 3e 00 00 c1 3e 00 00  |.........>...>..|
+00200080  00 00 00 00 00 00 00 00  10 0e 01 00 00 00 00 00  |................|
+00200090  00 00 00 00 00 00 00 00  20 00 00 00 00 00 00 00  |........ .......|
+002000a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+002000c0  00 00 00 00 57 45 56 82  35 7a 04 00 00 20 00 00  |....WEV.5z... ..|
+002000d0  00 20 00 00 01 08 00 00  00 10 00 00 00 00 00 00  |. ..............|
+002000e0  07 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+002000f0  00 00 00 00 00 40 00 00  00 10 00 00 00 00 00 00  |.....@..........|
+00200100  00 00 00 00 c1 3e 00 00  00 00 00 00 00 00 00 00  |.....>..........|
+00200110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+
+Welcome to fdisk <removed>.
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help): Entering nested BSD disklabel.
+
+Command (m for help): Disk <removed>2: 10 MiB, 10485760 bytes, 20480 sectors
+Geometry: 255 heads, 63 sectors/track, 1 cylinders
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: bsd
+
+Slice Start   End Sectors  Size Type     Fsize Bsize Cpg
+a      4096  6144    2049    1M 4.2BSD       0     0   0
+c      4096 20479   16384    8M unused       0     0   0
+d         0 16064   16065  7.9M unused       0     0   0
+
+Partition table entries are not in disk order.
+
+Command (m for help): Leaving nested disklabel.
+
+Command (m for help): 
+-------------------
+
+
+
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help): Entering nested BSD disklabel.
+
+Command (m for help): 
+ 0  unused           5  4.1BSD           9  4.4LFS           d  boot           
+ 1  swap             6  Eighth Edition   a  unknown          e  ADOS           
+ 2  Version 6        7  4.2BSD           b  HPFS             f  HFS            
+ 3  Version 7        8  MS-DOS           c  ISO-9660        10  AdvFS          
+ 4  System V       
+
+Command (m for help): 
diff --git a/tests/expected/fdisk/bsd_1_0.BE b/tests/expected/fdisk/bsd_1_0.BE
new file mode 100644 (file)
index 0000000..2c46abd
--- /dev/null
@@ -0,0 +1,213 @@
+BSD_LABELSECTOR=1
+BSD_LABELOFFSET=0
+BSD_EXTRA=
+BYTE_ORDER=BE
+
+Initialize empty image
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+Create new DOS partition table
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 00  |................|
+000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+Disk <removed>: 10 MiB, 10485760 bytes, 20480 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+-------------------
+
+Create 1st primary partition
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 00  |!..A............|
+000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+Disk <removed>: 10 MiB, 10485760 bytes, 20480 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1       2048  4095    2048   1M 83 Linux
+-------------------
+
+Create 2st primary partition
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e 83 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+Set 2nd partition type
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e a5 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+Disk <removed>: 10 MiB, 10485760 bytes, 20480 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1       2048  4095    2048   1M 83 Linux
+<removed>2       4096 20479   16384   8M a5 FreeBSD
+-------------------
+
+Create default BSD
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e a5 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00200200  82 56 45 57 00 06 00 00  00 00 00 00 00 00 00 00  |.VEW............|
+00200210  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+00200220  00 00 00 00 00 00 00 00  00 00 02 00 00 00 00 3f  |...............?|
+00200230  00 00 00 ff 00 00 00 01  00 00 3e c1 00 00 3e c1  |..........>...>.|
+00200240  00 00 00 00 00 00 00 00  0e 10 00 01 00 00 00 00  |................|
+00200250  00 00 00 00 00 00 00 00  00 00 00 20 00 00 00 00  |........... ....|
+00200260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00200280  00 00 00 00 82 56 45 57  62 33 00 04 00 00 20 00  |.....VEWb3.... .|
+00200290  00 00 20 00 00 00 00 00  00 00 00 00 00 00 00 00  |.. .............|
+002002a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+002002b0  00 00 00 00 00 00 40 00  00 00 10 00 00 00 00 00  |......@.........|
+002002c0  00 00 00 00 00 00 3e c1  00 00 00 00 00 00 00 00  |......>.........|
+002002d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+
+Welcome to fdisk <removed>.
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help): Entering nested BSD disklabel.
+
+Command (m for help): Disk <removed>2: 10 MiB, 10485760 bytes, 20480 sectors
+Geometry: 255 heads, 63 sectors/track, 1 cylinders
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: bsd
+
+Slice Start   End Sectors  Size Type     Fsize Bsize Cpg
+c      4096 20479   16384    8M unused       0     0   0
+d         0 16064   16065  7.9M unused       0     0   0
+
+Partition table entries are not in disk order.
+
+Command (m for help): Leaving nested disklabel.
+
+Command (m for help): 
+-------------------
+
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e a5 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00200200  82 56 45 57 00 06 00 00  00 00 00 00 00 00 00 00  |.VEW............|
+00200210  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+00200220  00 00 00 00 00 00 00 00  00 00 02 00 00 00 00 3f  |...............?|
+00200230  00 00 00 ff 00 00 00 01  00 00 3e c1 00 00 3e c1  |..........>...>.|
+00200240  00 00 00 00 00 00 00 00  0e 10 00 01 00 00 00 00  |................|
+00200250  00 00 00 00 00 00 00 00  00 00 00 20 00 00 00 00  |........... ....|
+00200260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00200280  00 00 00 00 82 56 45 57  7d 32 00 04 00 00 20 00  |.....VEW}2.... .|
+00200290  00 00 20 00 00 00 08 01  00 00 10 00 00 00 00 00  |.. .............|
+002002a0  07 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+002002b0  00 00 00 00 00 00 40 00  00 00 10 00 00 00 00 00  |......@.........|
+002002c0  00 00 00 00 00 00 3e c1  00 00 00 00 00 00 00 00  |......>.........|
+002002d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+
+Welcome to fdisk <removed>.
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help): Entering nested BSD disklabel.
+
+Command (m for help): Disk <removed>2: 10 MiB, 10485760 bytes, 20480 sectors
+Geometry: 255 heads, 63 sectors/track, 1 cylinders
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: bsd
+
+Slice Start   End Sectors  Size Type     Fsize Bsize Cpg
+a      4096  6144    2049    1M 4.2BSD       0     0   0
+c      4096 20479   16384    8M unused       0     0   0
+d         0 16064   16065  7.9M unused       0     0   0
+
+Partition table entries are not in disk order.
+
+Command (m for help): Leaving nested disklabel.
+
+Command (m for help): 
+-------------------
+
+
+
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help): Entering nested BSD disklabel.
+
+Command (m for help): 
+ 0  unused           5  4.1BSD           9  4.4LFS           d  boot           
+ 1  swap             6  Eighth Edition   a  unknown          e  ADOS           
+ 2  Version 6        7  4.2BSD           b  HPFS             f  HFS            
+ 3  Version 7        8  MS-DOS           c  ISO-9660        10  AdvFS          
+ 4  System V       
+
+Command (m for help): 
diff --git a/tests/expected/fdisk/bsd_1_0.LE b/tests/expected/fdisk/bsd_1_0.LE
new file mode 100644 (file)
index 0000000..5f3b838
--- /dev/null
@@ -0,0 +1,213 @@
+BSD_LABELSECTOR=1
+BSD_LABELOFFSET=0
+BSD_EXTRA=
+BYTE_ORDER=LE
+
+Initialize empty image
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+Create new DOS partition table
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 00  |................|
+000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+Disk <removed>: 10 MiB, 10485760 bytes, 20480 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+-------------------
+
+Create 1st primary partition
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 00  |!..A............|
+000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+Disk <removed>: 10 MiB, 10485760 bytes, 20480 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1       2048  4095    2048   1M 83 Linux
+-------------------
+
+Create 2st primary partition
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e 83 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+Set 2nd partition type
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e a5 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+Disk <removed>: 10 MiB, 10485760 bytes, 20480 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1       2048  4095    2048   1M 83 Linux
+<removed>2       4096 20479   16384   8M a5 FreeBSD
+-------------------
+
+Create default BSD
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e a5 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00200200  57 45 56 82 06 00 00 00  00 00 00 00 00 00 00 00  |WEV.............|
+00200210  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+00200220  00 00 00 00 00 00 00 00  00 02 00 00 3f 00 00 00  |............?...|
+00200230  ff 00 00 00 01 00 00 00  c1 3e 00 00 c1 3e 00 00  |.........>...>..|
+00200240  00 00 00 00 00 00 00 00  10 0e 01 00 00 00 00 00  |................|
+00200250  00 00 00 00 00 00 00 00  20 00 00 00 00 00 00 00  |........ .......|
+00200260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00200280  00 00 00 00 57 45 56 82  33 62 04 00 00 20 00 00  |....WEV.3b... ..|
+00200290  00 20 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |. ..............|
+002002a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+002002b0  00 00 00 00 00 40 00 00  00 10 00 00 00 00 00 00  |.....@..........|
+002002c0  00 00 00 00 c1 3e 00 00  00 00 00 00 00 00 00 00  |.....>..........|
+002002d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+
+Welcome to fdisk <removed>.
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help): Entering nested BSD disklabel.
+
+Command (m for help): Disk <removed>2: 10 MiB, 10485760 bytes, 20480 sectors
+Geometry: 255 heads, 63 sectors/track, 1 cylinders
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: bsd
+
+Slice Start   End Sectors  Size Type     Fsize Bsize Cpg
+c      4096 20479   16384    8M unused       0     0   0
+d         0 16064   16065  7.9M unused       0     0   0
+
+Partition table entries are not in disk order.
+
+Command (m for help): Leaving nested disklabel.
+
+Command (m for help): 
+-------------------
+
+00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+000001b0  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 20  |............... |
+000001c0  21 00 83 41 01 00 00 08  00 00 00 08 00 00 00 04  |!..A............|
+000001d0  01 3e a5 13 41 36 00 10  00 00 00 40 00 00 00 00  |.>..A6.....@....|
+000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
+00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00200200  57 45 56 82 06 00 00 00  00 00 00 00 00 00 00 00  |WEV.............|
+00200210  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+00200220  00 00 00 00 00 00 00 00  00 02 00 00 3f 00 00 00  |............?...|
+00200230  ff 00 00 00 01 00 00 00  c1 3e 00 00 c1 3e 00 00  |.........>...>..|
+00200240  00 00 00 00 00 00 00 00  10 0e 01 00 00 00 00 00  |................|
+00200250  00 00 00 00 00 00 00 00  20 00 00 00 00 00 00 00  |........ .......|
+00200260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00200280  00 00 00 00 57 45 56 82  35 7a 04 00 00 20 00 00  |....WEV.5z... ..|
+00200290  00 20 00 00 01 08 00 00  00 10 00 00 00 00 00 00  |. ..............|
+002002a0  07 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+002002b0  00 00 00 00 00 40 00 00  00 10 00 00 00 00 00 00  |.....@..........|
+002002c0  00 00 00 00 c1 3e 00 00  00 00 00 00 00 00 00 00  |.....>..........|
+002002d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00a00000
+
+---layout----------
+
+Welcome to fdisk <removed>.
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help): Entering nested BSD disklabel.
+
+Command (m for help): Disk <removed>2: 10 MiB, 10485760 bytes, 20480 sectors
+Geometry: 255 heads, 63 sectors/track, 1 cylinders
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
+Disklabel type: bsd
+
+Slice Start   End Sectors  Size Type     Fsize Bsize Cpg
+a      4096  6144    2049    1M 4.2BSD       0     0   0
+c      4096 20479   16384    8M unused       0     0   0
+d         0 16064   16065  7.9M unused       0     0   0
+
+Partition table entries are not in disk order.
+
+Command (m for help): Leaving nested disklabel.
+
+Command (m for help): 
+-------------------
+
+
+
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help): Entering nested BSD disklabel.
+
+Command (m for help): 
+ 0  unused           5  4.1BSD           9  4.4LFS           d  boot           
+ 1  swap             6  Eighth Edition   a  unknown          e  ADOS           
+ 2  Version 6        7  4.2BSD           b  HPFS             f  HFS            
+ 3  Version 7        8  MS-DOS           c  ISO-9660        10  AdvFS          
+ 4  System V       
+
+Command (m for help): 
diff --git a/tests/ts/fdisk/bsd b/tests/ts/fdisk/bsd
new file mode 100755 (executable)
index 0000000..8d2e762
--- /dev/null
@@ -0,0 +1,140 @@
+#!/bin/bash
+#
+# This file is part of util-linux.
+#
+# Copyright (C) 2013 Karel Zak <kzak@redhat.com>
+#
+# 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="nested BSD (new)"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_FDISK"
+ts_check_test_command "$TS_HELPER_SYSINFO"
+
+FDISK_CMD_CREATE_DOSLABEL="o\n"              # create dos label
+FDISK_CMD_SETID="x\ni\n0x1\nr\n"             # set non-random ID
+FDISK_CMD_WRITE_CLOSE="w\nq\n"               # write to image
+FDISK_CMD_CREATE_PRIMARY1="n\np\n1\n\n+1M\n" # 1st primary partition of size 1MiB
+FDISK_CMD_CREATE_PRIMARY2="n\np\n2\n\n\n"    # 2nd primary partition for whole of the disk
+FDISK_CMD_CHANGE_PART2TYPE="t\n2\na5\n"      # change partition type FreeBSD
+
+FDISK_CMD_BSD_CREATE="b\ny\n"                # create nested BSD PT
+FDISK_CMD_BSD_LIST="b\np\nr\nq\n"            # list nested BSD PT and quit
+FDISK_CMD_BSD_CREATE_PART="b\nn\na\n\n+1M\n" # add BSD partition 'a', size 1MiB
+FDISK_CMD_BSD_PARTTYPE="b\nt\na\n7\n"        # set partition 'a' to type 4.2BSD
+FDISK_CMD_BSD_LIST_TYPES="b\nl\nq\n"         # list supported PT types and quit
+
+#set -x
+
+# BSD disklabel depends on endianness
+BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order)
+
+# and also on arch-specific offset (see include/pt-bsd.h)
+ARCH=$(uname -m)
+case $ARCH in
+       *ppc* | *alpha* | *ia64*) 
+               BSD_LABELSECTOR=0
+               BSD_LABELOFFSET=64 
+               ;;
+       *)
+               BSD_LABELSECTOR=1
+               BSD_LABELOFFSET=0
+               ;;
+esac
+
+# and contains extra options for alpha
+BSD_EXTRA=""
+case $ARCH in
+       *alpha*)
+               BSD_EXTRA="_alpha"
+               ;;
+esac
+
+echo "BSD_LABELSECTOR=$BSD_LABELSECTOR" >> $TS_OUTPUT
+echo "BSD_LABELOFFSET=$BSD_LABELOFFSET" >> $TS_OUTPUT
+echo "BSD_EXTRA=$BSD_EXTRA" >> $TS_OUTPUT
+echo "BYTE_ORDER=$BYTE_ORDER" >> $TS_OUTPUT
+echo >> $TS_OUTPUT
+
+TS_EXPECTED+="_${BSD_LABELSECTOR}_${BSD_LABELOFFSET}${BSD_EXTRA}.${BYTE_ORDER}"
+#echo $TS_EXPECTED
+
+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
+}
+
+function print_bsd_layout {
+       echo -ne "\n---layout----------\n" >> $TS_OUTPUT
+       echo -e "${FDISK_CMD_BSD_LIST}" | \
+                       $TS_CMD_FDISK ${TEST_IMAGE_NAME} >> $TS_OUTPUT
+       echo -ne   "-------------------\n\n" >> $TS_OUTPUT
+}
+
+ts_log "Initialize empty image"
+TEST_IMAGE_NAME=$(ts_image_init 10)
+$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1
+
+ts_log "Create new DOS partition table"
+echo -e "${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_SETID}${FDISK_CMD_WRITE_CLOSE}" \
+        | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Create 1st primary partition"
+echo -e "${FDISK_CMD_CREATE_PRIMARY1}${FDISK_CMD_WRITE_CLOSE}" | \
+       $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Create 2st primary partition"
+echo -e "${FDISK_CMD_CREATE_PRIMARY2}${FDISK_CMD_WRITE_CLOSE}" | \
+       $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1
+
+ts_log "Set 2nd partition type"
+echo -e "${FDISK_CMD_CHANGE_PART2TYPE}${FDISK_CMD_WRITE_CLOSE}" | \
+       $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Create default BSD"
+echo -e "${FDISK_CMD_BSD_CREATE}${FDISK_CMD_WRITE_CLOSE}" | \
+       $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1
+
+print_bsd_layout
+
+echo -e "${FDISK_CMD_BSD_CREATE_PART}${FDISK_CMD_WRITE_CLOSE}" | \
+       $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+
+echo -e "${FDISK_CMD_BSD_PARTTYPE}${FDISK_CMD_WRITE_CLOSE}" | \
+       $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+$TS_CMD_HEXDUMP -C ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1
+
+print_bsd_layout
+
+echo -e "${FDISK_CMD_BSD_LIST_TYPES}" | \
+       $TS_CMD_FDISK ${TEST_IMAGE_NAME} | \
+       sed 's/Reading .*//g; s/Welcome to fdisk .*//' >> $TS_OUTPUT 2>&1
+
+ts_fdisk_clean ${TEST_IMAGE_NAME}
+ts_finalize