代码拉取完成,页面将自动刷新
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。