2
# Ensure parted preserves bootcode in extended partition.
4
# Copyright (C) 2009-2012 Free Software Foundation, Inc.
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
21
require_512_byte_sector_size_
26
# Create the test file
27
dd if=/dev/zero of=$dev bs=1M count=4 || fail=1
30
parted -s $dev mklabel msdos > out 2>&1 || fail=1
31
compare /dev/null out || fail=1 # Expect no output
33
# Create extended partition
34
parted -s $dev mkpart extended 2048s 8191s > out 2>&1 || fail=1
35
compare /dev/null out || fail=1 # Expect no output
37
# Create logical partition
38
parted -s $dev mkpart logical 4096s 8191s > out 2>&1 || fail=1
39
compare /dev/null out || fail=1 # Expect no output
41
# Install fake bootcode
42
printf %0${bootcode_size}d 0 > in || fail=1
43
dd if=in of=$dev bs=1c seek=1M count=$bootcode_size \
44
conv=notrunc > /dev/null 2>&1 || fail=1
46
# Save fake bootcode for later comparison
47
dd if=$dev of=before bs=1 skip=1M count=$bootcode_size || fail=1
49
# Do something to the label
50
parted -s $dev rm 5 > out 2>&1 || fail=1
51
compare /dev/null out || fail=1 # Expect no output
53
# Extract the bootcode for comparison
54
dd if=$dev of=after bs=1 skip=1M count=$bootcode_size || fail=1
56
# Expect bootcode has not changed
57
compare before after || fail=1