lvm2/0008-dev-type-detect-mixed-dos-partition-with-gpt-s-PMBR.patch

59 lines
1.9 KiB
Diff
Raw Normal View History

From 169430559462d162c6e44157f97126a1e75f1aed Mon Sep 17 00:00:00 2001
From: Peter Rajnoha <prajnoha@redhat.com>
Date: Thu, 3 Oct 2024 09:38:11 +0200
Subject: [PATCH] dev-type: detect mixed dos partition with gpt's PMBR
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Detect when we have mixed dos partition with gpt's PMBR partition.
This is not a sane configuration, but detect it anyway, just in case
someone configures such partition layout manually and forcefully and
incorrectly defines one of the partition types to be the GPT's PMBR.
For example:
fdisk -l /dev/sdc
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 67583 65536 32M 83 Linux
/dev/sdc2 67584 262143 194560 95M ee GPT
Before:
(The partition filter passes even though there's real existing dos
partition - the empty GPT PMBR overrides it.)
pvcreate /dev/sdc
WARNING: PMBR signature detected on /dev/sdc at offset 510. Wipe it? [y/n]:
Wiping PMBR signature on /dev/sdc.
Physical volume "/dev/sdc" successfully created.
With this patch applied:
(The GPT PMBR does not override the existence of the dos partition.)
pvcreate /dev/sdc
Cannot use /dev/sdc: device is partitioned
(cherry picked from commit 317fae4024d9a2a114cf30496500501bdf41ba20)
---
lib/device/dev-type.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index e89ed82c8..e3504e2b7 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -663,7 +663,7 @@ static int _has_partition_table(struct device *dev)
* If this is GPT's PMBR, then also
* check for gpt partition table.
*/
- if (buf.part[p].sys_ind == PART_MSDOS_TYPE_GPT_PMBR)
+ if (buf.part[p].sys_ind == PART_MSDOS_TYPE_GPT_PMBR && !ret)
ret = _has_gpt_partition_table(dev);
else
ret = 1;
--
2.46.2