aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/applets.h1
-rw-r--r--include/usage.h3
-rw-r--r--util-linux/Config.in9
-rw-r--r--util-linux/Kbuild1
-rw-r--r--util-linux/lsusb.c67
5 files changed, 81 insertions, 0 deletions
diff --git a/include/applets.h b/include/applets.h
index 7d5d4406c..69dcdc002 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -247,6 +247,7 @@ IF_LSATTR(APPLET(lsattr, _BB_DIR_BIN, _BB_SUID_DROP))
247IF_LSMOD(APPLET(lsmod, _BB_DIR_SBIN, _BB_SUID_DROP)) 247IF_LSMOD(APPLET(lsmod, _BB_DIR_SBIN, _BB_SUID_DROP))
248IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe)) 248IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe))
249IF_LSPCI(APPLET(lspci, _BB_DIR_SBIN, _BB_SUID_DROP)) 249IF_LSPCI(APPLET(lspci, _BB_DIR_SBIN, _BB_SUID_DROP))
250IF_LSUSB(APPLET(lsusb, _BB_DIR_SBIN, _BB_SUID_DROP))
250IF_UNLZMA(APPLET_ODDNAME(lzmacat, unlzma, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzmacat)) 251IF_UNLZMA(APPLET_ODDNAME(lzmacat, unlzma, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzmacat))
251IF_LZOP(APPLET(lzop, _BB_DIR_BIN, _BB_SUID_DROP)) 252IF_LZOP(APPLET(lzop, _BB_DIR_BIN, _BB_SUID_DROP))
252IF_LZOP(APPLET_ODDNAME(lzopcat, lzop, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzopcat)) 253IF_LZOP(APPLET_ODDNAME(lzopcat, lzop, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzopcat))
diff --git a/include/usage.h b/include/usage.h
index 6b2738407..9f4c44891 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -2510,6 +2510,9 @@
2510 "\n -m Parseable output" \ 2510 "\n -m Parseable output" \
2511 "\n -k Show driver" \ 2511 "\n -k Show driver" \
2512 2512
2513#define lsusb_trivial_usage NOUSAGE_STR
2514#define lsusb_full_usage ""
2515
2513#if ENABLE_FEATURE_MAKEDEVS_LEAF 2516#if ENABLE_FEATURE_MAKEDEVS_LEAF
2514#define makedevs_trivial_usage \ 2517#define makedevs_trivial_usage \
2515 "NAME TYPE MAJOR MINOR FIRST LAST [s]" 2518 "NAME TYPE MAJOR MINOR FIRST LAST [s]"
diff --git a/util-linux/Config.in b/util-linux/Config.in
index 94337df8e..f04511bb1 100644
--- a/util-linux/Config.in
+++ b/util-linux/Config.in
@@ -357,6 +357,15 @@ config LSPCI
357 357
358 This version uses sysfs (/sys/bus/pci/devices) only. 358 This version uses sysfs (/sys/bus/pci/devices) only.
359 359
360config LSUSB
361 bool "lsusb"
362 default n
363 help
364 lsusb is a utility for displaying information about USB buses in the
365 system and devices connected to them.
366
367 This version uses sysfs (/sys/bus/usb/devices) only.
368
360config MDEV 369config MDEV
361 bool "mdev" 370 bool "mdev"
362 default n 371 default n
diff --git a/util-linux/Kbuild b/util-linux/Kbuild
index 3004fd0a0..72a2ef1cd 100644
--- a/util-linux/Kbuild
+++ b/util-linux/Kbuild
@@ -22,6 +22,7 @@ lib-$(CONFIG_IPCRM) += ipcrm.o
22lib-$(CONFIG_IPCS) += ipcs.o 22lib-$(CONFIG_IPCS) += ipcs.o
23lib-$(CONFIG_LOSETUP) += losetup.o 23lib-$(CONFIG_LOSETUP) += losetup.o
24lib-$(CONFIG_LSPCI) += lspci.o 24lib-$(CONFIG_LSPCI) += lspci.o
25lib-$(CONFIG_LSUSB) += lsusb.o
25lib-$(CONFIG_MDEV) += mdev.o 26lib-$(CONFIG_MDEV) += mdev.o
26lib-$(CONFIG_MKFS_EXT2) += mkfs_ext2.o 27lib-$(CONFIG_MKFS_EXT2) += mkfs_ext2.o
27lib-$(CONFIG_MKFS_MINIX) += mkfs_minix.o 28lib-$(CONFIG_MKFS_MINIX) += mkfs_minix.o
diff --git a/util-linux/lsusb.c b/util-linux/lsusb.c
new file mode 100644
index 000000000..7c5b6b947
--- /dev/null
+++ b/util-linux/lsusb.c
@@ -0,0 +1,67 @@
1/* vi: set sw=4 ts=4: */
2/*
3* lspci implementation for busybox
4*
5* Copyright (C) 2009 Malek Degachi <malek-degachi@laposte.net>
6*
7* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
8*/
9#include <libbb.h>
10
11static int FAST_FUNC fileAction(
12 const char *fileName,
13 struct stat *statbuf UNUSED_PARAM,
14 void *userData UNUSED_PARAM,
15 int depth UNUSED_PARAM)
16{
17 parser_t *parser;
18 char *tokens[6];
19 char *bus = NULL, *device = NULL;
20 int product_vid = 0, product_did = 0;
21
22 char *uevent_filename = concat_path_file(fileName, "/uevent");
23 parser = config_open2(uevent_filename, fopen_for_read);
24 free(uevent_filename);
25
26 while (config_read(parser, tokens, 6, 1, "\\/=", PARSE_NORMAL)) {
27 if ((parser->lineno == 1) && strcmp(tokens[0], "DEVTYPE") == 0) {
28 break;
29 }
30
31 if (strcmp(tokens[0], "DEVICE") == 0) {
32 bus = xstrdup(tokens[4]);
33 device = xstrdup(tokens[5]);
34 continue;
35 }
36
37 if (strcmp(tokens[0], "PRODUCT") == 0) {
38 product_vid = xstrtou(tokens[1], 16);
39 product_did = xstrtou(tokens[2], 16);
40 continue;
41 }
42 }
43 config_close(parser);
44
45 if (bus) {
46 printf("Bus %s Device %s: ID %04x:%04x\n", bus, device, product_vid, product_did);
47 free(bus);
48 free(device);
49 }
50
51 return TRUE;
52}
53
54int lsusb_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
55int lsusb_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
56{
57 /* no options, no getopt */
58
59 recursive_action("/sys/bus/usb/devices",
60 ACTION_RECURSE,
61 fileAction,
62 NULL, /* dirAction */
63 NULL, /* userData */
64 0 /* depth */);
65
66 return EXIT_SUCCESS;
67}