1 Star 0 Fork 28

yanshuai/open-iscsi

forked from src-openEuler/open-iscsi 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0006-fix-default-file-corrupt.patch 1.61 KB
一键复制 编辑 原始数据 按行查看 历史
From 64fe2b6749cb3d53444d9a5663d8e6c852d5aa17 Mon Sep 17 00:00:00 2001
From: openEuler Buildteam <buildteam@openeuler.org>
Date: Wed, 8 Jan 2020 04:13:29 -0500
Subject: [PATCH] iscsi-initiator-utils: fix default file corrupt
---
usr/idbm.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/usr/idbm.c b/usr/idbm.c
index 6309be0..be5f8f9 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -2139,6 +2139,7 @@ static int idbm_rec_write(node_rec_t *rec, bool disable_lock)
struct stat statb;
FILE *f;
char *portal;
+ char *portalDef = NULL;
int rc = 0;
portal = malloc(PATH_MAX);
@@ -2227,7 +2228,7 @@ mkdir_portal:
}
}
- snprintf(portal, PATH_MAX, "%s/%s/%s,%d,%d/%s", NODE_CONFIG_DIR,
+ snprintf(portal, PATH_MAX, "%s/%s/%s,%d,%d/%s_bak", NODE_CONFIG_DIR,
rec->name, rec->conn[0].address, rec->conn[0].port, rec->tpgt,
rec->iface.name);
open_conf:
@@ -2240,6 +2241,28 @@ open_conf:
idbm_print(IDBM_PRINT_TYPE_NODE, rec, 1, f);
fclose(f);
+
+ /* add for default_bak -> default */
+ portalDef = malloc(PATH_MAX);
+ if (!portalDef) {
+ log_error("Could not alloc default\n");
+ rc = ISCSI_ERR_IDBM;
+ goto free_portal;
+ }
+
+ snprintf(portalDef, PATH_MAX, "%s/%s/%s,%d,%d/%s", NODE_CONFIG_DIR,
+ rec->name, rec->conn[0].address, rec->conn[0].port, rec->tpgt,
+ rec->iface.name);
+ /* Renaming default_bak->default. */
+ if (rename(portal, portalDef) < 0) {
+ log_error("Cannot rename %s -> %s\n", portal, portalDef);
+ rc = ISCSI_ERR_IDBM;
+ goto free_portalDef;
+ }
+
+free_portalDef:
+ free(portalDef);
+
unlock:
if (!disable_lock)
idbm_unlock();
--
1.8.3.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yanyan11222/open-iscsi.git
git@gitee.com:yanyan11222/open-iscsi.git
yanyan11222
open-iscsi
open-iscsi
master

搜索帮助