blob: 13a7622e51ea43e86934d3ee8b64028f0972296c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/bin/sh
# Ensure parted preserves bootcode in extended partition.
# Copyright (C) 2009-2010 Free Software Foundation, Inc.
# This program 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 3 of the License, or
# (at your option) any later version.
# This program 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.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
parted --version
fi
: ${srcdir=.}
. $srcdir/t-lib.sh
require_512_byte_sector_size_
dev=loop-file
bootcode_size=446
# Create the test file
dd if=/dev/zero of=$dev bs=1M count=4 || fail=1
# Create msdos label
parted -s $dev mklabel msdos > out 2>&1 || fail=1
compare out /dev/null || fail=1 # Expect no output
# Create extended partition
parted -s $dev mkpart extended 2048s 8191s > out 2>&1 || fail=1
compare out /dev/null || fail=1 # Expect no output
# Create logical partition
parted -s $dev mkpart logical 4096s 8191s > out 2>&1 || fail=1
compare out /dev/null || fail=1 # Expect no output
# Install fake bootcode
printf %0${bootcode_size}d 0 > in || fail=1
dd if=in of=$dev bs=1c seek=1M count=$bootcode_size \
conv=notrunc > /dev/null 2>&1 || fail=1
# Save fake bootcode for later comparison
dd if=$dev of=before bs=1 skip=1M count=$bootcode_size || fail=1
# Do something to the label
parted -s $dev rm 5 > out 2>&1 || fail=1
compare out /dev/null || fail=1 # Expect no output
# Extract the bootcode for comparison
dd if=$dev of=after bs=1 skip=1M count=$bootcode_size || fail=1
# Expect bootcode has not changed
compare before after || fail=1
Exit $fail
|