diff options
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/lsusb.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/util-linux/lsusb.c b/util-linux/lsusb.c index 262c70a..0a9e505 100644 --- a/util-linux/lsusb.c +++ b/util-linux/lsusb.c @@ -24,6 +24,24 @@ #include "libbb.h" +static char * FAST_FUNC add_sysfs_prop(const char *dir, const char *suffix, + char *buf, size_t size) +{ + char *filename; + ssize_t len; + + filename = concat_path_file(dir, suffix); + len = open_read_close(filename, buf, size - 1); + free(filename); + + if (len < 0) + len = 0; + + buf[len] = '\0'; + + return trim(buf); +} + static int FAST_FUNC fileAction(struct recursive_state *state UNUSED_PARAM, const char *fileName, struct stat *statbuf UNUSED_PARAM) @@ -61,7 +79,15 @@ static int FAST_FUNC fileAction(struct recursive_state *state UNUSED_PARAM, config_close(parser); if (busnum) { - printf("Bus %s Device %s: ID %04x:%04x\n", busnum, devnum, product_vid, product_did); + char name[256], *p; + + p = add_sysfs_prop(fileName, "/manufacturer", name, sizeof(name) - 1); + if (p != name) + p = stpcpy(p, " "); + add_sysfs_prop(fileName, "/product", p, name + sizeof(name) - p); + + printf("Bus %s Device %s: ID %04x:%04x %s\n", busnum, devnum, + product_vid, product_did, name); free(busnum); free(devnum); } |