From 6c332ee72d995b772779f17f194b8106d12b4dc6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 30 Jun 2020 22:10:08 +0300 Subject: [PATCH] busybox: Add USB vendor names to lsusb. Patch written and sent in by xzcvczx. --- core/busybox/checksums | 3 +- core/busybox/files/.config | 1 + .../patches/lsusb-vendor-product.patch | 53 +++++++++++++++++++ core/busybox/sources | 1 + core/busybox/version | 2 +- 5 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 core/busybox/patches/lsusb-vendor-product.patch diff --git a/core/busybox/checksums b/core/busybox/checksums index b3f64d64..790ac2b2 100644 --- a/core/busybox/checksums +++ b/core/busybox/checksums @@ -4,7 +4,8 @@ c35d87f1d04b2b153d33c275c2632e40d388a88f19a9e71727e0bbbff51fe689 busybox-1.32.0 0f54301a73af461e8066bc805b48d991cfed513d08a2f036e015b19f97cb424a modprobe-kernel-version.patch 68e0c7d5e96902d3b890e89d9b018ae11d53ed3104bfedd624a1485df58b11cb print-unicode.patch f0e17fefc0af6b10205d72b242b6ef7481a58ff07726c62890ebc5893b96a396 install-fix-chown.patch -2d0fa808b485cde87b6cc6ff449a441cfdb3e2a845e3b796e9e280e2afa7fd46 .config +73be7b16dcff44e88eb48696522794f529beddf9d5a139b8a76cc8685a9f6fc8 lsusb-vendor-product.patch +ae6cae539ad78abc4e412389c0e371fc7ea49f5645c632b8eb27efc1a2a09bbe .config 6e9c7bccc102d0e8fa062c750c9d00ec6de6aa67d6b4c6f6b0539247798e6c71 .config-suid ebd61afac770d3d9cae5c411f44002496fb18b28cf7b77520072a3909852246e acpid.run 814dea14ac612125e97dcc1d619219b2c9dfc14850bf48d858421fb2c98eca12 crond.run diff --git a/core/busybox/files/.config b/core/busybox/files/.config index fcccd0ba..709127c4 100644 --- a/core/busybox/files/.config +++ b/core/busybox/files/.config @@ -636,6 +636,7 @@ CONFIG_FEATURE_LAST_FANCY=y CONFIG_LOSETUP=y CONFIG_LSPCI=y CONFIG_LSUSB=y +CONFIG_FEATURE_LSUSB_STRINGS=y CONFIG_MDEV=y CONFIG_FEATURE_MDEV_CONF=y CONFIG_FEATURE_MDEV_RENAME=y diff --git a/core/busybox/patches/lsusb-vendor-product.patch b/core/busybox/patches/lsusb-vendor-product.patch new file mode 100644 index 00000000..45747ae8 --- /dev/null +++ b/core/busybox/patches/lsusb-vendor-product.patch @@ -0,0 +1,53 @@ +diff --git a/util-linux/lsusb.c b/util-linux/lsusb.c +index e27aa7f31..b7b7abb99 100644 +--- a/util-linux/lsusb.c ++++ b/util-linux/lsusb.c +@@ -15,7 +15,16 @@ + //config: system and devices connected to them. + //config: + //config: This version uses sysfs (/sys/bus/usb/devices) only. +- ++//config: ++//config:config FEATURE_LSUSB_STRINGS ++//config: bool "Print vendor and product strings if they exist" ++//config: default y ++//config: depends on LSUSB ++//config: help ++//config: lsusb is a utility for displaying information about USB busses in the ++//config: system and devices connected to them. This option prints out the ++//config: vendor and product strings if they are available. This option ++//config: replicates a simpler version of util-linux lsusb output. + //applet:IF_LSUSB(APPLET_NOEXEC(lsusb, lsusb, BB_DIR_USR_BIN, BB_SUID_DROP, lsusb)) + + //kbuild:lib-$(CONFIG_LSUSB) += lsusb.o +@@ -37,6 +46,16 @@ static int FAST_FUNC fileAction( + int product_vid = 0, product_did = 0; + char *uevent_filename = concat_path_file(fileName, "/uevent"); + ++#if ENABLE_FEATURE_LSUSB_STRINGS ++ ssize_t vlen, plen; ++ // max length standard allows, any longer and someones being naughty ++ char vendor[256] = { 0 }, product[256] = { 0 }; ++ vlen = open_read_close(concat_path_file(fileName, "/manufacturer"), vendor, sizeof(vendor)); ++ vendor[vlen - 1] = '\0'; ++ plen = open_read_close(concat_path_file(fileName, "/product"), product, sizeof(product)); ++ product[plen - 1] = '\0'; ++#endif ++ + parser = config_open2(uevent_filename, fopen_for_read); + free(uevent_filename); + +@@ -64,7 +83,12 @@ static int FAST_FUNC fileAction( + 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", busnum, devnum, product_vid, product_did); ++#if ENABLE_FEATURE_LSUSB_STRINGS ++ if(vlen) printf(" %s", vendor); ++ if(plen) printf(" %s", product); ++#endif ++ printf("\n"); + free(busnum); + free(devnum); + } diff --git a/core/busybox/sources b/core/busybox/sources index 16c0b667..3b1db187 100644 --- a/core/busybox/sources +++ b/core/busybox/sources @@ -4,6 +4,7 @@ patches/fsck-resolve-uuid.patch patches/modprobe-kernel-version.patch patches/print-unicode.patch patches/install-fix-chown.patch +patches/lsusb-vendor-product.patch files/.config files/.config-suid files/acpid.run diff --git a/core/busybox/version b/core/busybox/version index b9c04f8c..84a6c04f 100644 --- a/core/busybox/version +++ b/core/busybox/version @@ -1 +1 @@ -1.32.0 1 +1.32.0 2