Skip to content
Snippets Groups Projects
Commit b9d9cd59 authored by Jakob Olsson's avatar Jakob Olsson
Browse files

fix code to manage ubus call with path, can be refactored/used within call without path

parent be799471
No related branches found
No related tags found
No related merge requests found
...@@ -395,7 +395,7 @@ int get_devices_from_path(char *input_path) ...@@ -395,7 +395,7 @@ int get_devices_from_path(char *input_path)
struct stat st; struct stat st;
struct device *dev; struct device *dev;
int rv; int rv;
printf("initial input_path %s\n", input_path);
//strncpy(usb_path, "/sys/bus/usb/devices/", PATH_MAX); //strncpy(usb_path, "/sys/bus/usb/devices/", PATH_MAX);
dir = opendir(input_path); dir = opendir(input_path);
if (!dir) { if (!dir) {
...@@ -408,14 +408,15 @@ int get_devices_from_path(char *input_path) ...@@ -408,14 +408,15 @@ int get_devices_from_path(char *input_path)
continue; continue;
if (strstr(de->d_name, ":") || strstr(de->d_name, "usb")) if (strstr(de->d_name, ":") || strstr(de->d_name, "usb"))
continue; continue;
snprintf(product_path, PATH_MAX, "%s%s/product", input_path, de->d_name); snprintf(product_path, PATH_MAX, "%s/product", input_path);
printf("stat path %s\n", product_path);
memset(&st, 0, sizeof(st)); memset(&st, 0, sizeof(st));
rv = stat(product_path, &st); rv = stat(product_path, &st);
if (rv < 0) { if (rv < 0) {
//perror("stat"); //perror("stat");
continue; continue;
} }
snprintf(path, PATH_MAX, "%s%s/", input_path, de->d_name); snprintf(path, PATH_MAX, "%s/", input_path);
name = get_device_name(path); name = get_device_name(path);
if (!name) if (!name)
continue; continue;
...@@ -432,6 +433,7 @@ int get_devices_from_path(char *input_path) ...@@ -432,6 +433,7 @@ int get_devices_from_path(char *input_path)
dev->ip = get_device_ip(dev->usb.if_name); dev->ip = get_device_ip(dev->usb.if_name);
add_device(dev); add_device(dev);
break;
} }
closedir(dir); closedir(dir);
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment