parted/0040-partprobe-remove-partitions-when-there-is-no-partiti.patch
Brian C. Lane a248769183 - Rebasing Fedora patches with upstream master since v3.1 release
- Summary of important changes from upstream:
  - add support for a new Linux-specific GPT partition type code
  - partprobe: remove partitions when there is no partition table
  - libparted: refactor device-mapper partition sync code
  - libparted: remove extraneous blkpg add partition ped exception
  - libparted: don't probe every dm device in probe_all
- New Fedora changes:
  - libparted: Add Intel Rapid Start Technology partition flag.
  - libparted: Add UEFI System Partition flag.
  - libparted: Add hfs_esp partition flag to GPT.
  - libparted: Recognize btrfs filesystem
  - tests: Add btrfs and xfs to the fs probe test
2013-08-28 13:55:15 -07:00

68 lines
2.0 KiB
Diff

From 05917368a7867a17d6b2e0df16bf54239aa52107 Mon Sep 17 00:00:00 2001
From: Petr Uzel <petr.uzel@suse.cz>
Date: Mon, 15 Oct 2012 10:31:52 +0200
Subject: [PATCH 40/69] partprobe: remove partitions when there is no partition
table
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.
* NEWS (Bug fixes): Mention it.
Addresses: https://bugzilla.novell.com/783419
---
NEWS | 3 +++
partprobe/partprobe.c | 21 ++++++++++++++++-----
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/NEWS b/NEWS
index 4c4716d..293f5e4 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,9 @@ GNU parted NEWS -*- outline -*-
libparted: treat a disk with no pMBR as an msdos-labeled disk
even when it has valid GPT headers.
+ partprobe now tells the kernel to forget about any partitions
+ on a device that has no recognizable partition table.
+
** Changes in behavior
Added new Linux-specific partition GUID type code
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.3.1