1 /* vi: set sw=4 ts=4: */
3 * lspci implementation for busybox
5 * Copyright (C) 2009 Malek Degachi <malek-degachi@laposte.net>
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
11 static int FAST_FUNC fileAction(
13 struct stat *statbuf UNUSED_PARAM,
14 void *userData UNUSED_PARAM,
15 int depth UNUSED_PARAM)
19 char *busnum = NULL, *devnum = NULL;
20 int product_vid = 0, product_did = 0;
21 char *uevent_filename = concat_path_file(fileName, "/uevent");
23 parser = config_open2(uevent_filename, fopen_for_read);
24 free(uevent_filename);
26 while (config_read(parser, tokens, 4, 2, "\\/=", PARSE_NORMAL)) {
27 if ((parser->lineno == 1) && strcmp(tokens[0], "DEVTYPE") == 0) {
31 if (strcmp(tokens[0], "PRODUCT") == 0) {
32 product_vid = xstrtou(tokens[1], 16);
33 product_did = xstrtou(tokens[2], 16);
37 if (strcmp(tokens[0], "BUSNUM") == 0) {
38 busnum = xstrdup(tokens[1]);
42 if (strcmp(tokens[0], "DEVNUM") == 0) {
43 devnum = xstrdup(tokens[1]);
50 printf("Bus %s Device %s: ID %04x:%04x\n", busnum, devnum, product_vid, product_did);
58 int lsusb_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
59 int lsusb_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
61 /* no options, no getopt */
63 recursive_action("/sys/bus/usb/devices",