diff options
author | Jim Meyering <meyering@redhat.com> | 2011-11-05 20:49:18 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2011-11-05 20:55:51 +0100 |
commit | 723ca1f12f13ae108eba611d72de26591e1214ba (patch) | |
tree | 7b73887f7883717bfe5378b5fdbc4667e393ffd4 | |
parent | 6bc7e1965078579e9855f851254d67b3d8165784 (diff) | |
download | parted-723ca1f12f13ae108eba611d72de26591e1214ba.tar.gz |
tests: exercise and document the HFS-probe bug fix
Simply zeroing out the total_blocks and block_size members of the
on-disk _HfsMasterDirectoryBlock would provoke a failed assertion
any time parted tried to probe that partition.
* tests/t2500-probe-corrupt-hfs.sh: New script.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Bug fixes): Mention this.
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rwxr-xr-x | tests/t2500-probe-corrupt-hfs.sh | 41 |
4 files changed, 47 insertions, 1 deletions
@@ -36,9 +36,9 @@ libparted.pc libparted/tests/disk libparted/tests/init.sh libparted/tests/label +libparted/tests/symlink libparted/tests/t*.sh.log libparted/tests/test-suite.log -libparted/tests/symlink libparted/tests/zerolen libtool m4 @@ -34,6 +34,10 @@ GNU parted NEWS -*- outline -*- cause an MSDOS partition table to be mistakenly identified as pc98. [bug present since the beginning] + libparted no longer gets a failed assertion when probing a partition + with an HFS or HFS+ signature, but with invalid ->total_blocks and/or + ->block_size values. + ** Changes in behavior parted: mkpart command has changed semantics with regard to specifying end diff --git a/tests/Makefile.am b/tests/Makefile.am index 71787e5..5bc513d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -35,6 +35,7 @@ TESTS = \ t2300-dos-label-extended-bootcode.sh \ t2310-dos-extended-2-sector-min-offset.sh \ t2400-dos-hfs-partition-type.sh \ + t2500-probe-corrupt-hfs.sh \ t3200-type-change.sh \ t3300-palo-prep.sh \ t3310-flags.sh \ diff --git a/tests/t2500-probe-corrupt-hfs.sh b/tests/t2500-probe-corrupt-hfs.sh new file mode 100755 index 0000000..435af9f --- /dev/null +++ b/tests/t2500-probe-corrupt-hfs.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Do not misbehave when probing a corrupt HFS partition. + +# Copyright (C) 2011 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/>. + +. "${srcdir=.}/init.sh"; path_prepend_ ../parted +ss=$sector_size_ + +N=3M +dev=loop-file +# create a file large enough to hold a GPT partition table +dd if=/dev/null of=$dev bs=1 seek=$N || framework_failure + +parted -s "$dev" mklabel gpt mkpart p1 1MiB 2MiB > out 2>&1 || fail=1 +compare out /dev/null || fail=1 + +parted -s "$dev" u s p || fail=1 + +# Poke an HFS+ signature into place +printf '\x48\x2b' | dd of=$dev seek=$((2048+2)) conv=notrunc || fail=1 + +# Or, if starting from a valid HFS/HFS+ file system, poke these: +# offset 18 total_blocks=0(16b) +# offset 20 vh->block_size=0(32b) + +parted -s "$dev" u s p || fail=1 + +Exit $fail |