1 Star 0 Fork 25

Wieder/parted

forked from src-openEuler/parted 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0002-Add-extra-judgment-for-a-partition-created-success.patch 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
liuzhiqiang 提交于 2020-06-29 23:11 . parted: renumber patches
From c6c56f6510257a04013f24d63ba6755cadb176bd Mon Sep 17 00:00:00 2001
From: linyan <linyanly.lin@huawei.com>
Date: Fri, 25 Jan 2019 16:13:20 +0000
Subject: [PATCH] Add extra judgment for a partition created success and solve
the problem that parted races with systemd-udevd.
---
libparted/arch/linux.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index ec61b11..8fda092 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2530,6 +2530,25 @@ _blkpg_part_command (PedDevice* dev, struct blkpg_partition* part, int op)
return ioctl (arch_specific->fd, BLKPG, &ioctl_arg) == 0;
}
+static int _add_partition_succ(char *devname)
+{
+ int part_fd = -1;
+ int succ = 0;
+ unsigned size;
+ uint64_t bytes=0;
+
+ part_fd = open(devname, RD_MODE);
+
+ if (part_fd != -1) {
+ if(ioctl(part_fd, BLKGETSIZE64, &bytes) == 0 || ioctl (part_fd, BLKGETSIZE, &size) == 0) {
+ succ = 1;
+ }
+ close(part_fd);
+ }
+
+ return succ;
+}
+
static int
_blkpg_add_partition (PedDisk* disk, const PedPartition *part)
{
@@ -2580,6 +2599,8 @@ _blkpg_add_partition (PedDisk* disk, const PedPartition *part)
if (!_blkpg_part_command (disk->dev, &linux_part,
BLKPG_ADD_PARTITION)) {
+ if (_add_partition_succ(linux_part.devname))
+ return 1;
return 0;
}
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wieder/parted.git
git@gitee.com:wieder/parted.git
wieder
parted
parted
master

搜索帮助