summaryrefslogtreecommitdiff
path: root/patches/busybox/0010-lsusb-show-goddamn-descriptors.patch
blob: 9ecbf16958a2ba217aa4335f486ade4b4530812f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
uvok cheetah, 2024

Add some more useful info to lsusb output.
Index: busybox-1.36.1/util-linux/lsusb.c
===================================================================
--- busybox-1.36.1.orig/util-linux/lsusb.c
+++ busybox-1.36.1/util-linux/lsusb.c
@@ -33,6 +33,10 @@ static int FAST_FUNC fileAction(struct r
 	char *busnum = NULL, *devnum = NULL;
 	int product_vid = 0, product_did = 0;
 	char *uevent_filename = concat_path_file(fileName, "/uevent");
+	char *manu_filename = concat_path_file(fileName, "/manufacturer");
+	char *product_filename = concat_path_file(fileName, "/product");
+	char manu_buf[32] = { 0 };
+	char product_buf[32] = { 0 };
 
 	parser = config_open2(uevent_filename, fopen_for_read);
 	free(uevent_filename);
@@ -58,10 +62,34 @@ static int FAST_FUNC fileAction(struct r
 			continue;
 		}
 	}
+
+	{
+		FILE *manu_file = fopen(manu_filename, "r");
+		if (manu_file != NULL) {
+			// leave one for terminator
+			size_t read = fread(manu_buf, 1, sizeof(manu_buf) - 1, manu_file);
+			fclose(manu_file);
+			// remove newline
+			read && (manu_buf[read - 1] = '\0');
+			manu_buf[sizeof(manu_buf) - 1] = '\0';
+		}
+	}
+	{
+		FILE *product_file = fopen(product_filename, "r");
+		if (product_file != NULL) {
+			// leave one for terminator
+			size_t read = fread(product_buf, 1, sizeof(product_buf) - 1, product_file);
+			fclose(product_file);
+			// remove newline
+			read && (product_buf[read - 1] = '\0');
+			product_buf[sizeof(product_buf) - 1] = '\0';
+		}
+	}
+
 	config_close(parser);
 
 	if (busnum) {
-		printf("Bus %s Device %s: ID %04x:%04x\n", busnum, devnum, product_vid, product_did);
+		printf("Bus %s Device %s: ID %04x:%04x %s %s\n", busnum, devnum, product_vid, product_did, manu_buf, product_buf);
 		free(busnum);
 		free(devnum);
 	}