summaryrefslogtreecommitdiff
path: root/usr/src/lib
diff options
context:
space:
mode:
authorBryan Cantrill <bryan@oxide.computer>2022-08-20 22:06:33 +0000
committerRobert Mustacchi <rm@fingolfin.org>2022-11-05 13:53:49 +0000
commitb18d44ce328fbdf8d8c82ef1763d30b8a46edfde (patch)
treee2633884e5571aae687d8b00618a8805de7b5e34 /usr/src/lib
parent4f3f3e9a1dee62c031fa67cfe64e11d6dd3fab1b (diff)
downloadillumos-joyent-b18d44ce328fbdf8d8c82ef1763d30b8a46edfde.tar.gz
14535 cfgadm_usb(8) should provide iSerialNumber in -v output
Reviewed by: Robert Mustacchi <rm@fingolfin.org> Reviewed by: Andy Fiddaman <illumos@fiddaman.net> Reviewed by: Marco van Wieringen <mvw@planets.elm.net> Approved by: Dan McDonald <danmcd@mnx.io>
Diffstat (limited to 'usr/src/lib')
-rw-r--r--usr/src/lib/cfgadm_plugins/usb/common/cfga_usb.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/usr/src/lib/cfgadm_plugins/usb/common/cfga_usb.c b/usr/src/lib/cfgadm_plugins/usb/common/cfga_usb.c
index 47976fb058..663cd02f09 100644
--- a/usr/src/lib/cfgadm_plugins/usb/common/cfga_usb.c
+++ b/usr/src/lib/cfgadm_plugins/usb/common/cfga_usb.c
@@ -22,9 +22,9 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+ * Copyright 2022 Oxide Computer Company
*/
-
#include "cfga_usb.h"
@@ -889,12 +889,14 @@ fill_in_ap_info(const char *ap_id, char *info_buf, size_t info_size)
{
char *mfg_str = NULL; /* iManufacturer */
char *prod_str = NULL; /* iProduct */
+ char *serial_str = NULL; /* iSerialNumber */
char *cfg_descr = NULL; /* iConfiguration */
uint_t config; /* curr cfg index */
size_t size; /* tmp stuff */
boolean_t flag; /* wether to print ":" or not */
boolean_t free_mfg_str = B_FALSE;
boolean_t free_prod_str = B_FALSE;
+ boolean_t free_serial_str = B_FALSE;
boolean_t free_cfg_str = B_FALSE;
cfga_usb_ret_t rv = CFGA_USB_OK;
usb_dev_descr_t *dev_descrp = NULL; /* device descriptor */
@@ -938,6 +940,22 @@ fill_in_ap_info(const char *ap_id, char *info_buf, size_t info_size)
free_prod_str = B_TRUE;
}
+ /* iSerialNumber */
+ serial_str = USB_UNDEF_STR;
+ if (dev_descrp->iSerialNumber != 0) {
+ if ((rv = do_control_ioctl(ap_id, USB_DESCR_TYPE_STRING,
+ HUBD_SERIALNO_STR, (void **)&serial_str,
+ &size)) != CFGA_USB_OK) {
+ if (rv == CFGA_USB_ZEROLEN) {
+ rv = CFGA_USB_OK;
+ } else {
+ DPRINTF("getting iSerialNumber failed\n");
+ goto bailout;
+ }
+ }
+ free_serial_str = B_TRUE;
+ }
+
/* Current conifguration */
if ((rv = get_config(ap_id, &config)) != CFGA_USB_OK) {
DPRINTF("get_config failed\n");
@@ -968,8 +986,9 @@ fill_in_ap_info(const char *ap_id, char *info_buf, size_t info_size)
/* Dump local buf into passed-in buf. */
(void) snprintf(info_buf, info_size,
- "Mfg: %s Product: %s NConfigs: %d Config: %d %s%s", mfg_str,
- prod_str, dev_descrp->bNumConfigurations, config,
+ "Mfg: %s Product: %s Serial: %s NConfigs: %d Config: %d %s%s",
+ mfg_str, prod_str, serial_str,
+ dev_descrp->bNumConfigurations, config,
(flag == B_TRUE) ? ": " : "", cfg_descr);
bailout:
@@ -985,6 +1004,10 @@ bailout:
free(prod_str);
}
+ if ((free_serial_str == B_TRUE) && serial_str) {
+ free(serial_str);
+ }
+
if ((free_cfg_str == B_TRUE) && cfg_descr) {
free(cfg_descr);
}