代码拉取完成,页面将自动刷新
From 9b59641bcec3df9c451eea4c7057751a153a3fcb Mon Sep 17 00:00:00 2001
From: Portisch <hugo.portisch@yahoo.de>
Date: Mon, 8 Nov 2021 12:31:39 +0100
Subject: [PATCH] sysfs: fallback for partitions not including parent name
---
lib/sysfs.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/lib/sysfs.c b/lib/sysfs.c
index bb71833193..191d870f66 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -210,9 +210,10 @@ int sysfs_blkdev_is_partition_dirent(DIR *dir, struct dirent *d, const char *par
d->d_type != DT_UNKNOWN)
return 0;
#endif
+ size_t len = 0;
+
if (parent_name) {
const char *p = parent_name;
- size_t len;
/* /dev/sda --> "sda" */
if (*parent_name == '/') {
@@ -223,14 +224,15 @@ int sysfs_blkdev_is_partition_dirent(DIR *dir, struct dirent *d, const char *par
}
len = strlen(p);
- if (strlen(d->d_name) <= len)
- return 0;
+ if ((strlen(d->d_name) <= len) || (strncmp(p, d->d_name, len) != 0))
+ len = 0;
+ }
+ if (len > 0) {
/* partitions subdir name is
* "<parent>[:digit:]" or "<parent>p[:digit:]"
*/
- return strncmp(p, d->d_name, len) == 0 &&
- ((*(d->d_name + len) == 'p' && isdigit(*(d->d_name + len + 1)))
+ return ((*(d->d_name + len) == 'p' && isdigit(*(d->d_name + len + 1)))
|| isdigit(*(d->d_name + len)));
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。