[parted-devel] [PATCH 3/6] partprobe: remove partitions when there is no PT
Jim Meyering
jim at meyering.net
Mon Oct 15 14:49:46 UTC 2012
Petr Uzel wrote:
> When partprobe does not detect any partition table on the device,
> it should tell kernel to drop partitions on that device, but it
> does not. Fix it.
>
> * parted/partprobe.c (process_dev): Drop partitions even if no
> partition table has been detected on the disk.
>
> Addresses: https://bugzilla.novell.com/783419
>
> Signed-off-by: Petr Uzel <petr.uzel at suse.cz>
Thanks for the patch.
I appreciate the BZ reference.
Normally I would require a test case addition, but
since this is partprobe (which these days is rarely needed)
it's probably not worth the trouble.
I like the separate summary and ChangeLog entry, but found the
ChangeLog entry to be a near duplicate of the summary, so converted
it to be a little more implementation-related.
>From 27a662a2ed80546988ba7f31814bf7c3ba925213 Mon Sep 17 00:00:00 2001
From: Petr Uzel <petr.uzel at suse.cz>
Date: Mon, 15 Oct 2012 10:31:52 +0200
Subject: [PATCH] partprobe: remove partitions when there is no PT
When partprobe detects no partition table on a device, it should
tell the kernel to drop partitions on that device, but it did not.
* parted/partprobe.c (process_dev): When ped_disk_probe fails,
create a dummy (empty) partition table and use that.
Addresses: https://bugzilla.novell.com/783419
---
partprobe/partprobe.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/partprobe/partprobe.c b/partprobe/partprobe.c
index b8dca5e..0919d3f 100644
--- a/partprobe/partprobe.c
+++ b/partprobe/partprobe.c
@@ -106,12 +106,23 @@ process_dev (PedDevice* dev)
PedDisk* disk;
disk_type = ped_disk_probe (dev);
- if (!disk_type || !strcmp (disk_type->name, "loop"))
+ if (disk_type && !strcmp (disk_type->name, "loop"))
return 1;
-
- disk = ped_disk_new (dev);
- if (!disk)
- goto error;
+ else if (!disk_type) {
+ /* Partition table not found, so create dummy,
+ empty one */
+ disk_type = ped_disk_type_get("msdos");
+ if (!disk_type)
+ goto error;
+
+ disk = ped_disk_new_fresh (dev, disk_type);
+ if (!disk)
+ goto error_destroy_disk;
+ } else {
+ disk = ped_disk_new (dev);
+ if (!disk)
+ goto error;
+ }
if (!opt_no_inform) {
if (!ped_disk_commit_to_os (disk))
goto error_destroy_disk;
--
1.8.0.rc2
More information about the parted-devel
mailing list