15 Star 2 Fork 56

src-openEuler/util-linux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-lsmem-make-lsmem-to-check-for-the-nodes-more-robust.patch 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
zhangyao2022 提交于 2024-11-15 16:22 . sync patches from the old version
From 57714290bdc99cab533edbc4a021d6ee3a7cc211 Mon Sep 17 00:00:00 2001
From: zhangyao <zhangyao108@huawei.com>
Date: Thu, 4 Jul 2024 16:28:51 +0800
Subject: [PATCH] lsmem: make lsmem to check for the nodes more robust
See #3110.
Reference:https://github.com/util-linux/util-linux/commit/57714290bdc99cab533edbc4a021d6ee3a7cc211
Conflict:NA
---
sys-utils/lsmem.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/sys-utils/lsmem.c b/sys-utils/lsmem.c
index 3b5ca19a0..7c1be8e83 100644
--- a/sys-utils/lsmem.c
+++ b/sys-utils/lsmem.c
@@ -485,6 +485,7 @@ static int memory_block_filter(const struct dirent *de)
static void read_basic_info(struct lsmem *lsmem)
{
char dir[PATH_MAX];
+ int i = 0;
if (ul_path_access(lsmem->sysmem, F_OK, "block_size_bytes") != 0)
errx(EXIT_FAILURE, _("This system does not support memory blocks"));
@@ -495,8 +496,14 @@ static void read_basic_info(struct lsmem *lsmem)
if (lsmem->ndirs <= 0)
err(EXIT_FAILURE, _("Failed to read %s"), dir);
- if (memory_block_get_node(lsmem, lsmem->dirs[0]->d_name) != -1)
- lsmem->have_nodes = 1;
+ for (i = 0; i < lsmem->ndirs; i++)
+ {
+ if (memory_block_get_node(lsmem, lsmem->dirs[i]->d_name) != -1)
+ {
+ lsmem->have_nodes = 1;
+ break;
+ }
+ }
/* The valid_zones sysmem attribute was introduced with kernel 3.18 */
if (ul_path_access(lsmem->sysmem, F_OK, "memory0/valid_zones") == 0)
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/util-linux.git
git@gitee.com:src-openeuler/util-linux.git
src-openeuler
util-linux
util-linux
master

搜索帮助