blob: fa90aa1211a18b5cdbccf8fa27069c62129602ec [file] [log] [blame]
Andrew Geisslerd688a012020-09-18 13:36:00 -05001From a5a4bb4254b2109bd3e272174946f0bb36ee99a8 Mon Sep 17 00:00:00 2001
2From: Leon Anavi <leon.anavi@konsulko.com>
3Date: Tue, 25 Aug 2020 11:45:45 +0300
4Subject: [PATCH] Fix musl build
5
6Apply the following fixes for musl:
7
8- Fix basename() is in libgen.h
9- Fix wrong usage of LONG_BIT
10
11Same fixes have been submitted to the upstream of lshw by Sergio
12Prado but they have not been merged yet.
13
14Upstream-Status: Submitted
15
16Co-Authored-By: Sergio Prado <sergio.prado@e-labworks.com>
17Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
18---
19 src/core/abi.cc | 4 +---
20 src/core/sysfs.cc | 19 ++++++++++---------
21 2 files changed, 11 insertions(+), 12 deletions(-)
22
23diff --git a/src/core/abi.cc b/src/core/abi.cc
24index adff7b5..76c664c 100644
25--- a/src/core/abi.cc
26+++ b/src/core/abi.cc
27@@ -20,9 +20,7 @@ __ID("@(#) $Id: mem.cc 1352 2006-05-27 23:54:13Z ezix $");
28 bool scan_abi(hwNode & system)
29 {
30 // are we compiled as 32- or 64-bit process ?
31- long sc = sysconf(LONG_BIT);
32- if(sc==-1) sc = sysconf(_SC_LONG_BIT);
33- if(sc!=-1) system.setWidth(sc);
34+ system.setWidth(LONG_BIT);
35
36 pushd(PROC_SYS);
37
38diff --git a/src/core/sysfs.cc b/src/core/sysfs.cc
39index 32d6564..c2fa84f 100644
40--- a/src/core/sysfs.cc
41+++ b/src/core/sysfs.cc
42@@ -16,6 +16,7 @@
43 #include <sys/stat.h>
44 #include <sys/types.h>
45 #include <sys/mount.h>
46+#include <libgen.h>
47
48
49 __ID("@(#) $Id$");
50@@ -100,7 +101,7 @@ static string sysfs_getbustype(const string & path)
51 {
52 devname =
53 string(fs.path + "/bus/") + string(namelist[i]->d_name) +
54- "/devices/" + basename(path.c_str());
55+ "/devices/" + basename(const_cast<char*>(path.c_str()));
56
57 if (samefile(devname, path))
58 return string(namelist[i]->d_name);
59@@ -140,7 +141,7 @@ static string sysfstobusinfo(const string & path)
60
61 if (bustype == "usb")
62 {
63- string name = basename(path.c_str());
64+ string name = basename(const_cast<char*>(path.c_str()));
65 if (matches(name, "^[0-9]+-[0-9]+(\\.[0-9]+)*:[0-9]+\\.[0-9]+$"))
66 {
67 size_t colon = name.rfind(":");
68@@ -151,7 +152,7 @@ static string sysfstobusinfo(const string & path)
69
70 if (bustype == "virtio")
71 {
72- string name = basename(path.c_str());
73+ string name = basename(const_cast<char*>(path.c_str()));
74 if (name.compare(0, 6, "virtio") == 0)
75 return "virtio@" + name.substr(6);
76 else
77@@ -159,10 +160,10 @@ static string sysfstobusinfo(const string & path)
78 }
79
80 if (bustype == "vio")
81- return string("vio@") + basename(path.c_str());
82+ return string("vio@") + basename(const_cast<char*>(path.c_str()));
83
84 if (bustype == "ccw")
85- return string("ccw@") + basename(path.c_str());
86+ return string("ccw@") + basename(const_cast<char*>(path.c_str()));
87
88 if (bustype == "ccwgroup")
89 {
90@@ -240,7 +241,7 @@ string entry::driver() const
91 string driverlink = This->devpath + "/driver";
92 if (!exists(driverlink))
93 return "";
94- return basename(readlink(driverlink).c_str());
95+ return basename(const_cast<char*>(readlink(driverlink).c_str()));
96 }
97
98
99@@ -328,7 +329,7 @@ string entry::name_in_class(const string & classname) const
100
101 string entry::name() const
102 {
103- return basename(This->devpath.c_str());
104+ return basename(const_cast<char*>(This->devpath.c_str()));
105 }
106
107
108@@ -340,12 +341,12 @@ entry entry::parent() const
109
110 string entry::classname() const
111 {
112- return basename(dirname(This->devpath).c_str());
113+ return basename(const_cast<char*>(dirname(This->devpath).c_str()));
114 }
115
116 bool entry::isvirtual() const
117 {
118- return string(basename(dirname(dirname(This->devpath)).c_str())) == "virtual";
119+ return string(basename(const_cast<char*>(dirname(dirname(This->devpath)).c_str()))) == "virtual";
120 }
121
122 string entry::string_attr(const string & name, const string & def) const
123--
1242.17.1
125