1 Star 0 Fork 26

赵旦/parted

forked from src-openEuler/parted 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
9000-Add-extra-judgment-for-a-partition-created-success.patch 1.54 KB
Copy Edit Raw Blame History
eulerstorage authored 2020-01-11 11:08 . update package from 3.2 to 3.3
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dan_zhao/parted.git
git@gitee.com:dan_zhao/parted.git
dan_zhao
parted
parted
master

Search