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

Jim Meyering meyering at alioth.debian.org
Thu Jun 11 09:44:08 UTC 2009


 dist-check.mk                |    2 -
 doc/parted.texi              |   11 +++--
 libparted/arch/linux.c       |    1 
 libparted/fs/fat/calc.c      |    2 -
 libparted/labels/Makefile.am |    2 -
 libparted/labels/gpt.c       |   31 ++++++++++++---
 parted/parted.c              |   10 ++---
 tests/Makefile.am            |    1 
 tests/t0000-basic.sh         |    4 --
 tests/t6001-dm-ignoremd.sh   |   85 +++++++++++++++++++++++++++++++++++++++++++
 10 files changed, 127 insertions(+), 22 deletions(-)

New commits:
commit a2341d1fe688ba4d2d19ebed44626d205f50744b
Author: Joel Granados Moreno <jgranado at redhat.com>
Date:   Wed Jun 10 19:05:51 2009 +0200

    doc: improve mkpart description
    
    * doc/parted.texi: Make sure that part-type is portrayed as an
    optional argument.  Mention the "special behavior" that mkpart has
    with specific disk label types.

diff --git a/doc/parted.texi b/doc/parted.texi
index 936a1f6..fdb9af3 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -673,7 +673,7 @@ Make a @var{fat32} file system on partition 2.
 @cindex mkpart, command description
 @cindex command description, mkpart
 
- at deffn Command mkpart @var{part-type} [@var{fs-type}] @var{start} @var{end}
+ at deffn Command mkpart [@var{part-type} @var{fs-type} @var{name}] @var{start} @var{end}
 
 Creates a new partition, @emph{without} creating a new file system on
 that partition.  This is useful for creating partitions for file systems
@@ -684,10 +684,13 @@ partitions (i.e., non-extended partitions).  @var{start} and @var{end}
 are the offset from the beginning of the disk, that is, the ``distance''
 from the start of the disk.
 
- at var{part-type} is one of: primary, extended, logical.  Extended and
-logical are only used for msdos and dvh disk labels.
+ at var{part-type} is one of @samp{primary}, @samp{extended} or @samp{logical},
+and may be specified only with @samp{msdos} or @samp{dvh} partition tables.
+A @var{name} must be specified for a @samp{gpt} partition table.
+Neither @var{part-type} nor @var{name} may be used with a @samp{sun}
+partition table.
 
- at var{fs-type} must be on of these supported file systems:
+ at var{fs-type} must be one of these supported file systems:
 @itemize @bullet
 @item ext2
 @item fat16, fat32

commit 0615f35015f375d2c80cd95939b28fba3828eddb
Author: Joel Granados Moreno <jgranado at redhat.com>
Date:   Wed Jun 10 19:05:50 2009 +0200

    parted-ui: ensure cmd-line buffer is empty before ped_exception_throw
    
    When ped_exception_throw requires input from the user and there are
    leftover strings in the command line, there is an "invalid token" error
    from parted.  This happens because the ped_exception expects some input
    that is, most likely, different from the leftover string(s).  To address
    this, one must make sure that all the argument strings are parsed before
    invoking any exception that requires input.
    
    * parted/parted.c (do_mklabel): Call command_line_get_disk_type call
    before the disk checks (_disk_warn_loss will call ped_exception_throw).
    * tests/t0000-basic.sh: Adjust, now that the output need not include
    the error message.

diff --git a/parted/parted.c b/parted/parted.c
index ac1b176..e6364bf 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1,6 +1,6 @@
 /*
     parted - a frontend to libparted
-    Copyright (C) 1999-2003, 2005-2008 Free Software Foundation, Inc.
+    Copyright (C) 1999-2003, 2005-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
@@ -595,13 +595,16 @@ static int
 do_mklabel (PedDevice** dev)
 {
         PedDisk*                disk;
-        const PedDiskType*      type = ped_disk_probe (*dev);
+        const PedDiskType*      type = NULL;
 
         ped_exception_fetch_all ();
         disk = ped_disk_new (*dev);
         if (!disk) ped_exception_catch ();
         ped_exception_leave_all ();
 
+        if (!command_line_get_disk_type (_("New disk label type?"), &type))
+                goto error;
+
         if (disk) {
                 if (!_disk_warn_busy (disk))
                         goto error_destroy_disk;
@@ -611,9 +614,6 @@ do_mklabel (PedDevice** dev)
                 ped_disk_destroy (disk);
         }
 
-        if (!command_line_get_disk_type (_("New disk label type?"), &type))
-                goto error;
-
         disk = ped_disk_new_fresh (*dev, type);
         if (!disk)
                 goto error;
diff --git a/tests/t0000-basic.sh b/tests/t0000-basic.sh
index 4d7f2ee..6b6b07e 100755
--- a/tests/t0000-basic.sh
+++ b/tests/t0000-basic.sh
@@ -64,7 +64,7 @@ test_expect_success \
     'check its "interactive" output' \
     'compare out exp 1>&2'
 
-test_expect_success 'create interactive input' 'printf "y\n\n" > in'
+test_expect_success 'create interactive input' 'printf "y\n" > in'
 
 # Now that there's a label, rerunning the same command is interactive.
 test_expect_success \
@@ -84,9 +84,7 @@ fail=0
 cat <<EOF >> exp || fail=1
 Warning: The existing disk label on DEVICE will be destroyed and all\
  data on this disk will be lost. Do you want to continue?
-parted: invalid token: msdos
 Yes/No? y
-New disk label type?  [msdos]?
 EOF
 test_expect_success \
     'create expected output file' \

commit fafc091696d3022f7b1d6bf5df719a465e8e1cf7
Author: Joel Granados Moreno <jgranado at redhat.com>
Date:   Wed Jun 10 19:05:49 2009 +0200

    tests: verify that "md" devices are not listed
    
    * tests/t6001-dm-ignored.sh: New test file.
    * tests/Makefile.am (TESTS): Add it.

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2931e98..de09d38 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,6 +19,7 @@ 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
new file mode 100755
index 0000000..4fd9763
--- /dev/null
+++ b/tests/t6001-dm-ignoremd.sh
@@ -0,0 +1,85 @@
+#!/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
+# This will setup private /dev and /etc
+device_mapper_required_=1
+
+: ${srcdir=.}
+. $srcdir/test-lib.sh
+
+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
+  }
+
+which mdadm > /dev/null 2>&1 ||
+  {
+    say "skipping $0: could not find mdadm executable"
+    test_done
+    exit
+  }
+
+# The md device.
+mddev_=
+
+cleanup_() {
+    mdadm --stop $mddev_ > /dev/null 2>&1
+    test -n "$d1" && losetup -d "$d1"
+    rm -f "$f1";
+}
+
+md_dev_create_()
+{
+  lo_dev=$1
+  mdd=$G_dev_/md0
+  for i in 0 1 2 3 4 5 6 7 8 9 ; do
+      mdd=$G_dev_/md$i
+      mdadm  --create --force $mdd --level=linear --raid-devices=1 $lo_dev > /dev/null 2>&1 \
+      && break
+
+      if [ $i -eq 9 ]; then echo $mdd ; return 1 ; fi
+  done
+
+  echo $mdd
+  return 0
+}
+
+test_expect_success \
+    'setup: create loop devices' \
+    'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1")'
+
+test_expect_success \
+    'setup: create md# device' \
+    'mddev_=$(md_dev_create_ "$d1")'
+
+test_expect_failure \
+    'grep for the created md device' \
+    'parted -s -m -l | grep "Error:.*: unrecognised disk label"'
+
+test_done

commit f94e08bdb4ba0fa1b9fd35509e04c2d9ee84ff80
Author: Joel Granados Moreno <jgranado at redhat.com>
Date:   Wed Jun 10 19:05:48 2009 +0200

    linux: skip "md" devices when probing
    
    * libparted/arch/linux.c (_skip_entry) : Add "md" to the entries
    array so all devices of type "/dev/md#" get ignored.

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index ae0f8fb..66fdd37 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1994,6 +1994,7 @@ _skip_entry (const char *name)
 		{ ".",		sizeof (".") - 1	},
 		{ "..",		sizeof ("..") - 1	},
 		{ "dm-",	sizeof ("dm-") - 1	},
+		{ "md",		sizeof ("md") - 1	},
 		{ "loop",	sizeof ("loop") - 1	},
 		{ "ram",	sizeof ("ram") - 1	},
 		{ 0, 0 },

commit f51228760b9fd3322efd2f70cb2ec2fbcd71427f
Author: Joel Granados Moreno <jgranado at redhat.com>
Date:   Wed Jun 10 19:05:47 2009 +0200

    fat: support 64KB clusters for FAT16
    
    * libparted/fs/fat/calc.c (fat_max_cluster_size): A 64KB cluster
    size (128 sectors) for FAT16 is not common but is possible.  Allow
    the use of 128-sector clusters instead of outputting an error.
    
    Fixes this:
        http://parted.alioth.debian.org/cgi-bin/trac.cgi/ticket/207
    Additional info here:
        http://lists.alioth.debian.org/\
          pipermail/parted-devel/2009-June/002882.html

diff --git a/libparted/fs/fat/calc.c b/libparted/fs/fat/calc.c
index 026aec8..327ae67 100644
--- a/libparted/fs/fat/calc.c
+++ b/libparted/fs/fat/calc.c
@@ -62,7 +62,7 @@ PedSector
 fat_max_cluster_size (FatType fat_type) {
 	switch (fat_type) {
 		case FAT_TYPE_FAT12: return 1;	/* dunno... who cares? */
-		case FAT_TYPE_FAT16: return 32768/512;
+		case FAT_TYPE_FAT16: return 65536/512;
 		case FAT_TYPE_FAT32: return 65536/512;
 	}
 	return 0;

commit 14cce9b2e84bffb5b3c64e96e025914e8e85f2d1
Author: Matthew S. Harris <mharris312 at gmail.com>
Date:   Wed Jun 10 19:05:46 2009 +0200

    gpt: fix gpt_read to read all of the partition entries correctly
    
    * libparted/labels/gpt.c (gpt_read): Use the SizeOfPartitionEntry
    field value when reading the partition entries rather than assuming
    that the entries are the same size as our struct.
    (gpt_read): When reading the partition
    entries, round up, not down, the number of sectors to read.
    (_header_is_valid): Check that the SizeOfPartitionEntry is sane.
    With minor adjustments by Joel Granados Moreno.

diff --git a/libparted/labels/Makefile.am b/libparted/labels/Makefile.am
index 9acc296..d4fe198 100644
--- a/libparted/labels/Makefile.am
+++ b/libparted/labels/Makefile.am
@@ -9,7 +9,7 @@ else
 S390_SRCS =
 endif
 
-partedincludedir      =	-I$(top_srcdir)/include
+partedincludedir      =	-I$(top_srcdir)/lib -I$(top_srcdir)/include
 noinst_LTLIBRARIES    =	liblabels.la
 
 liblabels_la_SOURCES = \
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 765c8a5..536e06a 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -38,6 +38,7 @@
 #include <unistd.h>
 #include <uuid/uuid.h>
 #include <stdbool.h>
+#include "xalloc.h"
 
 #if ENABLE_NLS
 #  include <libintl.h>
@@ -603,6 +604,14 @@ _header_is_valid (const PedDevice* dev, GuidPartitionTableHeader_t* gpt)
 	    || PED_LE32_TO_CPU (gpt->HeaderSize) > dev->sector_size)
 		return 0;
 
+	/*
+	 * the SizeOfPartitionEntry must be a multiple of 8 and
+	 * no smaller than the size of the PartitionEntry structure.
+	 */
+	uint32_t sope = gpt->SizeOfPartitionEntry;
+	if (sope % 8 != 0 || sope < sizeof(GuidPartitionEntry_t) )
+		return 0;
+
 	origcrc = gpt->HeaderCRC32;
 	gpt->HeaderCRC32 = 0;
 	crc = pth_crc32 (dev, gpt);
@@ -807,8 +816,8 @@ gpt_read (PedDisk * disk)
 {
 	GPTDiskData *gpt_disk_data = disk->disk_specific;
 	GuidPartitionTableHeader_t* gpt;
-	GuidPartitionEntry_t* ptes;
-	int ptes_size;
+	void* ptes;
+	size_t ptes_sectors;
 	int i;
 #ifndef DISCOVER_ONLY
 	int write_back = 0;
@@ -902,22 +911,30 @@ gpt_read (PedDisk * disk)
 	if (!_parse_header (disk, gpt, &write_back))
 		goto error_free_gpt;
 
+	ptes_sectors = ped_div_round_up (gpt->SizeOfPartitionEntry
+					 * gpt_disk_data->entry_count,
+					 disk->dev->sector_size);
+
+	if (xalloc_oversized (ptes_sectors, disk->dev->sector_size))
+		goto error_free_gpt;
+	ptes = ped_malloc (ptes_sectors * disk->dev->sector_size);
 
-	ptes_size = sizeof (GuidPartitionEntry_t) * gpt_disk_data->entry_count;
-	ptes = (GuidPartitionEntry_t*) ped_malloc (ptes_size);
 	if (!ped_device_read (disk->dev, ptes,
 			      PED_LE64_TO_CPU(gpt->PartitionEntryLBA),
-			      ptes_size / disk->dev->sector_size))
+			      ptes_sectors))
 		goto error_free_ptes;
 
 	for (i = 0; i < gpt_disk_data->entry_count; i++) {
+		GuidPartitionEntry_t* pte
+		  = (GuidPartitionEntry_t*) ((char *)ptes + i
+					     * gpt->SizeOfPartitionEntry);
 		PedPartition* part;
 		PedConstraint* constraint_exact;
 
-		if (!guid_cmp (ptes[i].PartitionTypeGuid, UNUSED_ENTRY_GUID))
+		if (!guid_cmp (pte->PartitionTypeGuid, UNUSED_ENTRY_GUID))
 			continue;
 
-		part = _parse_part_entry (disk, &ptes[i]);
+		part = _parse_part_entry (disk, pte);
 		if (!part)
 			goto error_delete_all;
 

commit 34386567878a879bbf24d53e262581289b2d0a21
Author: Joel Granados Moreno <jgranado at redhat.com>
Date:   Wed Jun 10 19:05:55 2009 +0200

    Tweak distcheck.
    
    * dist-check.mk (install-transform-check): The binaries will be located
    in /sbin instead of /bin.

diff --git a/dist-check.mk b/dist-check.mk
index 16f3859..40e909c 100644
--- a/dist-check.mk
+++ b/dist-check.mk
@@ -46,7 +46,7 @@ define install-transform-check
     && rm -rf $(pfx)					\
     && $(MAKE) program_transform_name='s/.*/zyx/'	\
       prefix=$(pfx) install				\
-    && test "$$(echo $(pfx)/bin/*)" = "$(pfx)/bin/zyx"	\
+    && test "$$(echo $(pfx)/sbin/*)" = "$(pfx)/sbin/zyx"	\
     && test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
 endef
 



More information about the Parted-commits mailing list