~youscribe/parted/3.1

« back to all changes in this revision

Viewing changes to tests/t0206-gpt-print-with-corrupt-primary-clobbers-pmbr.sh

  • Committer: Guilhem Lettron
  • Date: 2012-10-22 14:37:59 UTC
  • Revision ID: guilhem+ubuntu@lettron.fr-20121022143759-m403kecgz13sknvp
3.1 from tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
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.
 
5
 
 
6
# Copyright (C) 2010-2012 Free Software Foundation, Inc.
 
7
 
 
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.
 
12
 
 
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.
 
17
 
 
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/>.
 
20
 
 
21
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
 
22
 
 
23
ss=$sector_size_
 
24
n_sectors=400
 
25
dev=dev-file
 
26
 
 
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
 
30
 
 
31
parted -m -s $dev u s p                        || fail=1
 
32
 
 
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
 
37
 
 
38
dd if=$dev of=before count=1 || fail=1
 
39
 
 
40
orig_byte=$(gpt_corrupt_primary_table_ $dev $ss) || fail=1
 
41
 
 
42
parted -m -s $dev u s p || fail=1
 
43
 
 
44
dd if=$dev of=after count=1 || fail=1
 
45
 
 
46
cmp before after || fail=1
 
47
 
 
48
Exit $fail