|
|
e377cc |
From aecaffc55dd763c34f61937b2047f0aaaeb4e6fc Mon Sep 17 00:00:00 2001
|
|
|
e377cc |
From: Karel Zak <kzak@redhat.com>
|
|
|
e377cc |
Date: Thu, 6 Aug 2020 11:32:33 +0200
|
|
|
e377cc |
Subject: [PATCH 66/74] libfdisk: fix fdisk_reread_changes() for extended
|
|
|
e377cc |
partitions
|
|
|
e377cc |
|
|
|
e377cc |
Linux kernel assumes only 1KiB extended partition to avoid overlapping
|
|
|
e377cc |
with nested logical partitions. We need to follow this rule for
|
|
|
e377cc |
BLKPG_ADD_PARTITION.
|
|
|
e377cc |
|
|
|
e377cc |
Addresses: https://github.com/karelzak/util-linux/issues/1112
|
|
|
e377cc |
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2041498
|
|
|
e377cc |
Upstream: http://github.com/util-linux/util-linux/commit/33f50706fd7c1c5e53f8f355f12b685c6935f5a4
|
|
|
e377cc |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
e377cc |
---
|
|
|
e377cc |
libfdisk/src/context.c | 13 ++++++++++++-
|
|
|
e377cc |
1 file changed, 12 insertions(+), 1 deletion(-)
|
|
|
e377cc |
|
|
|
e377cc |
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
|
|
|
e377cc |
index fe7eb9e7e..114101980 100644
|
|
|
e377cc |
--- a/libfdisk/src/context.c
|
|
|
e377cc |
+++ b/libfdisk/src/context.c
|
|
|
e377cc |
@@ -867,10 +867,21 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org)
|
|
|
e377cc |
}
|
|
|
e377cc |
}
|
|
|
e377cc |
for (i = 0; i < nadds; i++) {
|
|
|
e377cc |
+ uint64_t sz;
|
|
|
e377cc |
+
|
|
|
e377cc |
pa = add[i];
|
|
|
e377cc |
+ sz = pa->size * ssf;
|
|
|
e377cc |
+
|
|
|
e377cc |
DBG(PART, ul_debugobj(pa, "#%zu calling BLKPG_ADD_PARTITION", pa->partno));
|
|
|
e377cc |
+
|
|
|
e377cc |
+ if (fdisk_is_label(cxt, DOS) && fdisk_partition_is_container(pa))
|
|
|
e377cc |
+ /* Let's follow the Linux kernel and reduce
|
|
|
e377cc |
+ * DOS extended partition to 1 or 2 sectors.
|
|
|
e377cc |
+ */
|
|
|
e377cc |
+ sz = min(sz, (uint64_t) 2);
|
|
|
e377cc |
+
|
|
|
e377cc |
if (partx_add_partition(cxt->dev_fd, pa->partno + 1,
|
|
|
e377cc |
- pa->start * ssf, pa->size * ssf) != 0) {
|
|
|
e377cc |
+ pa->start * ssf, sz) != 0) {
|
|
|
e377cc |
fdisk_warn(cxt, _("Failed to add partition %zu to system"), pa->partno + 1);
|
|
|
e377cc |
err++;
|
|
|
e377cc |
}
|
|
|
e377cc |
--
|
|
|
e377cc |
2.31.1
|
|
|
e377cc |
|