Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysfs: Fix basename() build with musl #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/core/sysfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "version.h"
#include "sysfs.h"
#include "osutils.h"
#include <libgen.h>
#include <limits.h>
#include <unistd.h>
#include <stdlib.h>
Expand Down Expand Up @@ -99,7 +100,7 @@ static string sysfs_getbustype(const string & path)
{
devname =
string(fs.path + "/bus/") + string(namelist[i]->d_name) +
"/devices/" + basename(path.c_str());
"/devices/" + basename(const_cast<char *>(path.c_str()));

if (samefile(devname, path))
return string(namelist[i]->d_name);
Expand Down Expand Up @@ -139,7 +140,7 @@ static string sysfstobusinfo(const string & path)

if (bustype == "usb")
{
string name = basename(path.c_str());
string name = basename(const_cast<char *>(path.c_str()));
if (matches(name, "^[0-9]+-[0-9]+(\\.[0-9]+)*:[0-9]+\\.[0-9]+$"))
{
size_t colon = name.rfind(":");
Expand All @@ -150,18 +151,18 @@ static string sysfstobusinfo(const string & path)

if (bustype == "virtio")
{
string name = basename(path.c_str());
string name = basename(const_cast<char *>(path.c_str()));
if (name.compare(0, 6, "virtio") == 0)
return "virtio@" + name.substr(6);
else
return "virtio@" + name;
}

if (bustype == "vio")
return string("vio@") + basename(path.c_str());
return string("vio@") + basename(const_cast<char *>(path.c_str()));

if (bustype == "ccw")
return string("ccw@") + basename(path.c_str());
return string("ccw@") + basename(const_cast<char *>(path.c_str()));

if (bustype == "ccwgroup")
{
Expand Down Expand Up @@ -232,7 +233,7 @@ string entry::driver() const
string driverlink = This->devpath + "/driver";
if (!exists(driverlink))
return "";
return basename(readlink(driverlink).c_str());
return basename(const_cast<char *>(readlink(driverlink).c_str()));
}


Expand Down Expand Up @@ -320,7 +321,7 @@ string entry::name_in_class(const string & classname) const

string entry::name() const
{
return basename(This->devpath.c_str());
return basename(const_cast<char *>(This->devpath.c_str()));
}


Expand Down