OSDN Git Service

tests: exercise and document the HFS-probe bug fix
authorJim Meyering <meyering@redhat.com>
Sat, 5 Nov 2011 19:49:18 +0000 (20:49 +0100)
committerJim Meyering <meyering@redhat.com>
Sat, 5 Nov 2011 19:55:51 +0000 (20:55 +0100)
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.

.gitignore
NEWS
tests/Makefile.am
tests/t2500-probe-corrupt-hfs.sh [new file with mode: 0755]

index 5937e5b..98005db 100644 (file)
@@ -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
diff --git a/NEWS b/NEWS
index c6e22f0..43b73f1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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
index 71787e5..5bc513d 100644 (file)
@@ -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 (executable)
index 0000000..435af9f
--- /dev/null
@@ -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