mirror of
https://github.com/nitanmarcel/isodrive.git
synced 2026-03-13 04:17:24 +00:00
util: fix reading sysfs
This commit is contained in:
@@ -25,7 +25,7 @@ char *get_gadget_root()
|
|||||||
{
|
{
|
||||||
gadgetRoot = strjin(usbGadgetRoot, entry->d_name);
|
gadgetRoot = strjin(usbGadgetRoot, entry->d_name);
|
||||||
udc = sysfs_read(strjin(gadgetRoot, "/UDC"));
|
udc = sysfs_read(strjin(gadgetRoot, "/UDC"));
|
||||||
if (strcmp(udc, getprop("sys.usb.controller")) == 1)
|
if (strcmp(udc, getprop("sys.usb.controller")) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-4
@@ -65,13 +65,19 @@ void sysfs_write(char *path, char *content)
|
|||||||
|
|
||||||
char *sysfs_read(char *path)
|
char *sysfs_read(char *path)
|
||||||
{
|
{
|
||||||
char *value = nullptr;
|
std::string value;
|
||||||
std::ifstream sysfsFile(path);
|
std::ifstream sysfsFile(path);
|
||||||
sysfsFile >> path;
|
if (!sysfsFile.is_open())
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
sysfsFile >> value;
|
||||||
sysfsFile.close();
|
sysfsFile.close();
|
||||||
return value;
|
char *result = new char[value.length() + 1];
|
||||||
}
|
strcpy(result, value.c_str());
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
char *getprop(char *key)
|
char *getprop(char *key)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user