Le 16/03/2010 01:36, Denys Vlasenko a écrit :
On Wednesday 03 March 2010 22:51, Souf Oued wrote:
Hi,
This patch makes lsusb compatible with kernel>= 2.6.32

-               if (strcmp(tokens[0], "DEVICE") == 0) {
-                       bus = xstrdup(tokens[4]);
-                       device = xstrdup(tokens[5]);
+               if (strcmp(tokens[0], "DEVNAME") == 0) {
+                       bus = xstrdup(tokens[3]);
+                       device = xstrdup(tokens[4]);

Do I read this right that the format of that file has changed?
So, the applet will work correctly either on 2.6.31
or on 2.6.32, but not on both?
--
vda

Hi,
"DEVICE" it is no longer exported to userspace with kernel >= 2.6.32
with this patch lsusb works correctly with kernel <= 2.6.31 and kernel >= 2.6.32.
but not apply this version please, a new patch is attached

Thanks
diff -urpN busybox/util-linux/lsusb.c busybox-lsusb/util-linux/lsusb.c
--- busybox/util-linux/lsusb.c	2010-03-17 11:23:04.000000000 +0100
+++ busybox-lsusb/util-linux/lsusb.c	2010-03-18 20:20:50.901634077 +0100
@@ -15,37 +15,41 @@ static int FAST_FUNC fileAction(
 		int depth UNUSED_PARAM)
 {
 	parser_t *parser;
-	char *tokens[6];
-	char *bus = NULL, *device = NULL;
+	char *tokens[4];
+	char *busnum = NULL, *devnum = NULL;
 	int product_vid = 0, product_did = 0;
-
 	char *uevent_filename = concat_path_file(fileName, "/uevent");
+
 	parser = config_open2(uevent_filename, fopen_for_read);
 	free(uevent_filename);

-	while (config_read(parser, tokens, 6, 1, "\\/=", PARSE_NORMAL)) {
+	while (config_read(parser, tokens, 4, 2, "\\/=", PARSE_NORMAL)) {
 		if ((parser->lineno == 1) && strcmp(tokens[0], "DEVTYPE") == 0) {
 			break;
 		}

-		if (strcmp(tokens[0], "DEVICE") == 0) {
-			bus = xstrdup(tokens[4]);
-			device = xstrdup(tokens[5]);
-			continue;
-		}
-
 		if (strcmp(tokens[0], "PRODUCT") == 0) {
 			product_vid = xstrtou(tokens[1], 16);
 			product_did = xstrtou(tokens[2], 16);
 			continue;
 		}
+
+		if (strcmp(tokens[0], "BUSNUM") == 0) {
+			busnum = xstrdup(tokens[1]);
+			continue;
+		}
+
+		if (strcmp(tokens[0], "DEVNUM") == 0) {
+			devnum = xstrdup(tokens[1]);
+			continue;
+		}
 	}
 	config_close(parser);

-	if (bus) {
-		printf("Bus %s Device %s: ID %04x:%04x\n", bus, device, product_vid, product_did);
-		free(bus);
-		free(device);
+	if (busnum) {
+		printf("Bus %s Device %s: ID %04x:%04x\n", busnum, devnum, product_vid, product_did);
+		free(busnum);
+		free(devnum);
 	}

 	return TRUE;
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to