From b9d9cd59d85e790bc670a30ceee6b19250dc436f Mon Sep 17 00:00:00 2001
From: Jakob Olsson <jakobols@kth.se>
Date: Fri, 8 Jun 2018 16:17:56 +0200
Subject: [PATCH] fix code to manage ubus call with path, can be
 refactored/used within call without path

---
 dongle.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/dongle.c b/dongle.c
index a05684b..beb4405 100644
--- a/dongle.c
+++ b/dongle.c
@@ -395,7 +395,7 @@ int get_devices_from_path(char *input_path)
 	struct stat st;
 	struct device *dev;
 	int rv;
-
+	printf("initial input_path %s\n", input_path);
 	//strncpy(usb_path, "/sys/bus/usb/devices/", PATH_MAX);
 	dir = opendir(input_path);
 	if (!dir) {
@@ -408,14 +408,15 @@ int get_devices_from_path(char *input_path)
 			continue;
 		if (strstr(de->d_name, ":") || strstr(de->d_name, "usb"))
 			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));
 		rv = stat(product_path, &st);
 		if (rv < 0) {
 			//perror("stat");
 			continue;
 		}
-		snprintf(path, PATH_MAX, "%s%s/", input_path, de->d_name);
+		snprintf(path, PATH_MAX, "%s/", input_path);
 		name = get_device_name(path);
 		if (!name)
 			continue;
@@ -432,6 +433,7 @@ int get_devices_from_path(char *input_path)
 		dev->ip = get_device_ip(dev->usb.if_name);
 
 		add_device(dev);
+		break;
 	}
 	closedir(dir);
 	return 0;
-- 
GitLab