mdev_helper/hdd_menu: add udev support

busybox/mdev fills the MDEV variable without /dev/ prefix,
udev fills DEVNAME with /dev/ prefix. Handle both variants.
This commit is contained in:
Stefan Seyfried
2015-02-07 21:38:33 +01:00
committed by Jacek Jendrzej
parent c7dd4260d6
commit d04f7406a7
2 changed files with 15 additions and 8 deletions

View File

@@ -2,7 +2,7 @@
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Copyright (C) 2010-2014 Stefan Seyfried
Copyright (C) 2010-2015 Stefan Seyfried
Copyright (C) 2013-2014 martii
Copyright (C) 2009-2014 CoolStream International Ltd
@@ -389,11 +389,18 @@ int CHDDMenuHandler::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t dat
if (!split_config_string(str, smap))
return messages_return::handled;
std::string dev;
std::map<std::string,std::string>::iterator it = smap.find("MDEV");
if (it != smap.end())
dev = it->second;
else {
it = smap.find("DEVNAME");
if (it == smap.end())
return messages_return::handled;
std::string dev = it->second;
dev = it->second;
if (dev.length() > 5)
dev = dev.substr(5); /* strip off /dev/ */
}
printf("CHDDMenuHandler::handleMsg: MDEV=%s\n", dev.c_str());
if (!filterDevName(dev.c_str()))
return messages_return::handled;

View File

@@ -37,10 +37,10 @@ const char *mdev_env[] =
"MDEV" ,
"DEVPATH" ,
"INTERFACE",
"DEVNAME",
NULL /* terminating entry */
};
#define ENV_SIZE (sizeof(mdev_env)/sizeof(char *))
int main (int /*argc*/, char **argv)
{
struct sockaddr_un servaddr;
@@ -64,7 +64,7 @@ int main (int /*argc*/, char **argv)
goto _error;
}
for (unsigned i = 0; i < ENV_SIZE; i++) {
for (unsigned i = 0; mdev_env[i]; i++) {
char * s = getenv(mdev_env[i]);
if (s)
data += std::string(mdev_env[i]) + "=" + s + " ";