Dominique Leuenberger 2020-06-30 19:53:12 +00:00 committed by Git OBS Bridge
commit 9e64ea62d2
10 changed files with 277 additions and 16019 deletions

View File

@ -0,0 +1,41 @@
From 65381221fca3a4bba17bd54054ad542a64ee3899 Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Wed, 24 Jun 2020 11:07:53 -0700
Subject: [PATCH 1/6] Fix compiler complain about multiple defs of my_stdout.
A simple fix: define it in one place, refer to it
elsewhere.
---
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 28af1a5521c1..3378373db2e2 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 74db894ee19c..ab2397d1c847 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",
--
2.26.2

View File

@ -0,0 +1,90 @@
From 904296fbead9abe3369c3e455cd5cbf8c03419eb Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Wed, 24 Jun 2020 11:09:30 -0700
Subject: [PATCH 2/6] Fix compiler complaint about string truncation.
The compiler didn't like having to my_strncat()s defined,
so define it in one place, and refer to it elsewhere.
The string copying in this is still kind of crazy, but
it seems to work, and if the compiler can be happy,
so can I.
---
cmd/systool.c | 12 +-----------
lib/sysfs.h | 12 +-----------
lib/sysfs_utils.c | 16 ++++++++++++++++
3 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/cmd/systool.c b/cmd/systool.c
index e273e6bf92ec..45ed36db1d54 100644
--- a/cmd/systool.c
+++ b/cmd/systool.c
@@ -32,17 +32,7 @@
#include "libsysfs.h"
#include "names.h"
-inline void my_strncpy(char *to, const char *from, size_t max)
-{
- size_t i;
-
- for (i = 0; i < max && from[i] != '\0'; i++)
- to[i] = from[i];
- if (i < max)
- to[i] = '\0';
- else
- to[max-1] = '\0';
-}
+extern char *my_strncpy(char *to, const char *from, size_t max);
#define safestrcpy(to, from) my_strncpy(to, from, sizeof(to))
#define safestrcpymax(to, from, max) my_strncpy(to, from, max)
diff --git a/lib/sysfs.h b/lib/sysfs.h
index ec9ba36b6eed..481c1e9b7cf2 100644
--- a/lib/sysfs.h
+++ b/lib/sysfs.h
@@ -33,17 +33,7 @@
#include <fcntl.h>
#include <errno.h>
-inline void my_strncpy(char *to, const char *from, size_t max)
-{
- size_t i;
-
- for (i = 0; i < max && from[i] != '\0'; i++)
- to[i] = from[i];
- if (i < max)
- to[i] = '\0';
- else
- to[max-1] = '\0';
-}
+extern char *my_strncpy(char *to, const char *from, size_t max);
#define safestrcpy(to, from) my_strncpy(to, from, sizeof(to))
#define safestrcpymax(to, from, max) my_strncpy(to, from, max)
diff --git a/lib/sysfs_utils.c b/lib/sysfs_utils.c
index 9ca207c7f1f0..43df36fb972c 100644
--- a/lib/sysfs_utils.c
+++ b/lib/sysfs_utils.c
@@ -305,3 +305,19 @@ int sysfs_path_is_file(const char *path)
return 1;
}
+
+/**
+ * my_strncpy -- a safe strncpy
+ */
+char *my_strncpy(char *to, const char *from, size_t max)
+{
+ size_t i;
+
+ for (i = 0; i < max && from[i] != '\0'; i++)
+ to[i] = from[i];
+ if (i < max)
+ to[i] = '\0';
+ else
+ to[max-1] = '\0';
+ return to;
+}
--
2.26.2

View File

@ -0,0 +1,98 @@
From 0719881cad85f837f039ecb378b823306640902a Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
Date: Thu, 25 Jun 2020 08:05:18 -0700
Subject: [PATCH 3/6] Fix more string issues for gcc-10
These issues only surfaced for 64-bit PPC and for s390, having
to do with the home-grown strncat() the code was using, which
was just a macro.
---
cmd/systool.c | 3 ++-
lib/sysfs.h | 3 ++-
lib/sysfs_utils.c | 29 +++++++++++++++++++----------
3 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/cmd/systool.c b/cmd/systool.c
index 45ed36db1d54..f4060f57a6ca 100644
--- a/cmd/systool.c
+++ b/cmd/systool.c
@@ -36,7 +36,8 @@ extern char *my_strncpy(char *to, const char *from, size_t max);
#define safestrcpy(to, from) my_strncpy(to, from, sizeof(to))
#define safestrcpymax(to, from, max) my_strncpy(to, from, max)
-#define safestrcat(to, from) strncat(to, from, sizeof(to) - strlen(to)-1)
+extern char *my_strncat(char *to, const char *from, size_t max);
+#define safestrcat(to, from) my_strncat(to, from, sizeof(to) - strlen(to) - 1)
#define safestrcatmax(to, from, max) \
do { \
diff --git a/lib/sysfs.h b/lib/sysfs.h
index 481c1e9b7cf2..a9c14317ec4c 100644
--- a/lib/sysfs.h
+++ b/lib/sysfs.h
@@ -37,7 +37,8 @@ extern char *my_strncpy(char *to, const char *from, size_t max);
#define safestrcpy(to, from) my_strncpy(to, from, sizeof(to))
#define safestrcpymax(to, from, max) my_strncpy(to, from, max)
-#define safestrcat(to, from) strncat(to, from, sizeof(to) - strlen(to)-1)
+extern char *my_strncat(char *to, const char *from, size_t max);
+#define safestrcat(to, from) my_strncat(to, from, sizeof(to) - strlen(to) - 1)
#define safestrcatmax(to, from, max) \
do { \
diff --git a/lib/sysfs_utils.c b/lib/sysfs_utils.c
index 43df36fb972c..bd6f9c1b082b 100644
--- a/lib/sysfs_utils.c
+++ b/lib/sysfs_utils.c
@@ -152,12 +152,10 @@ int sysfs_get_link(const char *path, char *target, size_t len)
else if (*(d+1) == '.')
goto parse_path;
s = strrchr(temp_path, '/');
- if (s != NULL) {
- *(s+1) = '\0';
- safestrcat(temp_path, d);
- } else {
+ if (s != NULL)
+ safestrcpy(s+1, d);
+ else
safestrcpy(temp_path, d);
- }
safestrcpymax(target, temp_path, len);
break;
/*
@@ -187,12 +185,10 @@ parse_path:
/* relative path from this directory */
safestrcpy(temp_path, devdir);
s = strrchr(temp_path, '/');
- if (s != NULL) {
- *(s+1) = '\0';
- safestrcat(temp_path, linkpath);
- } else {
+ if (s != NULL)
+ safestrcpy(s+1, linkpath);
+ else
safestrcpy(temp_path, linkpath);
- }
safestrcpymax(target, temp_path, len);
}
return 0;
@@ -321,3 +317,16 @@ char *my_strncpy(char *to, const char *from, size_t max)
to[max-1] = '\0';
return to;
}
+
+/**
+ * my_strncpy -- a safe strncpy
+ */
+char *my_strncat(char *to, const char *from, size_t max)
+{
+ size_t i = 0;
+
+ while (i < max && to[i] != '\0')
+ i++;
+ my_strncpy(to+i, from, max-i);
+ return to;
+}
--
2.26.2

13
_service Normal file
View File

@ -0,0 +1,13 @@
<services>
<service name="download_url" mode="disabled">
<param name="protocol">https</param>
<param name="host">github.com</param>
<param name="filename">sysfsutils-sysfsutils-2_1_0.tar.gz</param>
<param name="path">linux-ras/sysfsutils/archive/sysfsutils-2_1_0.tar.gz</param>
</service>
<service name="verify_file" mode="disabled">
<param name="file">sysfsutils-sysfsutils-2_1_0.tar.gz</param>
<param name="verifier">sha256</param>
<param name="checksum">035cd517c2465fa86e4f82d035ae5817d9a8b23ba2ba42fe623eb36d3d9b973f</param>
</service>
</services>

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:65c7258f3c006f07078506c227acb94c2c4e451eab7cce7095e9e2cf283fd1de
size 1071810

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:94bed9464795c88c2ebc1a238d6f0975c5cdd43f7b096e38bbf67ad4902dedbb
size 93372

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:035cd517c2465fa86e4f82d035ae5817d9a8b23ba2ba42fe623eb36d3d9b973f
size 398079

View File

@ -1,3 +1,22 @@
-------------------------------------------------------------------
Sun Jun 28 21:15:38 UTC 2020 - Lee Duncan <lduncan@suse.com>
- Added a _service file, as per new OBS requirement
- Added a patch to bring sysfsutils up to latest upstream, which
now is in place:
* sysfsutils-latest-changes.diff.gz
- Added patches which have been submitted upstream but not yet
merged:
* 0001-Fix-compiler-complain-about-multiple-defs-of-my_stdo.patch
* 0002-Fix-compiler-complaint-about-string-truncation.patch
* 0003-Fix-more-string-issues-for-gcc-10.patch
And removing a patch that's subsumed by the above patches:
* sysfsutils-fix-compiler-issues.patch
Lastly, replaced the hand-rolled sysfsutils-2.1.0.tar.gz with
upstream archive file sysfsutils-sysfsutils-2_1_0.tar.gz
(retreived with OBS download service), though the contents
of the two are the same.
-------------------------------------------------------------------
Mon Apr 27 19:28:46 UTC 2020 - Martin Liška <mliska@suse.cz>

View File

@ -22,10 +22,13 @@ License: LGPL-2.1-or-later
Group: System/Libraries
Version: 2.1.0
Release: 0
URL: http://linux-diag.sourceforge.net
Source: http://aleron.dl.sourceforge.net/sourceforge/linux-diag/%{name}-%{version}.tar.gz
URL: https://github.com/linux-ras/sysfsutils
Source: %{name}-sysfsutils-2_1_0.tar.gz
Source2: baselibs.conf
Patch1: %{name}-fix-compiler-issues.patch
Patch1: sysfsutils-latest-changes.diff.gz
Patch2: 0001-Fix-compiler-complain-about-multiple-defs-of-my_stdo.patch
Patch3: 0002-Fix-compiler-complaint-about-string-truncation.patch
Patch4: 0003-Fix-more-string-issues-for-gcc-10.patch
Provides: libsysfs
# bug437293
%ifarch ppc64
@ -62,8 +65,11 @@ for the current users, but no new software should use this library.
This package contains the development files for libsysfs.
%prep
%setup -q
%setup -n sysfsutils-sysfsutils-2_1_0
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%build
%global optflags %{optflags} -fcommon