2
# Ensure that printing a GPT partition table does not modify the pMBR.
3
# Much like t0205, but with the addition of a corrupt PTE in primary table,
4
# "parted $device print" would modify $device.
6
# Copyright (C) 2010-2012 Free Software Foundation, Inc.
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
27
dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
28
parted -s $dev mklabel gpt || fail=1
29
parted -s $dev mkpart p1 128s 255s || fail=1
31
parted -m -s $dev u s p || fail=1
33
# Write non-NUL bytes all over the MBR, so we're likely to see any change.
34
# However, be careful to leave the type of the first partition, 0xEE,
35
# as well as the final two magic bytes.
36
printf '%0450d\xee%059d\x55\xaa' 0 0 | dd of=$dev count=1 conv=notrunc || fail=1
38
dd if=$dev of=before count=1 || fail=1
40
orig_byte=$(gpt_corrupt_primary_table_ $dev $ss) || fail=1
42
parted -m -s $dev u s p || fail=1
44
dd if=$dev of=after count=1 || fail=1
46
cmp before after || fail=1