!11 sysfsutils: backport upstream bugfix patches-epoch1
Merge pull request !11 from liuzhiqiang/master
This commit is contained in:
commit
3fdfb3e928
60
0001-Fix-issue-with-sysfs-name-comparisons.patch
Normal file
60
0001-Fix-issue-with-sysfs-name-comparisons.patch
Normal file
@ -0,0 +1,60 @@
|
||||
From 744befa9faa3446ff6bf0627cadb6a3addae1dd1 Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Fri, 3 Jul 2020 11:14:20 -0700
|
||||
Subject: [PATCH 1/9] Fix issue with sysfs name comparisons.
|
||||
|
||||
It turns out that cdev_name_equal() is used
|
||||
by dlist_find_custom() to compare sysfs
|
||||
entry names to ones already seen. But it was
|
||||
comparing using the length of the shortest string
|
||||
as a maximum, so when it compared, for example,
|
||||
"eth1" and "eth10", it thought they were the same.
|
||||
So now just return failure if the strings
|
||||
aren't the same length, else go ahead and
|
||||
compare them.
|
||||
|
||||
Signed-off-by: Lee Duncan <lduncan@suse.com>
|
||||
---
|
||||
lib/sysfs_class.c | 21 +++++++++++++++++++--
|
||||
1 file changed, 19 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/sysfs_class.c b/lib/sysfs_class.c
|
||||
index 4fe0b82..c696ff0 100644
|
||||
--- a/lib/sysfs_class.c
|
||||
+++ b/lib/sysfs_class.c
|
||||
@@ -60,13 +60,30 @@ void sysfs_close_class(struct sysfs_class *cls)
|
||||
}
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * pass this function to dlist_find_custom()
|
||||
+ * so it can compare device names
|
||||
+ *
|
||||
+ * return 1 if pathnames are equal, else 0
|
||||
+ */
|
||||
static int cdev_name_equal(void *a, void *b)
|
||||
{
|
||||
+ size_t length_a, length_b;
|
||||
+ char *str_a, *str_b;
|
||||
+
|
||||
if (!a || !b)
|
||||
return 0;
|
||||
|
||||
- if (strncmp((char *)a, ((struct sysfs_class_device *)b)->name,
|
||||
- strlen((char *)a)) == 0)
|
||||
+ str_a = (char *)a;
|
||||
+ str_b = ((struct sysfs_class_device *)b)->name;
|
||||
+
|
||||
+ length_a = strnlen(str_a, SYSFS_NAME_LEN+1);
|
||||
+ length_b = strnlen(str_b, SYSFS_NAME_LEN+1);
|
||||
+
|
||||
+ if (length_a != length_b)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (strncmp(str_a, str_b, SYSFS_NAME_LEN+1) == 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
diff -puN lib/sysfs_class.c~sysfsutils_class_dup lib/sysfs_class.c
|
||||
--- sysfsutils-2.1.0/lib/sysfs_class.c~sysfsutils_class_dup 2006-09-07 17:01:26.000000000 -0500
|
||||
+++ sysfsutils-2.1.0-bjking1/lib/sysfs_class.c 2006-09-07 17:01:26.000000000 -0500
|
||||
@@ -66,7 +66,7 @@ static int cdev_name_equal(void *a, void
|
||||
return 0;
|
||||
|
||||
if (strncmp((char *)a, ((struct sysfs_class_device *)b)->name,
|
||||
- strlen((char *)a)) == 0)
|
||||
+ SYSFS_NAME_LEN) == 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
28
0006-fix-of-FUNC_TABLE_SIZE-mentioned-in-prev-commit.patch
Normal file
28
0006-fix-of-FUNC_TABLE_SIZE-mentioned-in-prev-commit.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From 8c4c03717d6b9690d5adc70968a14819dc9a36e9 Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Wed, 26 Feb 2020 09:16:32 -0800
|
||||
Subject: [PATCH 6/9] fix of FUNC_TABLE_SIZE mentioned in prev commit
|
||||
|
||||
fix of FUNC_TABLE_SIZE mentioned in prev commit.
|
||||
|
||||
Signed-off-by: Lee Duncan <lduncan@suse.com>
|
||||
---
|
||||
test/test-defs.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/test/test-defs.h b/test/test-defs.h
|
||||
index b22909a..28af1a5 100644
|
||||
--- a/test/test-defs.h
|
||||
+++ b/test/test-defs.h
|
||||
@@ -40,7 +40,7 @@
|
||||
#define val_drv1_attr_name "dummy2"
|
||||
#define inval_name "invalid_name"
|
||||
#define inval_path "/sys/invalid/path"
|
||||
-#define FUNC_TABLE_SIZE (sizeof(func_table)/sizeof(int))
|
||||
+#define FUNC_TABLE_SIZE (sizeof(func_table) / sizeof(void *))
|
||||
|
||||
FILE *my_stdout;
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
From 049f2664ce29bd11c07894bbdef51b8d610b1d12 Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Wed, 24 Jun 2020 11:07:53 -0700
|
||||
Subject: [PATCH 7/9] Fix compiler complain about multiple defs of my_stdout.
|
||||
|
||||
A simple fix: define it in one place, refer to it
|
||||
elsewhere.
|
||||
|
||||
Signed-off-by: Lee Duncan <lduncan@suse.com>
|
||||
---
|
||||
test/test-defs.h | 2 +-
|
||||
test/test.c | 2 ++
|
||||
2 files changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/test/test-defs.h b/test/test-defs.h
|
||||
index 28af1a5..3378373 100644
|
||||
--- a/test/test-defs.h
|
||||
+++ b/test/test-defs.h
|
||||
@@ -42,7 +42,7 @@
|
||||
#define inval_path "/sys/invalid/path"
|
||||
#define FUNC_TABLE_SIZE (sizeof(func_table) / sizeof(void *))
|
||||
|
||||
-FILE *my_stdout;
|
||||
+extern FILE *my_stdout;
|
||||
|
||||
#define dbg_print(format, arg...) fprintf(my_stdout, format, ## arg)
|
||||
|
||||
diff --git a/test/test.c b/test/test.c
|
||||
index 2e8f201..f63e346 100644
|
||||
--- a/test/test.c
|
||||
+++ b/test/test.c
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "test-defs.h"
|
||||
#include <errno.h>
|
||||
|
||||
+FILE *my_stdout;
|
||||
+
|
||||
/*************************************************/
|
||||
char *function_name[] = {
|
||||
"sysfs_get_mnt_path",
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
29
0008-Use-stat-not-lstat-to-find-link-target.patch
Normal file
29
0008-Use-stat-not-lstat-to-find-link-target.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From e92be090a8a82c679a65bc0c885e259c3c64cc51 Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Thu, 25 Jun 2020 10:04:40 -0700
|
||||
Subject: [PATCH 8/9] Use stat() not lstat() to find link target.
|
||||
|
||||
The test was backwards? We are trying to find what the
|
||||
link points at, not info about the link.
|
||||
|
||||
Signed-off-by: Lee Duncan <lduncan@suse.com>
|
||||
---
|
||||
test/test.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/test/test.c b/test/test.c
|
||||
index f63e346..aea34c1 100644
|
||||
--- a/test/test.c
|
||||
+++ b/test/test.c
|
||||
@@ -165,7 +165,7 @@ static int path_is_dir(const char *path)
|
||||
{
|
||||
struct stat astats;
|
||||
|
||||
- if ((lstat(path, &astats)) != 0)
|
||||
+ if ((stat(path, &astats)) != 0)
|
||||
goto direrr;
|
||||
|
||||
if (S_ISDIR(astats.st_mode))
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
25
0009-path_is_file-should-call-stat-not-lstat.patch
Normal file
25
0009-path_is_file-should-call-stat-not-lstat.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From b7d5488a0a7b392842ae7ff988a6615eab32a95e Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Mon, 29 Jun 2020 10:11:02 -0700
|
||||
Subject: [PATCH 9/9] path_is_file() should call stat(), not lstat()
|
||||
|
||||
---
|
||||
lib/sysfs_utils.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/sysfs_utils.c b/lib/sysfs_utils.c
|
||||
index 4fa10f7..0257ffa 100644
|
||||
--- a/lib/sysfs_utils.c
|
||||
+++ b/lib/sysfs_utils.c
|
||||
@@ -293,7 +293,7 @@ int sysfs_path_is_link(const char *path)
|
||||
errno = EINVAL;
|
||||
return 1;
|
||||
}
|
||||
- if ((lstat(path, &astats)) != 0) {
|
||||
+ if ((stat(path, &astats)) != 0) {
|
||||
dprintf("stat() failed\n");
|
||||
return 1;
|
||||
}
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
Name: sysfsutils
|
||||
Version: 2.1.0
|
||||
Release: 29
|
||||
Release: 30
|
||||
Summary: A set of utilities for interfacing with sysfs
|
||||
License: GPLv2 and LGPLv2+
|
||||
URL: http://sourceforge.net/projects/linux-diag/
|
||||
|
||||
Source0: http://prdownloads.sourceforge.net/linux-diag/%{name}-%{version}.tar.gz
|
||||
|
||||
Patch1: 0001-sysfsutils-2.0.0-class-dup.patch
|
||||
Patch1: 0001-Fix-issue-with-sysfs-name-comparisons.patch
|
||||
Patch2: 0002-sysfsutils-2.1.0-get_link.patch
|
||||
Patch3: 0003-sysfsutils-2.1.0-manpages.patch
|
||||
Patch4: 0004-sysfsutils-aarch64.patch
|
||||
Patch5: 0005-sysutils-modify-GPL-path-written-in-COPYING.patch
|
||||
Patch6: 0006-fix-of-FUNC_TABLE_SIZE-mentioned-in-prev-commit.patch
|
||||
Patch7: 0007-Fix-compiler-complain-about-multiple-defs-of-my_stdo.patch
|
||||
Patch8: 0008-Use-stat-not-lstat-to-find-link-target.patch
|
||||
Patch9: 0009-path_is_file-should-call-stat-not-lstat.patch
|
||||
|
||||
BuildRequires: git gcc chrpath
|
||||
Provides: libsysfs libsysfs%{?_isa}
|
||||
@ -81,6 +85,9 @@ chrpath -d $(find $RPM_BUILD_ROOT -name systool)
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Jul 13 2020 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 2.1.0-30
|
||||
- backport upstream bugfix patches
|
||||
|
||||
* Tue Jun 30 2020 volcanodragon <linfeilong@huawei.com> - 2.1.0-29
|
||||
- Type:enhancemnet
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user