1 Star 0 Fork 25

dashnfschina/util-linux

forked from src-anolis-os/util-linux 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0066-libfdisk-fix-fdisk_reread_changes-for-extended-parti.patch 1.62 KB
一键复制 编辑 原始数据 按行查看 历史
From aecaffc55dd763c34f61937b2047f0aaaeb4e6fc Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 6 Aug 2020 11:32:33 +0200
Subject: [PATCH 66/74] libfdisk: fix fdisk_reread_changes() for extended
partitions
Linux kernel assumes only 1KiB extended partition to avoid overlapping
with nested logical partitions. We need to follow this rule for
BLKPG_ADD_PARTITION.
Addresses: https://github.com/karelzak/util-linux/issues/1112
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2041498
Upstream: http://github.com/util-linux/util-linux/commit/33f50706fd7c1c5e53f8f355f12b685c6935f5a4
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libfdisk/src/context.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
index fe7eb9e7e..114101980 100644
--- a/libfdisk/src/context.c
+++ b/libfdisk/src/context.c
@@ -867,10 +867,21 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org)
}
}
for (i = 0; i < nadds; i++) {
+ uint64_t sz;
+
pa = add[i];
+ sz = pa->size * ssf;
+
DBG(PART, ul_debugobj(pa, "#%zu calling BLKPG_ADD_PARTITION", pa->partno));
+
+ if (fdisk_is_label(cxt, DOS) && fdisk_partition_is_container(pa))
+ /* Let's follow the Linux kernel and reduce
+ * DOS extended partition to 1 or 2 sectors.
+ */
+ sz = min(sz, (uint64_t) 2);
+
if (partx_add_partition(cxt->dev_fd, pa->partno + 1,
- pa->start * ssf, pa->size * ssf) != 0) {
+ pa->start * ssf, sz) != 0) {
fdisk_warn(cxt, _("Failed to add partition %zu to system"), pa->partno + 1);
err++;
}
--
2.31.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dashnfschina/util-linux.git
git@gitee.com:dashnfschina/util-linux.git
dashnfschina
util-linux
util-linux
a8

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385