[Parted-commits] GNU Parted Official Repository: Changes to 'next'

Joel Granados jgranados-guest at alioth.debian.org
Fri Aug 21 09:10:31 UTC 2009


 libparted/labels/dos.c                     |   15 ++++--
 libparted/labels/fdasd.c                   |    2 
 parted/parted.c                            |    2 
 tests/Makefile.am                          |    2 
 tests/t2300-dos-label-extended-bootcode.sh |   70 +++++++++++++++++++++++++++++
 tests/t6001-dm-ignoremd.sh                 |   62 -------------------------
 tests/t7000-scripting.sh                   |    3 -
 7 files changed, 86 insertions(+), 70 deletions(-)

New commits:
commit 47f532825fcf7378dc20b7dfbe4ab40c1842fa0a
Author: Petr Uzel <petr.uzel at suse.cz>
Date:   Thu Aug 20 15:27:30 2009 +0200

    test for the bootcode-in-extended-partition fix
    
    * tests/t2300-dos-label-extended-bootcode.sh: New file.
    * tests/Makefile.am (TESTS): Add t2300-dos-label-extended-bootcode.sh.
    
    Signed-off-by: Petr Uzel <petr.uzel at suse.cz>

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1e5a211..5090b6a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -13,6 +13,7 @@ TESTS = \
   t2000-mkfs.sh \
   t2100-mkswap.sh \
   t2200-dos-label-recog.sh \
+  t2300-dos-label-extended-bootcode.sh \
   t3000-constraints.sh \
   t3100-resize-ext2-partion.sh \
   t4000-sun-raid-type.sh \
diff --git a/tests/t2300-dos-label-extended-bootcode.sh b/tests/t2300-dos-label-extended-bootcode.sh
new file mode 100755
index 0000000..f2f3a83
--- /dev/null
+++ b/tests/t2300-dos-label-extended-bootcode.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+# Copyright (C) 2009 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='Ensure parted preserves bootcode in extended partition.'
+
+: ${srcdir=.}
+. $srcdir/test-lib.sh
+
+require_512_byte_sector_size_
+
+# Note: the bootcode size is 440B
+
+dev=loop-file
+
+test_expect_success \
+  'Create the test file' \
+  'dd if=/dev/zero of=$dev bs=1024c count=100 >/dev/null 2>&1'
+
+test_expect_success \
+  'Create msdos label' \
+  'parted -s $dev mklabel msdos > out 2>&1'
+test_expect_success 'Expect no output' 'compare out /dev/null'
+
+test_expect_success \
+  'Create extended partition' \
+  'parted -s $dev mkpart extended 32s 127s > out 2>&1'
+test_expect_success 'Expect no output' 'compare out /dev/null'
+
+test_expect_success \
+  'Create logical partition' \
+  'parted -s $dev mkpart logical 64s 127s > out 2>&1'
+test_expect_success 'Expect no output' 'compare out /dev/null'
+
+test_expect_success \
+  'Install fake bootcode' \
+  'dd if=/dev/urandom of=$dev bs=1c seek=16384 count=400 \
+    conv=notrunc > /dev/null 2>&1'
+
+test_expect_success \
+  'Save fake bootcode for later comparison' \
+  'dd if=$dev of=before bs=1 skip=16384 count=440 > /dev/null 2>&1'
+
+test_expect_success \
+  'Do something to the label' \
+  'parted -s $dev rm 5 > out 2>&1'
+test_expect_success 'Expect no output' 'compare out /dev/null'
+
+test_expect_success \
+  'Extract the bootcode for comparison' \
+  'dd if=$dev of=after bs=1 skip=16384 count=440 > /dev/null 2>&1'
+
+test_expect_success \
+  'Expect bootcode has not changed' \
+  'compare before after'
+
+test_done

commit d693a28adbbb298e69b3d4388a9150416a88651a
Author: Petr Uzel <petr.uzel at suse.cz>
Date:   Thu Aug 20 15:27:09 2009 +0200

    do not discard bootcode from extended partition
    
    * libparted/labels/dos.c (write_ext_table): Do not discard
      bootcode from extended partition on msdos label when some of
      the logical partitions are changed
    
    Signed-off-by: Petr Uzel <petr.uzel at suse.cz>

diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index 1d4c2dd..2b1aaca 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -1027,7 +1027,8 @@ write_ext_table (const PedDisk* disk,
                  PedSector sector, const PedPartition* logical)
 {
 	PedPartition*		part;
-	PedSector		lba_offset;
+	PedSector			lba_offset;
+	void*				s;
 
 	PED_ASSERT (disk != NULL, return 0);
 	PED_ASSERT (ped_disk_extended_partition (disk) != NULL, return 0);
@@ -1035,10 +1036,11 @@ write_ext_table (const PedDisk* disk,
 
 	lba_offset = ped_disk_extended_partition (disk)->geom.start;
 
-	void *s = ped_calloc (disk->dev->sector_size);
-	if (s == NULL)
+	if (!ptt_read_sector (disk->dev, sector, &s))
 		return 0;
+
 	DosRawTable *table = s;
+	memset(&(table->partitions), 0, 4 * sizeof(DosRawPartition));
 	table->magic = PED_CPU_TO_LE16 (MSDOS_MAGIC);
 
 	int ok = 0;
@@ -1073,10 +1075,15 @@ static int
 write_empty_table (const PedDisk* disk, PedSector sector)
 {
 	DosRawTable		table;
+	void*			table_sector;
 
 	PED_ASSERT (disk != NULL, return 0);
 
-	memset (&table, 0, sizeof (DosRawTable));
+	if (ptt_read_sector (disk->dev, sector, &table_sector)) {
+		memcpy (&table, table_sector, sizeof(DosRawTable));
+		free(table_sector);
+	}
+	memset (&(table.partitions), 0, 4 * sizeof(DosRawPartition));
 	table.magic = PED_CPU_TO_LE16 (MSDOS_MAGIC);
 
 	return ped_device_write (disk->dev, (void*) &table, sector, 1);

commit 932b8dcb94c031d28ee1b0a9b29f56397dff4215
Author: Joel Granados Moreno <jgranado at redhat.com>
Date:   Tue Aug 18 18:23:35 2009 +0200

    Remove unneeded test.
    
    This test made sure that "md" was ignored when doing partition specific
    actions.  We have added code that allows this scan once more, therefore
    the test is no longer needed.
    
    * tests/t6001-dm-ignoremd.sh: Remove file.
    * tests/Makefile.am: Remove the test file from the list of tests.

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 09caf3d..1e5a211 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -22,7 +22,6 @@ TESTS = \
   t4200-partprobe.sh \
   t5000-tags.sh \
   t6000-dm.sh \
-  t6001-dm-ignoremd.sh \
   t7000-scripting.sh \
   t8000-loop.sh
 
diff --git a/tests/t6001-dm-ignoremd.sh b/tests/t6001-dm-ignoremd.sh
deleted file mode 100755
index 6a3f205..0000000
--- a/tests/t6001-dm-ignoremd.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/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='Ignore devices that start with md from /sys/block.'
-
-privileges_required_=1
-device_mapper_required_=1
-
-: ${srcdir=.}
-. $srcdir/test-lib.sh
-
-require_mdadm_
-
-mddev_=
-
-test "x$ENABLE_DEVICE_MAPPER" = xyes ||
-  {
-    say "skipping $0: no device-mapper support"
-    test_done
-    exit
-  }
-
-test -d /sys/block ||
-  {
-    say "skipping $0: system does not have /sys/block"
-    test_done
-    exit
-  }
-
-cleanup_() {
-    mdadm --stop $mddev_ > /dev/null 2>&1
-    test -n "$d1" && losetup -d "$d1"
-    rm -f "$f1";
-}
-
-test_expect_success \
-    'setup: create loop devices' \
-    'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1")'
-
-test_expect_success \
-    'setup: create md# device' \
-    'mddev_=$(mdadm_create_linear_device_ "$d1")'
-
-test_expect_failure \
-    'grep for the created md device' \
-    'parted -s -m -l | grep "Error:.*: unrecognised disk label"'
-
-test_done

commit 7955e1ca8404b50108aff884a11f1ba6efa191b8
Author: Joel Granados Moreno <jgranado at redhat.com>
Date:   Tue Aug 18 17:21:09 2009 +0200

    Compensate for different behavior in t7000 test.
    
    When the t7000 test was first engineered the "n" did not appear in the
    output when testing mkpart & mkpartfs.  ATM, for an unknown reason,
    the "n" is being echoed in the resulting string causing test failure
    when compared with the errI string.  This patch attempts to make both
    behaviors (with and without the echoed "n") pass the test.
    
    * tests/t7000-scripting.sh: Make sure we don't have an " n" at the end
    of the output string.

diff --git a/tests/t7000-scripting.sh b/tests/t7000-scripting.sh
index 91c4fd5..813841d 100755
--- a/tests/t7000-scripting.sh
+++ b/tests/t7000-scripting.sh
@@ -82,7 +82,8 @@ for mkpart in mkpart mkpartfs; do
   test_expect_success \
       'normalize the actual output' \
       '
-       sed "s,
   *
,,;s, $,," out > o2 && mv -f o2 out &&
+       echo -n x >> out &&
+       sed "s,
   *
,,;s, x$,,;/ n$/ {N;s, n\nx,,}" out > o2 && mv -f o2 out &&
        normalize_part_diag_ out
       '
 

commit 3194a5d9a7264073961d4a73d50d4ef70b2163c4
Author: Gilles Espinasse <g.esp at free.fr>
Date:   Tue Aug 18 10:24:07 2009 +0200

    Fix 2 typos.
    
    * libparted/labels/fdasd.c (fdasd_enqueue_new_partition): Fix typo in
    comment.
    * parted/parted.c (_init_commands): Fix typo in message.

diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index 0311bdc..cb9404e 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -967,7 +967,7 @@ fdasd_enqueue_new_partition (fdasd_anchor_t *anc)
 			anc->fspace_trk = p->start_trk - FIRST_USABLE_TRK;
 		}
 	} else {
-		/* there are partitons in front of the new one */
+		/* there are partitions in front of the new one */
 		if (p->start_trk == p->prev->end_trk + 1) {
 			/* new partition is right behind the previous one */
 			p->fspace_trk = p->prev->fspace_trk - p->len_trk;
diff --git a/parted/parted.c b/parted/parted.c
index 17b2b6c..addd775 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -2182,7 +2182,7 @@ NULL),
                 do_mkfs,
                 str_list_create (
 _("mkfs NUMBER FS-TYPE                      make a FS-TYPE file "
-  "system on partititon NUMBER"),
+  "system on partition NUMBER"),
 NULL),
                 str_list_create (_(number_msg), _(mkfs_fs_type_msg), NULL), 1));
 



More information about the Parted-commits mailing list