1 Star 0 Fork 71

Fisher/libvirt-rpm

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Don-t-cache-device-mapper-major.patch 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
imxcc 提交于 2021-09-14 22:17 . Modify some different patch files
From 1c5804926a289882ff4a84f1c6ca6df1dd117215 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Tue, 31 Aug 2021 08:22:41 -0400
Subject: [PATCH] Don't cache device-mapper major
---
src/util/virdevmapper.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
index a471504..2b9e689 100644
--- a/src/util/virdevmapper.c
+++ b/src/util/virdevmapper.c
@@ -46,11 +46,8 @@
G_STATIC_ASSERT(BUF_SIZE > sizeof(struct dm_ioctl));
-static unsigned int virDMMajor;
-
-
static int
-virDevMapperOnceInit(void)
+virDevMapperGetMajor(unsigned int *major)
{
g_autofree char *buf = NULL;
VIR_AUTOSTRINGLIST lines = NULL;
@@ -69,7 +66,7 @@ virDevMapperOnceInit(void)
if (sscanf(lines[i], "%u %ms\n", &maj, &dev) == 2 &&
STREQ(dev, DM_NAME)) {
- virDMMajor = maj;
+ *major = maj;
break;
}
}
@@ -84,10 +81,6 @@ virDevMapperOnceInit(void)
return 0;
}
-
-VIR_ONCE_GLOBAL_INIT(virDevMapper);
-
-
static void *
virDMIoctl(int controlFD, int cmd, struct dm_ioctl *dm, char **buf)
{
@@ -305,9 +298,6 @@ virDevMapperGetTargets(const char *path,
* consist of devices or yet another targets. If that's the
* case, we have to stop recursion somewhere. */
- if (virDevMapperInitialize() < 0)
- return -1;
-
if ((controlFD = virDMOpen()) < 0)
return -1;
@@ -319,13 +309,14 @@ bool
virIsDevMapperDevice(const char *dev_name)
{
struct stat buf;
+ unsigned int major;
- if (virDevMapperInitialize() < 0)
+ if (virDevMapperGetMajor(&major) < 0)
return false;
if (!stat(dev_name, &buf) &&
S_ISBLK(buf.st_mode) &&
- major(buf.st_rdev) == virDMMajor)
+ major(buf.st_rdev) == major)
return true;
return false;
--
2.18.2
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wengyu1/libvirt-rpm.git
git@gitee.com:wengyu1/libvirt-rpm.git
wengyu1
libvirt-rpm
libvirt-rpm
master

搜索帮助