Thanks again, Petr. I've changed both occurrences. Bryn, can you make the latter one (in _dm_reread...) misbehave? I've added a test to exercise the former. Here are the patches I've just pushed:
>From f6bd20573e3ecfb63f62d88c52a0870fb8851b59 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[EMAIL PROTECTED]> Date: Tue, 8 Jul 2008 10:41:20 +0200 Subject: [PATCH] fix computation of largest partition number * libparted/arch/linux.c (_disk_sync_part_table): s/PED_MAX/PED_MIN/ (_dm_reread_part_table): Likewise. Patch by Petr Uzel (tiny change). Details in http://thread.gmane.org/gmane.comp.gnu.parted.devel/2213 --- libparted/arch/linux.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c index 3b8838a..19ddae5 100644 --- a/libparted/arch/linux.c +++ b/libparted/arch/linux.c @@ -2212,7 +2212,7 @@ static int _disk_sync_part_table (PedDisk* disk) { int i; - int last = PED_MAX (ped_disk_get_last_partition_num (disk), 16); + int last = PED_MIN (ped_disk_get_last_partition_num (disk), 16); int* rets = ped_malloc(sizeof(int) * last); int* errnums = ped_malloc(sizeof(int) * last); int ret = 1; @@ -2433,7 +2433,7 @@ static int _dm_reread_part_table (PedDisk* disk) { int rc = 1; - int last = PED_MAX (ped_disk_get_last_partition_num (disk), 16); + int last = PED_MIN (ped_disk_get_last_partition_num (disk), 16); int i; sync(); -- 1.5.6.2.222.gf3584 >From e7be2e5befea3745226f5116c69066f5313c326a Mon Sep 17 00:00:00 2001 From: Jim Meyering <[EMAIL PROTECTED]> Date: Tue, 8 Jul 2008 10:48:07 +0200 Subject: [PATCH] test for the s/PED_MAX/PED_MIN/ partition-number fix * tests/t4200-partprobe.sh: New file. Test for today's fix. * tests/Makefile.am (TESTS): Add t4200-partprobe.sh. (init.sh): Now that we test partprobe, add $(abs_top_builddir)/partprobe to PATH. * tests/test-lib.sh: Honor new dvhtool_required_ variable. Based on a reproducer from Petr Uzel. --- tests/Makefile.am | 7 ++++- tests/t4200-partprobe.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++++ tests/test-lib.sh | 10 +++++++ 3 files changed, 81 insertions(+), 1 deletions(-) create mode 100755 tests/t4200-partprobe.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index fbcad7c..b9db0b1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,6 +11,7 @@ TESTS = \ t3100-resize-ext2-partion.sh \ t4100-msdos-partition-limits.sh \ t4100-dvh-partition-limits.sh \ + t4200-partprobe.sh \ t5000-tags.sh \ t6000-dm.sh \ t7000-scripting.sh @@ -18,13 +19,17 @@ TESTS = \ EXTRA_DIST = \ $(TESTS) test-lib.sh lvm-utils.sh +parted_dir = $(abs_top_builddir)/parted +pp_dir = $(abs_top_builddir)/partprobe +sep = $(PATH_SEPARATOR) + CLEANFILES = init.sh all: init.sh init.sh: Makefile.in rm -f [EMAIL PROTECTED] $@ echo 'PARTED_USABLE_TEST_DIR=$(PARTED_USABLE_TEST_DIR)' > [EMAIL PROTECTED] echo 'abs_top_srcdir=$(abs_top_srcdir)' >> [EMAIL PROTECTED] - echo 'PATH=$(abs_top_builddir)/parted$(PATH_SEPARATOR)$$PATH' >> [EMAIL PROTECTED] + echo 'PATH=$(parted_dir)$(sep)$(pp_dir)$(sep)$$PATH' >> [EMAIL PROTECTED] echo 'export PATH' >> [EMAIL PROTECTED] chmod a-w [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ diff --git a/tests/t4200-partprobe.sh b/tests/t4200-partprobe.sh new file mode 100755 index 0000000..db10c49 --- /dev/null +++ b/tests/t4200-partprobe.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# Copyright (C) 2008 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/>. + +test_description='partprobe must not examine more than 16 partitions' + +privileges_required_=1 +erasable_device_required_=1 +dvhtool_required_=1 + +: ${srcdir=.} +. $srcdir/test-lib.sh +dev=$DEVICE_TO_ERASE + +test_expect_success \ + "setup: create a DVH partition table on $dev" \ + ' + dd if=/dev/zero of=$dev bs=512 count=1 seek=10000 && + parted -s $dev mklabel dvh + ' + +test_expect_success \ + "setup: use dvhtool to create a 17th (invalid?) partition" \ + ' + dd if=/dev/zero of=d bs=1 count=4k && + dvhtool -d $dev --unix-to-vh d data + ' + +# Here's sample output from the parted...print command below: +# BYT; +# /dev/sdd:128880s:scsi:512:512:dvh: Flash Disk; +# 9:0s:4095s:4096s:::; +# 17:4s:11s:8s::data:; + +test_expect_success \ + "ensure that dvhtool did what we want" \ + ' + parted -m -s $dev unit s print > out 2>&1 && + grep "^17:.*::data:;\$" out + ' + +# Parted 1.8.9 and earlier would mistakenly try to access partition #17. +test_expect_success \ + "ensure that partprobe succeeds and produces no output" \ + ' + partprobe -s $dev > out 2>err && + $compare err /dev/null && + echo "$dev: dvh partitions 9 <17>" > exp && + $compare out exp + ' + +test_done diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 621d1b0..3a9a815 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -203,6 +203,16 @@ if test "$privileges_required_" != ''; then fi fi +# If $dvhtool_required_ is nonempty, and you lack the dvhtool program, +# then skip this test. +if test "$dvhtool_required_" != ''; then + (dvhtool --help) > /dev/null 2>&1 || { + SKIP_TESTS="$SKIP_TESTS $this_test" + say "you lack dvhtool, which is required for test $this_test" + skip_=1 + } +fi + emit_superuser_warning() { uid=`id -u` || uid=1 -- 1.5.6.2.222.gf3584 _______________________________________________ parted-devel mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/parted-devel

