CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: mrg Date: Sun Mar 24 03:23:19 UTC 2024 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: usbdevs(8): don't assume usb bus count is the same as max usb bus unit keep track of the highest usbN value, not the count of busses. fixes a problem where you do "drvctl -d usb0" (or a parent), and then "usbdevs" won't print info on the last bus. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: mrg Date: Sun Mar 24 03:23:19 UTC 2024 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: usbdevs(8): don't assume usb bus count is the same as max usb bus unit keep track of the highest usbN value, not the count of busses. fixes a problem where you do "drvctl -d usb0" (or a parent), and then "usbdevs" won't print info on the last bus. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.41 src/usr.sbin/usbdevs/usbdevs.c:1.42 --- src/usr.sbin/usbdevs/usbdevs.c:1.41 Tue Sep 13 08:34:37 2022 +++ src/usr.sbin/usbdevs/usbdevs.c Sun Mar 24 03:23:19 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.41 2022/09/13 08:34:37 riastradh Exp $ */ +/* $NetBSD: usbdevs.c,v 1.42 2024/03/24 03:23:19 mrg Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -31,10 +31,10 @@ #include #ifndef lint -__RCSID("$NetBSD: usbdevs.c,v 1.41 2022/09/13 08:34:37 riastradh Exp $"); +__RCSID("$NetBSD: usbdevs.c,v 1.42 2024/03/24 03:23:19 mrg Exp $"); #endif -#include +#include #include @@ -328,8 +328,12 @@ dumpone(char *name, int f, int addr) usbdump(f); } +/* + * Find the highest usb device unit. Searches recursively + * thought the device list, tracking highest unit seen. + */ static int -getusbcount_device(int fd, const char *dev, int depth) +get_highest_usb_device_unit(int fd, const char *dev, int depth) { struct devlistargs laa = { .l_childname = NULL, @@ -337,19 +341,23 @@ getusbcount_device(int fd, const char *d }; size_t i; size_t children; - int nbusses = 0; + int highbus = 0; if (depth && (dev == NULL || *dev == '\0')) return 0; /* - * Look for children that match "usb[0-9]*". Could maybe + * Look for children that match "usb[0-9]*". The high + * bus from this value, regardles * simply return 1 here, but there's always a chance that * someone has eg, a USB to PCI bridge, with a USB * controller behind PCI. */ - if (strncmp(dev, "usb", 3) == 0 && isdigit((int)dev[3])) - nbusses++; + if (strncmp(dev, "usb", 3) == 0 && isdigit((int)dev[3])) { + int new_high = atoi(dev+3); + + highbus = MAX(new_high, highbus); + } strlcpy(laa.l_devname, dev, sizeof(laa.l_devname)); @@ -366,11 +374,14 @@ getusbcount_device(int fd, const char *d err(EXIT_FAILURE, "DRVLISTDEV: number of children grew"); for (i = 0; i < laa.l_children; i++) { - nbusses += getusbcount_device(fd, laa.l_childname[i], + int new_high; + + new_high = get_highest_usb_device_unit(fd, laa.l_childname[i], depth + 1); + highbus = MAX(new_high, highbus); } - return nbusses; + return highbus; } int @@ -411,17 +422,17 @@ main(int argc, char **argv) argv += optind; if (dev == NULL) { - int nbusses; + int highbus; int fd = open(DRVCTLDEV, O_RDONLY, 0); /* If no drvctl configured, default to 16. */ if (fd != -1) - nbusses = getusbcount_device(fd, "", 0); + highbus = get_highest_usb_device_unit(fd, "", 0); else - nbusses = 16; + highbus = 16; close(fd); - for (ncont = 0, i = 0; i < nbusses; i++) { + for (ncont = 0, i = 0; i <= highbus; i++) { snprintf(buf, sizeof(buf), "%s%d", USBDEV, i); f = open(buf, O_RDONLY); if (f >= 0) {
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: riastradh Date: Tue Sep 13 08:34:37 UTC 2022 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: usbdevs(8): Misc KNF. - Fix whitespace and braces. - malloc(n * sizeof(...)) -> calloc(n, sizeof(...)) To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.40 src/usr.sbin/usbdevs/usbdevs.c:1.41 --- src/usr.sbin/usbdevs/usbdevs.c:1.40 Wed Nov 27 17:56:08 2019 +++ src/usr.sbin/usbdevs/usbdevs.c Tue Sep 13 08:34:37 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.40 2019/11/27 17:56:08 christos Exp $ */ +/* $NetBSD: usbdevs.c,v 1.41 2022/09/13 08:34:37 riastradh Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -31,24 +31,25 @@ #include #ifndef lint -__RCSID("$NetBSD: usbdevs.c,v 1.40 2019/11/27 17:56:08 christos Exp $"); +__RCSID("$NetBSD: usbdevs.c,v 1.41 2022/09/13 08:34:37 riastradh Exp $"); #endif #include + #include -#include -#include -#include -#include -#include +#include #include #include -#include -#include +#include #include -#include #include +#include +#include +#include +#include +#include +#include #include @@ -62,8 +63,9 @@ struct stringtable { const char *string; }; -__dead static void usage(void); -static void getstrings(const struct stringtable *, int, int, const char **, const char **); +static void usage(void) __dead; +static void getstrings(const struct stringtable *, int, int, +const char **, const char **); static void usbdev(int f, int a, int rec); static void usbdump(int f); static void dumpone(char *name, int f, int addr); @@ -100,7 +102,7 @@ u2t(const char *utf8str, char *termstr) insz = strlen(utf8str); outsz = MAXLEN - 1; icres = iconv(ic, __UNCONST(), , , - ); + ); if (icres != (size_t)-1) { *termstr = '\0'; return; @@ -184,8 +186,9 @@ struct stringtable class_strings[] = { }; static void -getstrings(const struct stringtable *table, - int row, int col, const char **rp, const char **cp) { +getstrings(const struct stringtable *table, int row, int col, +const char **rp, const char **cp) +{ static char rbuf[5], cbuf[5]; snprintf(rbuf, sizeof(rbuf), "0x%02x", row); @@ -245,9 +248,9 @@ usbdev(int f, int a, int rec) u2t(di.udi_serial, serial); if (verbose) { printf("%s(0x%04x), %s(0x%04x), rev %s(0x%04x)", - product, di.udi_productNo, - vendor, di.udi_vendorNo, - di.udi_release, di.udi_releaseNo); + product, di.udi_productNo, + vendor, di.udi_vendorNo, + di.udi_release, di.udi_releaseNo); if (di.udi_serial[0]) printf(", serial %s", serial); } else @@ -255,40 +258,43 @@ usbdev(int f, int a, int rec) printf("\n"); if (verbose > 1 && di.udi_class != UICLASS_UNSPEC) { const char *cstr, *sstr; - getstrings(class_strings, di.udi_class, di.udi_subclass, , ); + getstrings(class_strings, di.udi_class, di.udi_subclass, + , ); printf("%*s %s(0x%02x), %s(0x%02x), proto %u\n", indent, "", - cstr, di.udi_class, sstr, di.udi_subclass, - di.udi_protocol); + cstr, di.udi_class, sstr, di.udi_subclass, + di.udi_protocol); } if (showdevs) { - for (i = 0; i < USB_MAX_DEVNAMES; i++) - if (di.udi_devnames[i][0]) + for (i = 0; i < USB_MAX_DEVNAMES; i++) { + if (di.udi_devnames[i][0]) { printf("%*s %s\n", indent, "", - di.udi_devnames[i]); +di.udi_devnames[i]); + } + } } if (!rec) return; - unsigned int nports = di.udi_nports; + unsigned int p, nports = di.udi_nports; - for (unsigned int p = 0; p < nports && p < __arraycount(di.udi_ports); p++) { + for (p = 0; p < nports && p < __arraycount(di.udi_ports); p++) { int s = di.udi_ports[p]; if (s >= USB_MAX_DEVICES) { if (verbose) { -printf("%*sport %d %s\n", indent+1, "", p+1, - s == USB_PORT_ENABLED ? "enabled" : - s == USB_PORT_SUSPENDED ? "suspended" : - s == USB_PORT_POWERED ? "powered" : - s == USB_PORT_DISABLED ? "disabled" : - "???"); - +printf("%*sport %d %s\n", indent + 1, "", +p + 1, +s == USB_PORT_ENABLED ? "enabled" : +s == USB_PORT_SUSPENDED ? "suspended" : +s == USB_PORT_POWERED ? "powered" : +s == USB_PORT_DISABLED ? "disabled" : +"???"); } continue; } indent++; printf("%*s", indent, ""); if (verbose) - printf("port %d ", p+1); + printf("port %d ", p + 1); if (s == 0) printf("addr 0 should never happen!\n"); else @@ -311,6 +317,7 @@ usbdump(int f) static void dumpone(char *name, int f, int addr) { + if (verbose) printf("Controller %s:\n", name); indent = 0; @@ -325,8 +332,8 @@ static int getusbcount_device(int fd, const char
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: riastradh Date: Tue Sep 13 08:34:37 UTC 2022 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: usbdevs(8): Misc KNF. - Fix whitespace and braces. - malloc(n * sizeof(...)) -> calloc(n, sizeof(...)) To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: christos Date: Wed Nov 27 17:56:09 UTC 2019 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Use strtoi instead of atoi() to catch bad input (Alexander Kuleshov) To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: christos Date: Wed Nov 27 17:56:09 UTC 2019 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Use strtoi instead of atoi() to catch bad input (Alexander Kuleshov) To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.39 src/usr.sbin/usbdevs/usbdevs.c:1.40 --- src/usr.sbin/usbdevs/usbdevs.c:1.39 Tue Nov 12 02:41:50 2019 +++ src/usr.sbin/usbdevs/usbdevs.c Wed Nov 27 12:56:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.39 2019/11/12 07:41:50 mrg Exp $ */ +/* $NetBSD: usbdevs.c,v 1.40 2019/11/27 17:56:08 christos Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: usbdevs.c,v 1.39 2019/11/12 07:41:50 mrg Exp $"); +__RCSID("$NetBSD: usbdevs.c,v 1.40 2019/11/27 17:56:08 christos Exp $"); #endif #include @@ -48,6 +48,7 @@ __RCSID("$NetBSD: usbdevs.c,v 1.39 2019/ #include #include #include +#include #include @@ -367,7 +368,7 @@ getusbcount_device(int fd, const char *d int main(int argc, char **argv) { - int ch, i, f; + int ch, i, f, error; char buf[50]; char *dev = NULL; int addr = -1; @@ -376,7 +377,13 @@ main(int argc, char **argv) while ((ch = getopt(argc, argv, "a:df:v?")) != -1) { switch(ch) { case 'a': - addr = atoi(optarg); + addr = strtoi(optarg, NULL, 10, 0, USB_MAX_DEVICES - 1, + ); + if (error) { +errc(EXIT_FAILURE, error, +"Bad value for device address: `%s'", +optarg); + } break; case 'd': showdevs++; @@ -429,5 +436,5 @@ main(int argc, char **argv) else err(1, "%s", dev); } - exit(EXIT_SUCCESS); + return EXIT_SUCCESS; }
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: mrg Date: Tue Nov 12 07:41:50 UTC 2019 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: dynamically calculate the list of usb hubs from drvctl if available. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: mrg Date: Tue Nov 12 07:41:50 UTC 2019 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: dynamically calculate the list of usb hubs from drvctl if available. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.38 src/usr.sbin/usbdevs/usbdevs.c:1.39 --- src/usr.sbin/usbdevs/usbdevs.c:1.38 Thu Oct 24 18:18:00 2019 +++ src/usr.sbin/usbdevs/usbdevs.c Tue Nov 12 07:41:50 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.38 2019/10/24 18:18:00 kamil Exp $ */ +/* $NetBSD: usbdevs.c,v 1.39 2019/11/12 07:41:50 mrg Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -31,13 +31,15 @@ #include #ifndef lint -__RCSID("$NetBSD: usbdevs.c,v 1.38 2019/10/24 18:18:00 kamil Exp $"); +__RCSID("$NetBSD: usbdevs.c,v 1.39 2019/11/12 07:41:50 mrg Exp $"); #endif +#include +#include + #include #include #include -#include #include #include #include @@ -45,6 +47,8 @@ __RCSID("$NetBSD: usbdevs.c,v 1.38 2019/ #include #include #include +#include + #include #define USBDEV "/dev/usb" @@ -316,6 +320,50 @@ dumpone(char *name, int f, int addr) usbdump(f); } +static int +getusbcount_device(int fd, const char *dev, int depth) +{ + struct devlistargs laa = { + .l_childname = NULL, + .l_children = 0, + }; + size_t i; + size_t children; + int nbusses = 0; + + if (depth && (dev == NULL || *dev == '\0')) + return 0; + + /* + * Look for children that match "usb[0-9]*". Could maybe + * simply return 1 here, but there's always a chance that + * someone has eg, a USB to PCI bridge, with a USB + * controller behind PCI. + */ + if (strncmp(dev, "usb", 3) == 0 && isdigit((int)dev[3])) + nbusses++; + + strlcpy(laa.l_devname, dev, sizeof(laa.l_devname)); + + if (ioctl(fd, DRVLISTDEV, ) == -1) + err(EXIT_FAILURE, "DRVLISTDEV"); + children = laa.l_children; + + laa.l_childname = malloc(children * sizeof(laa.l_childname[0])); + if (laa.l_childname == NULL) + err(EXIT_FAILURE, "out of memory"); + if (ioctl(fd, DRVLISTDEV, ) == -1) + err(EXIT_FAILURE, "DRVLISTDEV"); + if (laa.l_children > children) + err(EXIT_FAILURE, "DRVLISTDEV: number of children grew"); + + for (i = 0; i < laa.l_children; i++) { + nbusses += getusbcount_device(fd, laa.l_childname[i], depth+1); + } + + return nbusses; +} + int main(int argc, char **argv) { @@ -348,7 +396,17 @@ main(int argc, char **argv) argv += optind; if (dev == NULL) { - for (ncont = 0, i = 0; i < 16; i++) { + int nbusses; + int fd = open(DRVCTLDEV, O_RDONLY, 0); + + /* If no drvctl configured, default to 16. */ + if (fd != -1) + nbusses = getusbcount_device(fd, "", 0); + else + nbusses = 16; + close(fd); + + for (ncont = 0, i = 0; i < nbusses; i++) { snprintf(buf, sizeof(buf), "%s%d", USBDEV, i); f = open(buf, O_RDONLY); if (f >= 0) {
re: CVS commit: src/usr.sbin/usbdevs
> On further thought, I think your patch won't work correctly in cases > where USB controllers are detached. For example, if you attach usb0 > and usb1, and then detach usb0, getusbcount_device() will return 1, > and usbdevs will try to list devices only on the detached usb0, and > not on the still attached usb1. good point. i'll re-think...including your suggestion about notifying the user about missing devices. thanks! .mrg.
re: CVS commit: src/usr.sbin/usbdevs
Matthew, On further thought, I think your patch won't work correctly in cases where USB controllers are detached. For example, if you attach usb0 and usb1, and then detach usb0, getusbcount_device() will return 1, and usbdevs will try to list devices only on the detached usb0, and not on the still attached usb1. -- Andreas Gustafsson, g...@netbsd.org
re: CVS commit: src/usr.sbin/usbdevs
Hi mrg You wrote: > > Look for up to 16 USB controllers, to match the number of device nodes > > now created by MAKEDEV. > > thanks for doing this. you inspired me to get usbdevs to get the > count from drvctl(8) if available, so next time we don't have to > patch it again. based upon the code in drvctl(8). > > what do you think? > >https://www.netbsd.org/~mrg/usbdevs.anycount.diff Thanks for improving on my commit. Your patch looks correct as far as I can see, but rather complicated for what it does. Couldn't we get the same end result simply by looping until opening /dev/usbN yields ENOENT? Or alternatively, if we do spend the effort to walk the device tree, we should use the information gained from that to full advantage by issuing warnings about missing /dev/usbN device nodes rather than just silently ignoring the affected controllers. -- Andreas Gustafsson, g...@netbsd.org
re: CVS commit: src/usr.sbin/usbdevs
"Andreas Gustafsson" writes: > Module Name: src > Committed By: gson > Date: Sat Sep 21 16:22:25 UTC 2019 > > Modified Files: > src/usr.sbin/usbdevs: usbdevs.c > > Log Message: > Look for up to 16 USB controllers, to match the number of device nodes > now created by MAKEDEV. thanks for doing this. you inspired me to get usbdevs to get the count from drvctl(8) if available, so next time we don't have to patch it again. based upon the code in drvctl(8). what do you think? https://www.netbsd.org/~mrg/usbdevs.anycount.diff thanks. .mrg.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: gson Date: Sat Sep 21 16:22:25 UTC 2019 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Look for up to 16 USB controllers, to match the number of device nodes now created by MAKEDEV. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: gson Date: Sat Sep 21 16:22:25 UTC 2019 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Look for up to 16 USB controllers, to match the number of device nodes now created by MAKEDEV. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.36 src/usr.sbin/usbdevs/usbdevs.c:1.37 --- src/usr.sbin/usbdevs/usbdevs.c:1.36 Thu Jul 5 19:46:58 2018 +++ src/usr.sbin/usbdevs/usbdevs.c Sat Sep 21 16:22:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.36 2018/07/05 19:46:58 jmcneill Exp $ */ +/* $NetBSD: usbdevs.c,v 1.37 2019/09/21 16:22:25 gson Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: usbdevs.c,v 1.36 2018/07/05 19:46:58 jmcneill Exp $"); +__RCSID("$NetBSD: usbdevs.c,v 1.37 2019/09/21 16:22:25 gson Exp $"); #endif #include @@ -347,7 +347,7 @@ main(int argc, char **argv) argv += optind; if (dev == NULL) { - for (ncont = 0, i = 0; i < 10; i++) { + for (ncont = 0, i = 0; i < 16; i++) { snprintf(buf, sizeof(buf), "%s%d", USBDEV, i); f = open(buf, O_RDONLY); if (f >= 0) {
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: jmcneill Date: Thu Jul 5 19:46:58 UTC 2018 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Print USB_SPEED_SUPER_PLUS capability if present To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.35 src/usr.sbin/usbdevs/usbdevs.c:1.36 --- src/usr.sbin/usbdevs/usbdevs.c:1.35 Wed Sep 7 08:09:59 2016 +++ src/usr.sbin/usbdevs/usbdevs.c Thu Jul 5 19:46:58 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.35 2016/09/07 08:09:59 skrll Exp $ */ +/* $NetBSD: usbdevs.c,v 1.36 2018/07/05 19:46:58 jmcneill Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: usbdevs.c,v 1.35 2016/09/07 08:09:59 skrll Exp $"); +__RCSID("$NetBSD: usbdevs.c,v 1.36 2018/07/05 19:46:58 jmcneill Exp $"); #endif #include @@ -222,6 +222,7 @@ usbdev(int f, int a, int rec) case USB_SPEED_FULL: printf("full speed, "); break; case USB_SPEED_HIGH: printf("high speed, "); break; case USB_SPEED_SUPER: printf("super speed, "); break; + case USB_SPEED_SUPER_PLUS: printf("super speed+, "); break; default: break; } if (di.udi_power)
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: jmcneill Date: Thu Jul 5 19:46:58 UTC 2018 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Print USB_SPEED_SUPER_PLUS capability if present To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: skrll Date: Wed Sep 7 08:10:00 UTC 2016 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Fix previous... handle hub ports To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.34 src/usr.sbin/usbdevs/usbdevs.c:1.35 --- src/usr.sbin/usbdevs/usbdevs.c:1.34 Wed Sep 7 08:05:02 2016 +++ src/usr.sbin/usbdevs/usbdevs.c Wed Sep 7 08:09:59 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.34 2016/09/07 08:05:02 skrll Exp $ */ +/* $NetBSD: usbdevs.c,v 1.35 2016/09/07 08:09:59 skrll Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: usbdevs.c,v 1.34 2016/09/07 08:05:02 skrll Exp $"); +__RCSID("$NetBSD: usbdevs.c,v 1.35 2016/09/07 08:09:59 skrll Exp $"); #endif #include @@ -205,7 +205,7 @@ static void usbdev(int f, int a, int rec) { struct usb_device_info di; - int e, p, i; + int e, i; di.udi_addr = a; e = ioctl(f, USB_DEVICEINFO, ); @@ -261,7 +261,10 @@ usbdev(int f, int a, int rec) } if (!rec) return; - for (p = 0; p < di.udi_nports && p < __arraycount(di.udi_ports); p++) { + + unsigned int nports = di.udi_nports; + + for (unsigned int p = 0; p < nports && p < __arraycount(di.udi_ports); p++) { int s = di.udi_ports[p]; if (s >= USB_MAX_DEVICES) { if (verbose) {
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: skrll Date: Wed Sep 7 08:10:00 UTC 2016 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Fix previous... handle hub ports To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: skrll Date: Wed Sep 7 08:05:02 UTC 2016 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Don't read beyond the end of the array when given a overly large number of ports on a hub. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.33 src/usr.sbin/usbdevs/usbdevs.c:1.34 --- src/usr.sbin/usbdevs/usbdevs.c:1.33 Fri Sep 2 05:59:04 2016 +++ src/usr.sbin/usbdevs/usbdevs.c Wed Sep 7 08:05:02 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.33 2016/09/02 05:59:04 skrll Exp $ */ +/* $NetBSD: usbdevs.c,v 1.34 2016/09/07 08:05:02 skrll Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: usbdevs.c,v 1.33 2016/09/02 05:59:04 skrll Exp $"); +__RCSID("$NetBSD: usbdevs.c,v 1.34 2016/09/07 08:05:02 skrll Exp $"); #endif #include @@ -261,7 +261,7 @@ usbdev(int f, int a, int rec) } if (!rec) return; - for (p = 0; p < di.udi_nports; p++) { + for (p = 0; p < di.udi_nports && p < __arraycount(di.udi_ports); p++) { int s = di.udi_ports[p]; if (s >= USB_MAX_DEVICES) { if (verbose) {
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: skrll Date: Wed Sep 7 08:05:02 UTC 2016 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Don't read beyond the end of the array when given a overly large number of ports on a hub. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: skrll Date: Fri Sep 2 05:59:05 UTC 2016 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Add __RCDIS To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.32 src/usr.sbin/usbdevs/usbdevs.c:1.33 --- src/usr.sbin/usbdevs/usbdevs.c:1.32 Sun Jun 26 07:10:24 2016 +++ src/usr.sbin/usbdevs/usbdevs.c Fri Sep 2 05:59:04 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.32 2016/06/26 07:10:24 mlelstv Exp $ */ +/* $NetBSD: usbdevs.c,v 1.33 2016/09/02 05:59:04 skrll Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -29,6 +29,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include +#ifndef lint +__RCSID("$NetBSD: usbdevs.c,v 1.33 2016/09/02 05:59:04 skrll Exp $"); +#endif + #include #include #include
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: skrll Date: Fri Sep 2 05:59:05 UTC 2016 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Add __RCDIS To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: mlelstv Date: Sun Jun 26 07:10:24 UTC 2016 Modified Files: src/usr.sbin/usbdevs: usbdevs.8 usbdevs.c Log Message: Print release also in hex. Print device class information if -v is used twice. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/usbdevs/usbdevs.8 cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.8 diff -u src/usr.sbin/usbdevs/usbdevs.8:1.9 src/usr.sbin/usbdevs/usbdevs.8:1.10 --- src/usr.sbin/usbdevs/usbdevs.8:1.9 Mon Aug 15 14:31:24 2011 +++ src/usr.sbin/usbdevs/usbdevs.8 Sun Jun 26 07:10:24 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: usbdevs.8,v 1.9 2011/08/15 14:31:24 wiz Exp $ +.\" $NetBSD: usbdevs.8,v 1.10 2016/06/26 07:10:24 mlelstv Exp $ .\" .\" Copyright (c) 1999 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -53,7 +53,7 @@ Show the device drivers associated with .It Fl f Ar dev Only print information for the given USB controller. .It Fl v -Be verbose. +Be verbose, more information is given if used twice. .El .Sh FILES .Bl -tag -width Pa Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.31 src/usr.sbin/usbdevs/usbdevs.c:1.32 --- src/usr.sbin/usbdevs/usbdevs.c:1.31 Tue Aug 12 13:40:07 2014 +++ src/usr.sbin/usbdevs/usbdevs.c Sun Jun 26 07:10:24 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.31 2014/08/12 13:40:07 skrll Exp $ */ +/* $NetBSD: usbdevs.c,v 1.32 2016/06/26 07:10:24 mlelstv Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -47,7 +47,13 @@ static int verbose = 0; static int showdevs = 0; +struct stringtable { + int row, col; + const char *string; +}; + __dead static void usage(void); +static void getstrings(const struct stringtable *, int, int, const char **, const char **); static void usbdev(int f, int a, int rec); static void usbdump(int f); static void dumpone(char *name, int f, int addr); @@ -92,6 +98,104 @@ u2t(const char *utf8str, char *termstr) strcpy(termstr, "(invalid)"); } +struct stringtable class_strings[] = { + { UICLASS_UNSPEC, -1, "Unspecified" }, + + { UICLASS_AUDIO, -1, "Audio" }, + { UICLASS_AUDIO, UISUBCLASS_AUDIOCONTROL, "Audio Control" }, + { UICLASS_AUDIO, UISUBCLASS_AUDIOSTREAM, "Audio Streaming" }, + { UICLASS_AUDIO, UISUBCLASS_MIDISTREAM, "MIDI Streaming" }, + + { UICLASS_CDC, -1, "Communications and CDC Control" }, + { UICLASS_CDC, UISUBCLASS_DIRECT_LINE_CONTROL_MODEL, "Direct Line" }, + { UICLASS_CDC, UISUBCLASS_ABSTRACT_CONTROL_MODEL, "Abstract" }, + { UICLASS_CDC, UISUBCLASS_TELEPHONE_CONTROL_MODEL, "Telephone" }, + { UICLASS_CDC, UISUBCLASS_MULTICHANNEL_CONTROL_MODEL, "Multichannel" }, + { UICLASS_CDC, UISUBCLASS_CAPI_CONTROLMODEL, "CAPI" }, + { UICLASS_CDC, UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL, "Ethernet Networking" }, + { UICLASS_CDC, UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL, "ATM Networking" }, + + { UICLASS_HID, -1, "Human Interface Device" }, + { UICLASS_HID, UISUBCLASS_BOOT, "Boot" }, + + { UICLASS_PHYSICAL,-1, "Physical" }, + + { UICLASS_IMAGE, -1, "Image" }, + + { UICLASS_PRINTER, -1, "Printer" }, + { UICLASS_PRINTER, UISUBCLASS_PRINTER, "Printer" }, + + { UICLASS_MASS,-1, "Mass Storage" }, + { UICLASS_MASS,UISUBCLASS_RBC, "RBC" }, + { UICLASS_MASS,UISUBCLASS_SFF8020I, "SFF8020I" }, + { UICLASS_MASS,UISUBCLASS_QIC157, "QIC157" }, + { UICLASS_MASS,UISUBCLASS_UFI, "UFI" }, + { UICLASS_MASS,UISUBCLASS_SFF8070I, "SFF8070I" }, + { UICLASS_MASS,UISUBCLASS_SCSI, "SCSI" }, + { UICLASS_MASS,UISUBCLASS_SCSI, "SCSI" }, + + { UICLASS_HUB, -1, "Hub" }, + { UICLASS_HUB, UISUBCLASS_HUB, "Hub" }, + + { UICLASS_CDC_DATA,-1, "CDC-Data" }, + { UICLASS_CDC_DATA,UISUBCLASS_DATA, "Data" }, + + { UICLASS_SMARTCARD, -1, "Smart Card" }, + + { UICLASS_SECURITY,-1, "Content Security" }, + + { UICLASS_VIDEO, -1, "Video" }, + { UICLASS_VIDEO, UISUBCLASS_VIDEOCONTROL, "Video Control" }, + { UICLASS_VIDEO, UISUBCLASS_VIDEOSTREAMING, "Video Streaming" }, + { UICLASS_VIDEO, UISUBCLASS_VIDEOCOLLECTION, "Video Collection" }, + +#ifdef notyet + { UICLASS_HEALTHCARE, -1, "Personal Healthcare" }, + { UICLASS_AVDEVICE,-1, "Audio/Video Device" }, + { UICLASS_BILLBOARD, -1, "Billboard" }, +#endif + + { UICLASS_DIAGNOSTIC, -1, "Diagnostic" }, + { UICLASS_WIRELESS,-1, "Wireless" }, + { UICLASS_WIRELESS,UISUBCLASS_RF, "Radio Frequency" }, + +#ifdef notyet + { UICLASS_MISC,-1, "Miscellaneous" }, +#endif + + { UICLASS_APPL_SPEC, -1, "Application Specific" }, + { UICLASS_APPL_SPEC, UISUBCLASS_FIRMWARE_DOWNLOAD, "Firmware Download" }, + { UICLASS_APPL_SPEC, UISUBCLASS_IRDA,
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: mlelstv Date: Sun Jun 26 07:10:24 UTC 2016 Modified Files: src/usr.sbin/usbdevs: usbdevs.8 usbdevs.c Log Message: Print release also in hex. Print device class information if -v is used twice. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/usbdevs/usbdevs.8 cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: skrll Date: Tue Aug 12 13:40:07 UTC 2014 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Report super speed devices. From Takahiro HAYASHI. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.30 src/usr.sbin/usbdevs/usbdevs.c:1.31 --- src/usr.sbin/usbdevs/usbdevs.c:1.30 Sat Sep 14 14:07:56 2013 +++ src/usr.sbin/usbdevs/usbdevs.c Tue Aug 12 13:40:07 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.30 2013/09/14 14:07:56 jakllsch Exp $ */ +/* $NetBSD: usbdevs.c,v 1.31 2014/08/12 13:40:07 skrll Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -112,6 +112,7 @@ usbdev(int f, int a, int rec) case USB_SPEED_LOW: printf(low speed, ); break; case USB_SPEED_FULL: printf(full speed, ); break; case USB_SPEED_HIGH: printf(high speed, ); break; + case USB_SPEED_SUPER: printf(super speed, ); break; default: break; } if (di.udi_power)
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: skrll Date: Tue Aug 12 13:40:07 UTC 2014 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Report super speed devices. From Takahiro HAYASHI. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: jakllsch Date: Sat Sep 14 14:07:56 UTC 2013 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Try to dump device at address 0. Allows dumping of xhci(4) root hub. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.29 src/usr.sbin/usbdevs/usbdevs.c:1.30 --- src/usr.sbin/usbdevs/usbdevs.c:1.29 Mon Jul 8 14:47:18 2013 +++ src/usr.sbin/usbdevs/usbdevs.c Sat Sep 14 14:07:56 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.29 2013/07/08 14:47:18 jakllsch Exp $ */ +/* $NetBSD: usbdevs.c,v 1.30 2013/09/14 14:07:56 jakllsch Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -174,7 +174,7 @@ usbdump(int f) { int a; - for (a = 1; a USB_MAX_DEVICES; a++) { + for (a = 0; a USB_MAX_DEVICES; a++) { if (!done[a]) usbdev(f, a, 1); } @@ -187,7 +187,7 @@ dumpone(char *name, int f, int addr) printf(Controller %s:\n, name); indent = 0; memset(done, 0, sizeof done); - if (addr) + if (addr = 0) usbdev(f, addr, 0); else usbdump(f); @@ -199,7 +199,7 @@ main(int argc, char **argv) int ch, i, f; char buf[50]; char *dev = NULL; - int addr = 0; + int addr = -1; int ncont; while ((ch = getopt(argc, argv, a:df:v?)) != -1) {
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: jakllsch Date: Sat Sep 14 14:07:56 UTC 2013 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Try to dump device at address 0. Allows dumping of xhci(4) root hub. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: jakllsch Date: Mon Jul 8 14:47:18 UTC 2013 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Use symbolic constants EXIT_SUCCESS, EXIT_FAILURE, and NULL where appropriate. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.28 src/usr.sbin/usbdevs/usbdevs.c:1.29 --- src/usr.sbin/usbdevs/usbdevs.c:1.28 Tue Aug 30 20:51:29 2011 +++ src/usr.sbin/usbdevs/usbdevs.c Mon Jul 8 14:47:18 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.28 2011/08/30 20:51:29 joerg Exp $ */ +/* $NetBSD: usbdevs.c,v 1.29 2013/07/08 14:47:18 jakllsch Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ usage(void) fprintf(stderr, usage: %s [-dv] [-a addr] [-f dev]\n, getprogname()); - exit(1); + exit(EXIT_FAILURE); } static char done[USB_MAX_DEVICES]; @@ -198,7 +198,7 @@ main(int argc, char **argv) { int ch, i, f; char buf[50]; - char *dev = 0; + char *dev = NULL; int addr = 0; int ncont; @@ -224,7 +224,7 @@ main(int argc, char **argv) argc -= optind; argv += optind; - if (dev == 0) { + if (dev == NULL) { for (ncont = 0, i = 0; i 10; i++) { snprintf(buf, sizeof(buf), %s%d, USBDEV, i); f = open(buf, O_RDONLY); @@ -248,5 +248,5 @@ main(int argc, char **argv) else err(1, %s, dev); } - exit(0); + exit(EXIT_SUCCESS); }
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: jakllsch Date: Mon Jul 8 14:47:18 UTC 2013 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Use symbolic constants EXIT_SUCCESS, EXIT_FAILURE, and NULL where appropriate. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: joerg Date: Tue Aug 30 20:51:29 UTC 2011 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: static + __dead To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.27 src/usr.sbin/usbdevs/usbdevs.c:1.28 --- src/usr.sbin/usbdevs/usbdevs.c:1.27 Mon Aug 15 14:31:58 2011 +++ src/usr.sbin/usbdevs/usbdevs.c Tue Aug 30 20:51:29 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.27 2011/08/15 14:31:58 wiz Exp $ */ +/* $NetBSD: usbdevs.c,v 1.28 2011/08/30 20:51:29 joerg Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -44,17 +44,16 @@ #define USBDEV /dev/usb -int verbose = 0; -int showdevs = 0; +static int verbose = 0; +static int showdevs = 0; -void usage(void); -void usbdev(int f, int a, int rec); -void usbdump(int f); -void dumpone(char *name, int f, int addr); -int main(int, char **); +__dead static void usage(void); +static void usbdev(int f, int a, int rec); +static void usbdump(int f); +static void dumpone(char *name, int f, int addr); -void -usage() +static void +usage(void) { fprintf(stderr, usage: %s [-dv] [-a addr] [-f dev]\n, @@ -62,10 +61,10 @@ exit(1); } -char done[USB_MAX_DEVICES]; -int indent; +static char done[USB_MAX_DEVICES]; +static int indent; #define MAXLEN USB_MAX_ENCODED_STRING_LEN /* assume can't grow over UTF-8 */ -char vendor[MAXLEN], product[MAXLEN], serial[MAXLEN]; +static char vendor[MAXLEN], product[MAXLEN], serial[MAXLEN]; static void u2t(const char *utf8str, char *termstr) @@ -93,7 +92,7 @@ strcpy(termstr, (invalid)); } -void +static void usbdev(int f, int a, int rec) { struct usb_device_info di; @@ -170,7 +169,7 @@ } } -void +static void usbdump(int f) { int a; @@ -181,7 +180,7 @@ } } -void +static void dumpone(char *name, int f, int addr) { if (verbose)
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: joerg Date: Tue Aug 30 20:51:29 UTC 2011 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: static + __dead To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: tnn Date: Mon Aug 15 14:20:08 UTC 2011 Modified Files: src/usr.sbin/usbdevs: usbdevs.8 Log Message: Use proper capitalization. Reported on IRC. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/usbdevs/usbdevs.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.8 diff -u src/usr.sbin/usbdevs/usbdevs.8:1.7 src/usr.sbin/usbdevs/usbdevs.8:1.8 --- src/usr.sbin/usbdevs/usbdevs.8:1.7 Wed Apr 30 13:11:03 2008 +++ src/usr.sbin/usbdevs/usbdevs.8 Mon Aug 15 14:20:08 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: usbdevs.8,v 1.7 2008/04/30 13:11:03 martin Exp $ +.\ $NetBSD: usbdevs.8,v 1.8 2011/08/15 14:20:08 tnn Exp $ .\ .\ Copyright (c) 1999 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -27,7 +27,7 @@ .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\ POSSIBILITY OF SUCH DAMAGE. .\ -.Dd October 15, 2000 +.Dd August 15, 2011 .Dt USBDEVS 8 .Os .Sh NAME @@ -48,11 +48,11 @@ The options are as follows: .Bl -tag -width Fl .It Fl a Ar addr -only print information about the device at the given address. +Only print information about the device at the given address. .It Fl d Show the device drivers associated with each device. .It Fl f Ar dev -only print information for the given USB controller. +Only print information for the given USB controller. .It Fl v Be verbose. .El
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: wiz Date: Mon Aug 15 14:31:24 UTC 2011 Modified Files: src/usr.sbin/usbdevs: usbdevs.8 Log Message: Sort options in SYNOPSIS. From Snader_LB. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/usbdevs/usbdevs.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.8 diff -u src/usr.sbin/usbdevs/usbdevs.8:1.8 src/usr.sbin/usbdevs/usbdevs.8:1.9 --- src/usr.sbin/usbdevs/usbdevs.8:1.8 Mon Aug 15 14:20:08 2011 +++ src/usr.sbin/usbdevs/usbdevs.8 Mon Aug 15 14:31:24 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: usbdevs.8,v 1.8 2011/08/15 14:20:08 tnn Exp $ +.\ $NetBSD: usbdevs.8,v 1.9 2011/08/15 14:31:24 wiz Exp $ .\ .\ Copyright (c) 1999 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -35,10 +35,9 @@ .Nd show USB devices connected to the system .Sh SYNOPSIS .Nm +.Op Fl dv .Op Fl a Ar addr -.Op Fl d .Op Fl f Ar dev -.Op Fl v .Sh DESCRIPTION .Nm prints a listing of all USB devices connected to the system
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: wiz Date: Mon Aug 15 14:31:58 UTC 2011 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Sync usage with SYNOPSIS. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.26 src/usr.sbin/usbdevs/usbdevs.c:1.27 --- src/usr.sbin/usbdevs/usbdevs.c:1.26 Tue Feb 2 16:25:30 2010 +++ src/usr.sbin/usbdevs/usbdevs.c Mon Aug 15 14:31:58 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.26 2010/02/02 16:25:30 drochner Exp $ */ +/* $NetBSD: usbdevs.c,v 1.27 2011/08/15 14:31:58 wiz Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ usage() { - fprintf(stderr, usage: %s [-a addr] [-d] [-f dev] [-v]\n, + fprintf(stderr, usage: %s [-dv] [-a addr] [-f dev]\n, getprogname()); exit(1); }
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: tnn Date: Mon Aug 15 14:20:08 UTC 2011 Modified Files: src/usr.sbin/usbdevs: usbdevs.8 Log Message: Use proper capitalization. Reported on IRC. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/usbdevs/usbdevs.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: wiz Date: Mon Aug 15 14:31:24 UTC 2011 Modified Files: src/usr.sbin/usbdevs: usbdevs.8 Log Message: Sort options in SYNOPSIS. From Snader_LB. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/usbdevs/usbdevs.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: wiz Date: Mon Aug 15 14:31:58 UTC 2011 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: Sync usage with SYNOPSIS. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/usbdevs
Module Name:src Committed By: drochner Date: Tue Feb 2 16:25:31 UTC 2010 Modified Files: src/usr.sbin/usbdevs: usbdevs.c Log Message: The structure returned by USB_DEVICEINFO has the vendor/device strings UTF-8 encoded now. We can't simply print this to a terminal, so convert it to the current codeset first. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/usbdevs/usbdevs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/usbdevs/usbdevs.c diff -u src/usr.sbin/usbdevs/usbdevs.c:1.25 src/usr.sbin/usbdevs/usbdevs.c:1.26 --- src/usr.sbin/usbdevs/usbdevs.c:1.25 Mon Apr 28 20:24:17 2008 +++ src/usr.sbin/usbdevs/usbdevs.c Tue Feb 2 16:25:30 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdevs.c,v 1.25 2008/04/28 20:24:17 martin Exp $ */ +/* $NetBSD: usbdevs.c,v 1.26 2010/02/02 16:25:30 drochner Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -37,6 +37,9 @@ #include unistd.h #include err.h #include errno.h +#include locale.h +#include langinfo.h +#include iconv.h #include dev/usb/usb.h #define USBDEV /dev/usb @@ -61,6 +64,34 @@ char done[USB_MAX_DEVICES]; int indent; +#define MAXLEN USB_MAX_ENCODED_STRING_LEN /* assume can't grow over UTF-8 */ +char vendor[MAXLEN], product[MAXLEN], serial[MAXLEN]; + +static void +u2t(const char *utf8str, char *termstr) +{ + static iconv_t ic; + static int iconv_inited = 0; + size_t insz, outsz, icres; + + if (!iconv_inited) { + setlocale(LC_ALL, ); + ic = iconv_open(nl_langinfo(CODESET), UTF-8); + if (ic == (iconv_t)-1) + ic = iconv_open(ASCII, UTF-8); /* g.c.d. */ + iconv_inited = 1; + } + if (ic != (iconv_t)-1) { + insz = strlen(utf8str); + outsz = MAXLEN - 1; + icres = iconv(ic, utf8str, insz, termstr, outsz); + if (icres != (size_t)-1) { + *termstr = '\0'; + return; + } + } + strcpy(termstr, (invalid)); +} void usbdev(int f, int a, int rec) @@ -93,14 +124,17 @@ else printf(unconfigured, ); } + u2t(di.udi_product, product); + u2t(di.udi_vendor, vendor); + u2t(di.udi_serial, serial); if (verbose) { printf(%s(0x%04x), %s(0x%04x), rev %s, - di.udi_product, di.udi_productNo, - di.udi_vendor, di.udi_vendorNo, di.udi_release); + product, di.udi_productNo, + vendor, di.udi_vendorNo, di.udi_release); if (di.udi_serial[0]) - printf(, serial %s, di.udi_serial); + printf(, serial %s, serial); } else - printf(%s, %s, di.udi_product, di.udi_vendor); + printf(%s, %s, product, vendor); printf(\n); if (showdevs) { for (i = 0; i USB_MAX_DEVNAMES; i++)