0001-Fix-musl-build.patch 3.7 KB

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