!19 update to 2.1.1
From: @markeryang Reviewed-by: @wubo009 Signed-off-by: @wubo009
This commit is contained in:
commit
c46c1560db
@ -1,60 +0,0 @@
|
||||
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,164 +0,0 @@
|
||||
diff -upr sysfsutils-2.1.0-old/lib/sysfs_utils.c sysfsutils-2.1.0/lib/sysfs_utils.c
|
||||
--- sysfsutils-2.1.0-old/lib/sysfs_utils.c 2006-08-07 07:08:01.000000000 +0200
|
||||
+++ sysfsutils-2.1.0/lib/sysfs_utils.c 2008-05-13 07:42:50.000000000 +0200
|
||||
@@ -117,84 +117,104 @@ int sysfs_get_link(const char *path, cha
|
||||
{
|
||||
char devdir[SYSFS_PATH_MAX];
|
||||
char linkpath[SYSFS_PATH_MAX];
|
||||
- char temp_path[SYSFS_PATH_MAX];
|
||||
- char *d = NULL, *s = NULL;
|
||||
- int slashes = 0, count = 0;
|
||||
+ char *d, *s;
|
||||
+ int count;
|
||||
|
||||
if (!path || !target || len == 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
- memset(devdir, 0, SYSFS_PATH_MAX);
|
||||
- memset(linkpath, 0, SYSFS_PATH_MAX);
|
||||
- memset(temp_path, 0, SYSFS_PATH_MAX);
|
||||
- safestrcpy(devdir, path);
|
||||
-
|
||||
- if ((readlink(path, linkpath, SYSFS_PATH_MAX)) < 0) {
|
||||
+ count = readlink(path, linkpath, SYSFS_PATH_MAX);
|
||||
+ if (count < 0)
|
||||
return -1;
|
||||
- }
|
||||
- d = linkpath;
|
||||
+ else
|
||||
+ linkpath[count] = '\0';
|
||||
/*
|
||||
* Three cases here:
|
||||
* 1. relative path => format ../..
|
||||
* 2. absolute path => format /abcd/efgh
|
||||
* 3. relative path _from_ this dir => format abcd/efgh
|
||||
*/
|
||||
- switch (*d) {
|
||||
- case '.':
|
||||
+ if (*linkpath == '/') {
|
||||
+ /* absolute path - copy as is */
|
||||
+ safestrcpymax(target, linkpath, len);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ safestrcpy(devdir, path);
|
||||
+ s = strrchr(devdir, '/');
|
||||
+ if (s == NULL)
|
||||
+ s = devdir - 1;
|
||||
+ d = linkpath;
|
||||
+ while (*d == '.') {
|
||||
+ if (*(d+1) == '/') {
|
||||
/*
|
||||
* handle the case where link is of type ./abcd/xxx
|
||||
*/
|
||||
- safestrcpy(temp_path, devdir);
|
||||
- if (*(d+1) == '/')
|
||||
- d += 2;
|
||||
- else if (*(d+1) == '.')
|
||||
- goto parse_path;
|
||||
- s = strrchr(temp_path, '/');
|
||||
- if (s != NULL) {
|
||||
- *(s+1) = '\0';
|
||||
- safestrcat(temp_path, d);
|
||||
- } else {
|
||||
- safestrcpy(temp_path, d);
|
||||
- }
|
||||
- safestrcpymax(target, temp_path, len);
|
||||
- break;
|
||||
+ d += 2;
|
||||
+ while (*d == '/')
|
||||
+ d++;
|
||||
+ continue;
|
||||
+ } else if (*(d+1) != '.' || *(d+2) != '/')
|
||||
/*
|
||||
- * relative path, getting rid of leading "../.."
|
||||
+ * relative path from this directory, starting
|
||||
+ * with a hidden directory
|
||||
*/
|
||||
-parse_path:
|
||||
- while (*d == '/' || *d == '.') {
|
||||
- if (*d == '/')
|
||||
- slashes++;
|
||||
- d++;
|
||||
- }
|
||||
- d--;
|
||||
- s = &devdir[strlen(devdir)-1];
|
||||
- while (s != NULL && count != (slashes+1)) {
|
||||
+ break;
|
||||
+
|
||||
+ /*
|
||||
+ * relative path, getting rid of leading "../.."; must
|
||||
+ * be careful here since any path component of devdir
|
||||
+ * could be a symlink again
|
||||
+ */
|
||||
+ for (;;) {
|
||||
+ while (s > devdir && *s == '/') {
|
||||
s--;
|
||||
- if (*s == '/')
|
||||
- count++;
|
||||
+ if (*s == '.'
|
||||
+ && (s == devdir || *(s-1) == '/'))
|
||||
+ s--;
|
||||
}
|
||||
- safestrcpymax(s, d, (SYSFS_PATH_MAX-strlen(devdir)));
|
||||
- safestrcpymax(target, devdir, len);
|
||||
- break;
|
||||
- case '/':
|
||||
- /* absolute path - copy as is */
|
||||
- safestrcpymax(target, linkpath, len);
|
||||
- break;
|
||||
- default:
|
||||
- /* relative path from this directory */
|
||||
- safestrcpy(temp_path, devdir);
|
||||
- s = strrchr(temp_path, '/');
|
||||
- if (s != NULL) {
|
||||
- *(s+1) = '\0';
|
||||
- safestrcat(temp_path, linkpath);
|
||||
- } else {
|
||||
- safestrcpy(temp_path, linkpath);
|
||||
+ *(s+1) = '\0';
|
||||
+ if (*devdir == '\0' || sysfs_path_is_link(devdir))
|
||||
+ /*
|
||||
+ * condition will be true eventually
|
||||
+ * because we already know that all
|
||||
+ * but the last component of path
|
||||
+ * resolve to a directory
|
||||
+ */
|
||||
+ break;
|
||||
+ if (sysfs_get_link(devdir, devdir, SYSFS_PATH_MAX))
|
||||
+ return -1;
|
||||
+ s = devdir + strlen(devdir) - 1;
|
||||
+ }
|
||||
+ while (s >= devdir) {
|
||||
+ if (*s == '/') {
|
||||
+ if (*(s+1) != '.' || *(s+2) != '.'
|
||||
+ || *(s+3) != '\0') {
|
||||
+ d += 3;
|
||||
+ while (*d == '/')
|
||||
+ d++;
|
||||
+ } else
|
||||
+ s += 2;
|
||||
+ break;
|
||||
}
|
||||
- safestrcpymax(target, temp_path, len);
|
||||
+ s--;
|
||||
+ }
|
||||
+ if (s < devdir || *(s+1) == '\0')
|
||||
+ break;
|
||||
}
|
||||
+
|
||||
+ /*
|
||||
+ * appending to devdir a slash and the (possibly shortened)
|
||||
+ * relative path to the link source
|
||||
+ */
|
||||
+ s++;
|
||||
+ if (s > devdir && *s == '\0')
|
||||
+ *s++ = '/';
|
||||
+ *s = '\0';
|
||||
+ safestrcpymax(s, d, SYSFS_PATH_MAX-(s-devdir));
|
||||
+ safestrcpymax(target, devdir, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
diff -urpN sysfsutils-2.1.0.orig/systool.1 sysfsutils-2.1.0/systool.1
|
||||
--- sysfsutils-2.1.0.orig/systool.1 2011-03-22 18:15:40.775891943 +0100
|
||||
+++ sysfsutils-2.1.0/systool.1 2011-03-22 18:16:05.158970786 +0100
|
||||
@@ -14,7 +14,7 @@ classes, and root devices.
|
||||
.P
|
||||
When
|
||||
.I device
|
||||
-is supplied, the information reqested by
|
||||
+is supplied, the information requested by
|
||||
.I options
|
||||
is shown only for the specified device, otherwise all present devices
|
||||
are displayed.
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,31 +0,0 @@
|
||||
From bcb67a67348ebe154d6bf2d426e0a0b5c18630be Mon Sep 17 00:00:00 2001
|
||||
From: Huangzheng <huangzheng22@huawei.com>
|
||||
Date: Fri, 10 Jan 2020 16:27:37 +0800
|
||||
Subject: [PATCH] sysfsutils: modify GPL path written in COPYING
|
||||
|
||||
Openeuler has packaged the GPL and LGPL into usr/share/licenses/sysfsutils,
|
||||
so we need modify COPYING file.
|
||||
|
||||
Signed-off-by: Huangzheng <huangzheng22@huawei.com>
|
||||
---
|
||||
COPYING | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/COPYING b/COPYING
|
||||
index 39cac23..c0b5638 100644
|
||||
--- a/COPYING
|
||||
+++ b/COPYING
|
||||
@@ -3,9 +3,9 @@ The commands and utilities under the "test" directory are licensed under the
|
||||
GNU General Public License (GPL) Version 2, June 1991. The full text of the
|
||||
GPL is located at:
|
||||
|
||||
-sysfsutils/cmd/GPL
|
||||
+/usr/share/licenses/sysfsutils/GPL
|
||||
|
||||
The sysfs library is licensed under the GNU Lesser Public License (LGPL)
|
||||
Version 2.1, February 1999. The full text of the LGPL is located at:
|
||||
|
||||
-sysfsutils/lib/LGPL
|
||||
+/usr/share/licenses/sysfsutils/LGPL
|
||||
--
|
||||
2.19.1
|
||||
@ -1,28 +0,0 @@
|
||||
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
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
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
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
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
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
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
|
||||
|
||||
Binary file not shown.
@ -1,23 +1,14 @@
|
||||
Name: sysfsutils
|
||||
Version: 2.1.0
|
||||
Release: 32
|
||||
Version: 2.1.1
|
||||
Release: 1
|
||||
Summary: A set of utilities for interfacing with sysfs
|
||||
License: GPLv2 and LGPLv2+
|
||||
URL: http://sourceforge.net/projects/linux-diag/
|
||||
URL: https://github.com/linux-ras/sysfsutils
|
||||
|
||||
Source0: http://prdownloads.sourceforge.net/linux-diag/%{name}-%{version}.tar.gz
|
||||
Source0: https://github.com/linux-ras/sysfsutils/archive/v%{version}.tar.gz
|
||||
|
||||
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: gcc chrpath
|
||||
BuildRequires: gcc chrpath autoconf automake make libtool
|
||||
Provides: libsysfs libsysfs%{?_isa}
|
||||
Obsoletes: libsysfs
|
||||
|
||||
@ -50,6 +41,7 @@ This contains man files for the using of sysfsutils.
|
||||
%autosetup -n %{name}-%{version} -p1
|
||||
|
||||
%build
|
||||
./autogen
|
||||
%configure --disable-static --libdir=/%{_lib}
|
||||
%make_build
|
||||
|
||||
@ -71,9 +63,8 @@ chrpath -d $(find $RPM_BUILD_ROOT -name systool)
|
||||
|
||||
%files
|
||||
%license COPYING cmd/GPL lib/LGPL
|
||||
%doc README NEWS ChangeLog
|
||||
%doc README
|
||||
%{_bindir}/systool
|
||||
%{_bindir}/get_module
|
||||
/%{_lib}/libsysfs.so.*
|
||||
|
||||
%files devel
|
||||
@ -81,6 +72,7 @@ chrpath -d $(find $RPM_BUILD_ROOT -name systool)
|
||||
%{_includedir}/sysfs/libsysfs.h
|
||||
%{_includedir}/sysfs/dlist.h
|
||||
/%{_lib}/libsysfs.so
|
||||
/%{_lib}/pkgconfig/libsysfs.pc
|
||||
|
||||
%files help
|
||||
%{_mandir}/man1/systool.1.gz
|
||||
@ -88,6 +80,9 @@ chrpath -d $(find $RPM_BUILD_ROOT -name systool)
|
||||
|
||||
|
||||
%changelog
|
||||
* Thu Nov 25 2021 yanglongkang <yanglongkang@huawei.com> - 2.1.1-1
|
||||
- update to 2.1.1
|
||||
|
||||
* Fri Jul 30 2021 chenyanpanHW <chenyanpan@huawei.com> - 2.1.0-32
|
||||
- DESC: delete -S git from %autosetup, and delete BuildRequires git
|
||||
|
||||
|
||||
BIN
v2.1.1.tar.gz
Normal file
BIN
v2.1.1.tar.gz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user