Soren Hansen <[EMAIL PROTECTED]> wrote: > Parted fails if telling the kernel to reread the partition table for the > device > in question fails. However, for loop back devices and possibly other > types of disk images, this makes little sense. > > This patch makes libparted consider (ioctl(fd, BLKRRPART) || errno > == EINVAL) succesful, and provides a test script as well. > > Signed-off-by: Soren Hansen <[EMAIL PROTECTED]> > > --- > libparted/arch/linux.c | 4 ++-- > tests/Makefile.am | 3 ++- > tests/t8000-loop.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 49 insertions(+), 3 deletions(-) > create mode 100755 tests/t8000-loop.sh
Thanks for the patch and the new test. Since the part that changes libparted/arch/linux.c also modifies how Parted reacts to a failed attempt to tell the kernel about the "add partition" event, I'm omitting it. In addition, I've seen people who've found obvious value in the "EINVAL" failure message (they were trying to partition a device that they didn't realize was not partitionable), so that's another reason not to suppress the diagnostic and failure. Alerting users to such a fundamental misconception is worthwhile. I've modified your test script to expect the existing behavior (i.e., the mkpart failure) but your name is still on it, so will wait for your "ok" before pushing it. Here's the adjusted patch: >From 1a618be38c6cab3d5aeca8ec580b332c9828c624 Mon Sep 17 00:00:00 2001 From: Soren Hansen <[EMAIL PROTECTED]> Date: Wed, 6 Aug 2008 20:15:00 +0200 Subject: [PATCH] add a test for recently introduced loop-dev-based bug This also checks for the current behavior when trying to partition a device that may not be partitioned, like loop devices. * tests/Makefile.am (TESTS): Add tests/t8000-loop.sh. * tests/t8000-loop.sh: New file. Test for the above fix. --- tests/Makefile.am | 3 +- tests/t8000-loop.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletions(-) create mode 100755 tests/t8000-loop.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index 1b00cc3..019d1bc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -15,7 +15,8 @@ TESTS = \ t4200-partprobe.sh \ t5000-tags.sh \ t6000-dm.sh \ - t7000-scripting.sh + t7000-scripting.sh \ + t8000-loop.sh EXTRA_DIST = \ $(TESTS) test-lib.sh lvm-utils.sh diff --git a/tests/t8000-loop.sh b/tests/t8000-loop.sh new file mode 100755 index 0000000..016c715 --- /dev/null +++ b/tests/t8000-loop.sh @@ -0,0 +1,55 @@ +#!/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='Test usage of loop devices' + +privileges_required_=1 +device_mapper_required_=1 + +: ${srcdir=.} +. $srcdir/test-lib.sh + +cleanup_() { + test -n "$d1" && losetup -d "$d1" + rm -f "$f1"; +} + +emit_expected_diagnostic() +{ + printf '%s\n' \ + 'Error: Error informing the kernel about modifications to partiti' \ + 'Warning: The kernel was unable to re-read the partition table on' +} + +test_expect_success \ + "setup: create loop devices" \ + 'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1")' + +test_expect_success \ + 'run parted -s "$d1" mklabel msdos' \ + 'parted -s $d1 mklabel msdos > out 2>&1' +test_expect_success 'check for empty output' '$compare out /dev/null' + +test_expect_failure \ + 'run parted -s "$d1" mkpart primary 1 10' \ + 'parted -s $d1 mkpart primary 1 10 > out 2>&1' +test_expect_success 'prepare actual/expected output' \ + 'emit_expected_diagnostic > exp && + cut -b1-64 out > k && mv k out' +test_expect_success 'check for expected output' '$compare exp out' + +test_done -- 1.6.0.rc2.2.g59bf _______________________________________________ parted-devel mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/parted-devel

