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

Jim Meyering meyering at alioth.debian.org
Mon Feb 22 08:57:12 UTC 2010


 NEWS                    |   14 ++++++++++++
 libparted/arch/linux.c  |    7 ++++--
 libparted/disk.c        |    3 ++
 libparted/labels/aix.c  |   22 -------------------
 libparted/labels/bsd.c  |   16 --------------
 libparted/labels/dasd.c |   24 ---------------------
 libparted/labels/dos.c  |   21 -------------------
 libparted/labels/dvh.c  |   10 ---------
 libparted/labels/gpt.c  |   16 --------------
 libparted/labels/loop.c |   11 ---------
 libparted/labels/mac.c  |   53 ------------------------------------------------
 libparted/labels/pc98.c |   26 -----------------------
 libparted/labels/rdb.c  |   25 ----------------------
 libparted/labels/sun.c  |   21 -------------------
 14 files changed, 33 insertions(+), 236 deletions(-)

New commits:
commit abb411bce7e6a1699f09c9a32e32739d2e4becfb
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Thu Feb 18 15:34:41 2010 +0100

    libparted: copy the needs_clobber value in ped_disk_duplicate()
    
    Most duplicate disk_ops use ped_disk_new_fresh, which sets needs_clobber
    to 1. This would lead to clobbering the disk when committing a duplicate
    disk even when the original disk was not made with ped_disk_new_fresh.
    * libparted/disk.c (ped_disk_duplicate): Copy the needs_clobber member.
    * NEWS (Bug fixes): Describe it.

diff --git a/NEWS b/NEWS
index 8e80746..30ca181 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,11 @@ GNU parted NEWS                                    -*- outline -*-
   or a user might encounter a failure to format or delete a newly
   created partition, respectively.
 
+  libparted: committing a disk that was returned by ped_disk_duplicate
+  would always result in ped_disk_clobber being called (and thus the first
+  and last 9KiB of the disk being zeroed), even if the duplicated disk,
+  was not returned by ped_disk_fresh().
+
 
 * Noteworthy changes in release 2.1 (2009-12-20) [stable]
 
diff --git a/libparted/disk.c b/libparted/disk.c
index b819d59..fc5ef17 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -276,6 +276,9 @@ ped_disk_duplicate (const PedDisk* old_disk)
 	}
 	if (!_disk_pop_update_mode (new_disk))
 		goto error_destroy_new_disk;
+
+        new_disk->needs_clobber = old_disk->needs_clobber;
+
 	return new_disk;
 
 error_destroy_new_disk:

commit 0a21f0b7ed7ff0e536a5c30dfe1910c33d2ca243
Author: Curtis Gedak <gedakc at gmail.com>
Date:   Mon Feb 22 09:13:53 2010 +0100

    linux: add wait time and retries to kernel partition reread
    
    Occasionally when using parted with newer GNU/Linux kernels (2.6.31)
    and udev (145), the kernel would fail to reread the partition table.
    This could lead to problems with subsequent actions such as formatting
    the partition.
    
    Basically this patch increases the retry_count, and adds one sleep(1)
    function call prior to the the last few ioctl() calls.
    
    This patch might not be a perfect solution to this problem of "failure
    to inform kernel of partition changes", but it does significantly
    reduce the likelihood of encountering the problem.
    
    Details on the testing results and procedures used can be found at
    the following link:
    https://bugzilla.gnome.org/show_bug.cgi?id=604298#c9
    
    * libparted/arch/linux.c (_kernel_reread_part_table): Sleep for a
    full second if retry_count makes it down to "3".  Start it at 9
    rather than at 5.
    * NEWS (Bug fixes):

diff --git a/NEWS b/NEWS
index 28f87de..8e80746 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,15 @@ GNU parted NEWS                                    -*- outline -*-
 
   "make install" no longer installs tests programs named disk and label
 
+  libparted: try harder to inform kernel of partition changes.
+  Previously when editing partitions, occasionally the kernel would
+  fail to be informed of partition changes.  When this happened future
+  problems would occur because the kernel had incorrect information.
+  For example, if this problem arose when resizing or creating a
+  new partition, then an incorrect partition size might be displayed
+  or a user might encounter a failure to format or delete a newly
+  created partition, respectively.
+
 
 * Noteworthy changes in release 2.1 (2009-12-20) [stable]
 
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index a083028..49ab08c 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1,5 +1,5 @@
 /* libparted - a library for manipulating disk partitions
-    Copyright (C) 1999 - 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+    Copyright (C) 1999-2010 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
@@ -2521,12 +2521,15 @@ static int
 _kernel_reread_part_table (PedDevice* dev)
 {
         LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
-        int             retry_count = 5;
+        int             retry_count = 9;
 
         sync();
         while (ioctl (arch_specific->fd, BLKRRPART)) {
                 retry_count--;
                 sync();
+                if (retry_count == 3)
+                        sleep(1); /* Pause to allow system to settle */
+
                 if (!retry_count) {
                         ped_exception_throw (
                                 PED_EXCEPTION_WARNING,

commit 66df8b2ce2f596e7c446c08d9874cce5700555fd
Author: Jim Meyering <meyering at redhat.com>
Date:   Sat Feb 20 12:44:47 2010 +0100

    maint: remove now-unused <partition_table_type>_clobber functions
    
    All of these functions were rendered unused by commit 376b143045,
    "ped_disk_clobber: change semantics" on 2009-11-13.
    Also, Update each <...>_disk_ops "clobber:" member to be NULL.
    * libparted/labels/aix.c (aix_clobber): Remove function.
    * libparted/labels/bsd.c (bsd_clobber): Likewise.
    * libparted/labels/dasd.c (dasd_clobber): Likewise.
    * libparted/labels/dos.c (msdos_clobber): Likewise.
    * libparted/labels/dvh.c (dvh_clobber): Likewise.
    * libparted/labels/gpt.c (gpt_clobber): Likewise.
    * libparted/labels/loop.c (loop_clobber): Likewise.
    * libparted/labels/mac.c (_clobber_part_map, mac_clobber): Likewise.
    * libparted/labels/pc98.c (pc98_clobber): Likewise.
    * libparted/labels/rdb.c (amiga_clobber): Likewise.
    * libparted/labels/sun.c (sun_clobber): Likewise.
    Suggested by Hans De Goede.

diff --git a/libparted/labels/aix.c b/libparted/labels/aix.c
index 6a39202..804e8c2 100644
--- a/libparted/labels/aix.c
+++ b/libparted/labels/aix.c
@@ -64,26 +64,6 @@ aix_probe (const PedDevice *dev)
 	return magic == AIX_LABEL_MAGIC;
 }
 
-#ifndef DISCOVER_ONLY
-static int
-aix_clobber (PedDevice* dev)
-{
-	PED_ASSERT (dev != NULL, return 0);
-
-	if (!aix_probe (dev))
-		return 0;
-
-	void *label;
-	if (!ptt_read_sector (dev, 0, &label))
-		return 0;
-
-	aix_label_magic_set (label, 0);
-	int result = ped_device_write (dev, label, 0, 1);
-	free (label);
-	return result;
-}
-#endif /* !DISCOVER_ONLY */
-
 static PedDisk*
 aix_alloc (const PedDevice* dev)
 {
@@ -239,7 +219,7 @@ aix_alloc_metadata (PedDisk* disk)
 PT_define_limit_functions (aix)
 
 static PedDiskOps aix_disk_ops = {
-	clobber:		NULL_IF_DISCOVER_ONLY (aix_clobber),
+	clobber:		NULL,
 	write:			NULL_IF_DISCOVER_ONLY (aix_write),
 
 	partition_set_name:		NULL,
diff --git a/libparted/labels/bsd.c b/libparted/labels/bsd.c
index e1b57e5..0f9eb62 100644
--- a/libparted/labels/bsd.c
+++ b/libparted/labels/bsd.c
@@ -254,20 +254,6 @@ bsd_free (PedDisk* disk)
 	_ped_disk_free (disk);
 }
 
-#ifndef DISCOVER_ONLY
-static int
-bsd_clobber (PedDevice* dev)
-{
-	void *label;
-	if (!ptt_read_sector (dev, 0, &label))
-		return 0;
-	BSDRawLabel *rawlabel
-	  = (BSDRawLabel *) ((char *) label + BSD_LABEL_OFFSET);
-	rawlabel->d_magic = 0;
-	return ped_device_write (dev, label, 0, 1);
-}
-#endif /* !DISCOVER_ONLY */
-
 static int
 bsd_read (PedDisk* disk)
 {
@@ -641,7 +627,7 @@ error:
 PT_define_limit_functions (bsd)
 
 static PedDiskOps bsd_disk_ops = {
-	clobber:		NULL_IF_DISCOVER_ONLY (bsd_clobber),
+	clobber:		NULL,
 	write:			NULL_IF_DISCOVER_ONLY (bsd_write),
 
 	partition_set_name:	NULL,
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index 516d189..275a55a 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -75,7 +75,6 @@ typedef struct {
 } DasdDiskSpecific;
 
 static int dasd_probe (const PedDevice *dev);
-static int dasd_clobber (PedDevice* dev);
 static int dasd_read (PedDisk* disk);
 static int dasd_write (const PedDisk* disk);
 
@@ -111,7 +110,7 @@ static int dasd_alloc_metadata (PedDisk* disk);
 PT_define_limit_functions (dasd)
 
 static PedDiskOps dasd_disk_ops = {
-	clobber:		NULL_IF_DISCOVER_ONLY (dasd_clobber),
+	clobber:		NULL,
 	write:			NULL_IF_DISCOVER_ONLY (dasd_write),
 
 	partition_set_name:	NULL,
@@ -243,27 +242,6 @@ dasd_probe (const PedDevice *dev)
 }
 
 static int
-dasd_clobber (PedDevice* dev)
-{
-	LinuxSpecific* arch_specific;
-	struct fdasd_anchor anchor;
-
-	PED_ASSERT(dev != NULL, return 0);
-
-	arch_specific = LINUX_SPECIFIC(dev);
-
-	fdasd_initialize_anchor(&anchor);
-	fdasd_get_geometry(dev, &anchor, arch_specific->fd);
-
-	fdasd_recreate_vtoc(&anchor);
-	fdasd_write_labels(&anchor, arch_specific->fd);
-
-	fdasd_cleanup(&anchor);
-
-	return 1;
-}
-
-static int
 dasd_read (PedDisk* disk)
 {
 	int i;
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index 339acf4..dce35b2 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -306,25 +306,6 @@ msdos_disk_is_flag_available (const PedDisk *disk, PedDiskFlag flag)
         }
 }
 
-#ifndef DISCOVER_ONLY
-static int
-msdos_clobber (PedDevice* dev)
-{
-	PED_ASSERT (dev != NULL, return 0);
-	PED_ASSERT (msdos_probe (dev), return 0);
-
-	void *label;
-	if (!ptt_read_sector (dev, 0, &label))
-		return 0;
-
-	DosRawTable *table = label;
-	table->magic = 0;
-        int write_ok = ped_device_write (dev, (void*) table, 0, 1);
-        free (label);
-	return write_ok;
-}
-#endif /* !DISCOVER_ONLY */
-
 static int
 chs_get_cylinder (const RawCHS* chs)
 {
@@ -2338,7 +2319,7 @@ msdos_get_max_supported_partition_count(const PedDisk* disk, int *max_n)
 PT_define_limit_functions (msdos)
 
 static PedDiskOps msdos_disk_ops = {
-	clobber:		NULL_IF_DISCOVER_ONLY (msdos_clobber),
+	clobber:		NULL,
 	write:			NULL_IF_DISCOVER_ONLY (msdos_write),
 
 	disk_set_flag:          msdos_disk_set_flag,
diff --git a/libparted/labels/dvh.c b/libparted/labels/dvh.c
index 55654d9..c96741a 100644
--- a/libparted/labels/dvh.c
+++ b/libparted/labels/dvh.c
@@ -95,14 +95,6 @@ dvh_probe (const PedDevice *dev)
 	return found;
 }
 
-#ifndef DISCOVER_ONLY
-static int
-dvh_clobber (PedDevice* dev)
-{
-	return ptt_clear_sectors (dev, 0, 1);
-}
-#endif /* !DISCOVER_ONLY */
-
 static PedDisk*
 dvh_alloc (const PedDevice* dev)
 {
@@ -892,7 +884,7 @@ error:
 PT_define_limit_functions (dvh)
 
 static PedDiskOps dvh_disk_ops = {
-	clobber:		NULL_IF_DISCOVER_ONLY (dvh_clobber),
+	clobber:		NULL,
 	write:			NULL_IF_DISCOVER_ONLY (dvh_write),
 
 	partition_set_name:	dvh_partition_set_name,
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 40ee0c1..4793315 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -494,20 +494,6 @@ gpt_probe (const PedDevice *dev)
   return ok;
 }
 
-#ifndef DISCOVER_ONLY
-/* writes zeros to the PMBR and the primary GPTH, and to the final sector */
-static int
-gpt_clobber (PedDevice *dev)
-{
-  PED_ASSERT (dev != NULL, return 0);
-
-  return (ptt_clear_sectors (dev, GPT_PMBR_LBA, GPT_PMBR_SECTORS)
-          && ptt_clear_sectors (dev, GPT_PRIMARY_HEADER_LBA, GPT_HEADER_SECTORS)
-          && ptt_clear_sectors (dev, dev->length - GPT_HEADER_SECTORS,
-                                GPT_HEADER_SECTORS));
-}
-#endif /* !DISCOVER_ONLY */
-
 static PedDisk *
 gpt_alloc (const PedDevice *dev)
 {
@@ -1736,7 +1722,7 @@ PT_define_limit_functions (gpt)
 
 static PedDiskOps gpt_disk_ops =
 {
-  clobber:			NULL_IF_DISCOVER_ONLY (gpt_clobber),
+  clobber:			NULL,
   write:			NULL_IF_DISCOVER_ONLY (gpt_write),
 
   partition_set_name:		gpt_partition_set_name,
diff --git a/libparted/labels/loop.c b/libparted/labels/loop.c
index d225cdf..17cdf4e 100644
--- a/libparted/labels/loop.c
+++ b/libparted/labels/loop.c
@@ -73,15 +73,6 @@ error:
 	return 0;
 }
 
-#ifndef DISCOVER_ONLY
-static int
-loop_clobber (PedDevice* dev)
-{
-	PED_ASSERT (dev != NULL, return 0);
-        return ptt_clear_sectors (dev, 0, 1);
-}
-#endif /* !DISCOVER_ONLY */
-
 static PedDisk*
 loop_alloc (const PedDevice* dev)
 {
@@ -297,7 +288,7 @@ loop_get_max_supported_partition_count (const PedDisk* disk, int *max_n)
 PT_define_limit_functions (loop)
 
 static PedDiskOps loop_disk_ops = {
-	clobber:		NULL_IF_DISCOVER_ONLY (loop_clobber),
+	clobber:		NULL,
 	write:			NULL_IF_DISCOVER_ONLY (loop_write),
 
 	partition_set_name:	NULL,
diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
index 19de261..49a236e 100644
--- a/libparted/labels/mac.c
+++ b/libparted/labels/mac.c
@@ -353,57 +353,6 @@ mac_free (PedDisk* disk)
 	free (mac_disk_data);
 }
 
-#ifndef DISCOVER_ONLY
-static int
-_clobber_part_map (PedDevice* dev)
-{
-        void *buf = ped_malloc (dev->sector_size);
-        if (!buf)
-                return 0;
-
-        int ok = 1;
-	PedSector sector;
-	for (sector=1; 1; sector++) {
-                if (!ped_device_read (dev, buf, sector, 1)) {
-                        ok = 0;
-                        break;
-                }
-		if (!_rawpart_check_signature (buf)) {
-                        ok = 1;
-                        break;
-                }
-		memset (buf, 0, dev->sector_size);
-		if (!ped_device_write (dev, buf, sector, 1)) {
-                        ok = 0;
-                        break;
-                }
-	}
-        free (buf);
-        return ok;
-}
-
-static int
-mac_clobber (PedDevice* dev)
-{
-	void *buf;
-	if (!ptt_read_sector (dev, 0, &buf))
-		return 0;
-
-	if (!_check_signature (buf)) {
-                free (buf);
-		return 0;
-        }
-
-        memset (buf, 0, dev->sector_size);
-        int ok = ped_device_write (dev, buf, 0, 1);
-        free (buf);
-        if (!ok)
-		return 0;
-
-	return _clobber_part_map (dev);
-}
-#endif /* !DISCOVER_ONLY */
-
 static int
 _rawpart_cmp_type (const MacRawPartition* raw_part, const char* type)
 {
@@ -1634,7 +1583,7 @@ mac_get_max_supported_partition_count (const PedDisk* disk, int *max_n)
 PT_define_limit_functions (mac)
 
 static PedDiskOps mac_disk_ops = {
-	clobber: NULL_IF_DISCOVER_ONLY (mac_clobber),
+	clobber: NULL,
         /* FIXME: remove this cast, once mac_write is fixed not to
            modify its *DISK parameter.  */
 	write:	NULL_IF_DISCOVER_ONLY ((int (*) (const PedDisk*)) mac_write),
diff --git a/libparted/labels/pc98.c b/libparted/labels/pc98.c
index 2f9e5cd..4b34480 100644
--- a/libparted/labels/pc98.c
+++ b/libparted/labels/pc98.c
@@ -218,30 +218,6 @@ pc98_probe (const PedDevice *dev)
 	return 1;
 }
 
-#ifndef DISCOVER_ONLY
-static int
-pc98_clobber (PedDevice* dev)
-{
-	PC98RawTable	table;
-
-	PED_ASSERT (dev != NULL, return 0);
-	PED_ASSERT (pc98_probe (dev), return 0);
-
-	if (!ped_device_read (dev, &table, 0, 1))
-		return 0;
-
-	memset (table.partitions, 0, sizeof (table.partitions));
-	table.magic = PED_CPU_TO_LE16(0);
-
-	if (pc98_check_ipl_signature (&table))
-		memset (table.boot_code, 0, sizeof (table.boot_code));
-
-	if (!ped_device_write (dev, (void*) &table, 0, 1))
-		return 0;
-	return ped_device_sync (dev);
-}
-#endif /* !DISCOVER_ONLY */
-
 static PedDisk*
 pc98_alloc (const PedDevice* dev)
 {
@@ -857,7 +833,7 @@ pc98_get_max_supported_partition_count (const PedDisk* disk, int *max_n)
 PT_define_limit_functions (pc98)
 
 static PedDiskOps pc98_disk_ops = {
-	clobber:		NULL_IF_DISCOVER_ONLY (pc98_clobber),
+	clobber:		NULL,
 	write:			NULL_IF_DISCOVER_ONLY (pc98_write),
 
 	partition_set_name:	pc98_partition_set_name,
diff --git a/libparted/labels/rdb.c b/libparted/labels/rdb.c
index 71b3458..43bb7a7 100644
--- a/libparted/labels/rdb.c
+++ b/libparted/labels/rdb.c
@@ -449,29 +449,6 @@ amiga_free (PedDisk* disk)
 	_ped_disk_free (disk);
 }
 
-#ifndef DISCOVER_ONLY
-static int
-amiga_clobber (PedDevice* dev)
-{
-	struct RigidDiskBlock *rdb;
-	uint32_t i;
-	int result = 0;
-	PED_ASSERT(dev != NULL, return 0);
-
-	if ((rdb=RDSK(ped_malloc(dev->sector_size)))==NULL)
-		return 0;
-
-	while ((i = _amiga_find_rdb (dev, rdb)) != AMIGA_RDB_NOT_FOUND) {
-		rdb->rdb_ID = PED_CPU_TO_BE32 (0);
-		result = ped_device_write (dev, (void*) rdb, i, 1);
-	}
-
-	free (rdb);
-
-	return result;
-}
-#endif /* !DISCOVER_ONLY */
-
 static int
 _amiga_loop_check (uint32_t block, uint32_t * blocklist, uint32_t max)
 {
@@ -1150,7 +1127,7 @@ amiga_get_max_supported_partition_count (const PedDisk* disk, int *max_n)
 PT_define_limit_functions (amiga)
 
 static PedDiskOps amiga_disk_ops = {
-	clobber:		NULL_IF_DISCOVER_ONLY (amiga_clobber),
+	clobber:		NULL,
 	write:			NULL_IF_DISCOVER_ONLY (amiga_write),
 
 	partition_set_name:	amiga_partition_set_name,
diff --git a/libparted/labels/sun.c b/libparted/labels/sun.c
index 0528e2c..9aeddcf 100644
--- a/libparted/labels/sun.c
+++ b/libparted/labels/sun.c
@@ -157,25 +157,6 @@ sun_probe (const PedDevice *dev)
 	return ok;
 }
 
-#ifndef DISCOVER_ONLY
-static int
-sun_clobber (PedDevice* dev)
-{
-	PED_ASSERT (dev != NULL, return 0);
-	PED_ASSERT (sun_probe (dev), return 0);
-
-	void *s0;
-	if (!ptt_read_sector (dev, 0, &s0))
-		return 0;
-
-	SunRawLabel *table = s0;
-	table->magic = 0;
-	int write_ok = ped_device_write (dev, (void*) table, 0, 1);
-	free (s0);
-	return write_ok;
-}
-#endif /* !DISCOVER_ONLY */
-
 static PedDisk*
 sun_alloc (const PedDevice* dev)
 {
@@ -921,7 +902,7 @@ error:
 PT_define_limit_functions (sun)
 
 static PedDiskOps sun_disk_ops = {
-	clobber:		NULL_IF_DISCOVER_ONLY (sun_clobber),
+	clobber:		NULL,
 	write:			NULL_IF_DISCOVER_ONLY (sun_write),
 
 	disk_set_flag:          sun_disk_set_flag,



More information about the Parted-commits mailing list