From 502b33a50609aec2d2a1f0465da1ad3bac47d74a Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Fri, 18 Nov 2016 15:26:15 +0200 Subject: [PATCH] 7593 lsdev device name section headers should be printed by dv_print callback. Reviewed by: Robert Mustacchi Reviewed by: Yuri Pankov Approved by: Richard Lowe --- usr/src/boot/sys/boot/common/commands.c | 3 --- usr/src/boot/sys/boot/common/dev_net.c | 22 ++++++++++++---------- usr/src/boot/sys/boot/common/md.c | 11 ++++++++--- usr/src/boot/sys/boot/efi/libefi/efinet.c | 4 ++++ usr/src/boot/sys/boot/efi/libefi/efipart.c | 4 ++++ usr/src/boot/sys/boot/i386/libfirewire/firewire.c | 15 +++++++++++---- usr/src/boot/sys/boot/i386/libi386/bioscd.c | 7 +++++++ usr/src/boot/sys/boot/i386/libi386/biosdisk.c | 7 +++++++ usr/src/boot/sys/boot/i386/libi386/pxe.c | 3 +++ usr/src/boot/sys/boot/uboot/lib/disk.c | 11 +++++++++-- usr/src/boot/sys/boot/usb/storage/umass_loader.c | 8 ++++++-- usr/src/boot/sys/boot/userboot/userboot/host.c | 6 +++++- .../sys/boot/userboot/userboot/userboot_disk.c | 11 +++++++++-- usr/src/boot/sys/boot/zfs/zfs.c | 7 +++++++ 14 files changed, 92 insertions(+), 27 deletions(-) diff --git a/usr/src/boot/sys/boot/common/commands.c b/usr/src/boot/sys/boot/common/commands.c index cf16d83e8c..65941a2f2b 100644 --- a/usr/src/boot/sys/boot/common/commands.c +++ b/usr/src/boot/sys/boot/common/commands.c @@ -509,9 +509,6 @@ command_lsdev(int argc, char *argv[]) pager_open(); for (i = 0; devsw[i] != NULL; i++) { if (devsw[i]->dv_print != NULL){ - sprintf(line, "%s devices:\n", devsw[i]->dv_name); - if (pager_output(line)) - break; if (devsw[i]->dv_print(verbose)) break; } else { diff --git a/usr/src/boot/sys/boot/common/dev_net.c b/usr/src/boot/sys/boot/common/dev_net.c index 98ae42b33f..0e54e7e6e8 100644 --- a/usr/src/boot/sys/boot/common/dev_net.c +++ b/usr/src/boot/sys/boot/common/dev_net.c @@ -334,28 +334,30 @@ static int net_print(int verbose) { struct netif_driver *drv; - char line[80]; int i, d, cnt; int ret = 0; + if (netif_drivers[0] == NULL) + return (ret); + + printf("%s devices:", netdev.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + cnt = 0; for (d = 0; netif_drivers[d]; d++) { drv = netif_drivers[d]; for (i = 0; i < drv->netif_nifs; i++) { - snprintf(line, 80, "\t%s%d:", "net", cnt++); - ret = pager_output(line); - if (ret != 0) - break; + printf("\t%s%d:", netdev.dv_name, cnt++); if (verbose) { - snprintf(line, 80, " (%s%d)", drv->netif_bname, + printf(" (%s%d)", drv->netif_bname, drv->netif_ifs[i].dif_unit); - ret = pager_output(line); - if (ret != 0) - break; } + if ((ret = pager_output("\n")) != 0) + return (ret); } } - return (ret |= pager_output("\n")); + return (ret); } /* diff --git a/usr/src/boot/sys/boot/common/md.c b/usr/src/boot/sys/boot/common/md.c index a8f092b92b..c9bc52b1d2 100644 --- a/usr/src/boot/sys/boot/common/md.c +++ b/usr/src/boot/sys/boot/common/md.c @@ -63,7 +63,7 @@ static int md_init(void); static int md_strategy(void *, int, daddr_t, size_t, char *, size_t *); static int md_open(struct open_file *, ...); static int md_close(struct open_file *); -static void md_print(int); +static int md_print(int); struct devsw md_dev = { "md", @@ -143,9 +143,14 @@ md_close(struct open_file *f) return ((dev->d_unit != 0) ? ENXIO : 0); } -static void +static int md_print(int verbose) { - printf("MD (%u bytes)\n", MD_IMAGE_SIZE); + printf("%s devices:", md_dev.dv_name); + if (pager_output("\n") != 0) + return (1); + + printf("MD (%u bytes)", MD_IMAGE_SIZE); + return (pager_output("\n")); } diff --git a/usr/src/boot/sys/boot/efi/libefi/efinet.c b/usr/src/boot/sys/boot/efi/libefi/efinet.c index e48b4a4b72..5afa5ffa86 100644 --- a/usr/src/boot/sys/boot/efi/libefi/efinet.c +++ b/usr/src/boot/sys/boot/efi/libefi/efinet.c @@ -329,6 +329,10 @@ efinet_dev_print(int verbose) EFI_HANDLE h; int unit, ret; + printf("%s devices:", efinet_dev.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (unit = 0, h = efi_find_handle(&efinet_dev, 0); h != NULL; h = efi_find_handle(&efinet_dev, ++unit)) { sprintf(line, " %s%d:\n", efinet_dev.dv_name, unit); diff --git a/usr/src/boot/sys/boot/efi/libefi/efipart.c b/usr/src/boot/sys/boot/efi/libefi/efipart.c index c97eb6694a..9ba52bb626 100644 --- a/usr/src/boot/sys/boot/efi/libefi/efipart.c +++ b/usr/src/boot/sys/boot/efi/libefi/efipart.c @@ -182,6 +182,10 @@ efipart_print(int verbose) u_int unit; int ret = 0; + printf("%s devices:", efipart_dev.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (unit = 0, h = efi_find_handle(&efipart_dev, 0); h != NULL; h = efi_find_handle(&efipart_dev, ++unit)) { sprintf(line, " %s%d:", efipart_dev.dv_name, unit); diff --git a/usr/src/boot/sys/boot/i386/libfirewire/firewire.c b/usr/src/boot/sys/boot/i386/libfirewire/firewire.c index 8191a63d8b..4c62145ef2 100644 --- a/usr/src/boot/sys/boot/i386/libfirewire/firewire.c +++ b/usr/src/boot/sys/boot/i386/libfirewire/firewire.c @@ -69,7 +69,7 @@ static int fw_strategy(void *devdata, int flag, daddr_t dblk, size_t size, char *buf, size_t *rsize); static int fw_open(struct open_file *f, ...); static int fw_close(struct open_file *f); -static void fw_print(int verbose); +static int fw_print(int verbose); static void fw_cleanup(void); void fw_enable(void); @@ -148,21 +148,28 @@ fw_init(void) /* * Print information about OHCI chips */ -static void +static int fw_print(int verbose) { - int i; + int i, ret; struct fwohci_softc *sc; + printf("%s devices:", fwohci.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (i = 0; i < MAX_OHCI; i ++) { sc = &fwinfo[i]; if (sc->state == FWOHCI_STATE_DEAD) break; printf("%d: locator=0x%04x devid=0x%08x" - " base_addr=0x%08x handle=0x%08x bus_id=0x%08x\n", + " base_addr=0x%08x handle=0x%08x bus_id=0x%08x", i, sc->locator, sc->devid, sc->base_addr, sc->handle, sc->bus_id); + if ((ret = pager_output("\n")) != 0) + break; } + return (ret); } static int diff --git a/usr/src/boot/sys/boot/i386/libi386/bioscd.c b/usr/src/boot/sys/boot/i386/libi386/bioscd.c index 764fdc7c2e..0d51bd29db 100644 --- a/usr/src/boot/sys/boot/i386/libi386/bioscd.c +++ b/usr/src/boot/sys/boot/i386/libi386/bioscd.c @@ -183,6 +183,13 @@ bc_print(int verbose) char line[80]; int i, ret = 0; + if (nbcinfo == 0) + return (0); + + printf("%s devices:", bioscd.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (i = 0; i < nbcinfo; i++) { sprintf(line, " cd%d: Device 0x%x\n", i, bcinfo[i].bc_sp.sp_devicespec); diff --git a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c index bf11f27e0c..1165facb08 100644 --- a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c +++ b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c @@ -287,6 +287,13 @@ bd_print(int verbose) struct disk_devdesc dev; int i, ret = 0; + if (nbdinfo == 0) + return (0); + + printf("%s devices:", biosdisk.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (i = 0; i < nbdinfo; i++) { snprintf(line, sizeof (line), " disk%d: BIOS drive %c (%ju X %u):\n", i, diff --git a/usr/src/boot/sys/boot/i386/libi386/pxe.c b/usr/src/boot/sys/boot/i386/libi386/pxe.c index cddf8d244e..873b78e8f6 100644 --- a/usr/src/boot/sys/boot/i386/libi386/pxe.c +++ b/usr/src/boot/sys/boot/i386/libi386/pxe.c @@ -377,6 +377,9 @@ pxe_print(int verbose) if (pxe_call == NULL) return (0); + printf("%s devices:", pxedisk.dv_name); + if (pager_output("\n") != 0) + return (1); snprintf(line, sizeof (line), " pxe0: %s:%s\n", inet_ntoa(rootip), rootpath); return (pager_output(line)); diff --git a/usr/src/boot/sys/boot/uboot/lib/disk.c b/usr/src/boot/sys/boot/uboot/lib/disk.c index a8b7853198..22bec208a1 100644 --- a/usr/src/boot/sys/boot/uboot/lib/disk.c +++ b/usr/src/boot/sys/boot/uboot/lib/disk.c @@ -77,7 +77,7 @@ static int stor_strategy(void *, int, daddr_t, size_t, char *, size_t *); static int stor_open(struct open_file *, ...); static int stor_close(struct open_file *); static int stor_ioctl(struct open_file *f, u_long cmd, void *data); -static void stor_print(int); +static int stor_print(int); static void stor_cleanup(void); struct devsw uboot_storage = { @@ -237,13 +237,20 @@ stor_readdev(struct disk_devdesc *dev, daddr_t blk, size_t size, char *buf) return (err); } -static void +static int stor_print(int verbose) { struct disk_devdesc dev; static char line[80]; int i; + if (stor_info_no == 0) + return (ret); + + printf("%s devices:", uboot_storage.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (i = 0; i < stor_info_no; i++) { dev.d_dev = &uboot_storage; dev.d_unit = i; diff --git a/usr/src/boot/sys/boot/usb/storage/umass_loader.c b/usr/src/boot/sys/boot/usb/storage/umass_loader.c index 4311b2b65e..889c779c92 100644 --- a/usr/src/boot/sys/boot/usb/storage/umass_loader.c +++ b/usr/src/boot/sys/boot/usb/storage/umass_loader.c @@ -49,7 +49,7 @@ static int umass_disk_close(struct open_file *); static void umass_disk_cleanup(void); static int umass_disk_ioctl(struct open_file *, u_long, void *); static int umass_disk_strategy(void *, int, daddr_t, size_t, char *, size_t *); -static void umass_disk_print(int); +static int umass_disk_print(int); struct devsw umass_disk = { .dv_name = "umass", @@ -169,11 +169,15 @@ umass_disk_close(struct open_file *f) return (disk_close(dev)); } -static void +static int umass_disk_print(int verbose) { struct disk_devdesc dev; + printf("%s devices:", umass_disk.dv_name); + if (pager_output("\n") != 0) + return (1); + memset(&dev, 0, sizeof(dev)); pager_output(" umass0 UMASS device\n"); diff --git a/usr/src/boot/sys/boot/userboot/userboot/host.c b/usr/src/boot/sys/boot/userboot/userboot/host.c index 81858a989f..db88c61eca 100644 --- a/usr/src/boot/sys/boot/userboot/userboot/host.c +++ b/usr/src/boot/sys/boot/userboot/userboot/host.c @@ -134,11 +134,15 @@ host_dev_init(void) return (0); } -static void +static int host_dev_print(int verbose) { char line[80]; + printf("%s devices:", host_dev.dv_name); + if (pager_output("\n") != 0) + return (1); + sprintf(line, " host%d: Host filesystem\n", 0); pager_output(line); } diff --git a/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c b/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c index bbd9efcc03..156df63878 100644 --- a/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c +++ b/usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c @@ -56,7 +56,7 @@ static int userdisk_strategy(void *devdata, int flag, daddr_t dblk, static int userdisk_open(struct open_file *f, ...); static int userdisk_close(struct open_file *f); static int userdisk_ioctl(struct open_file *f, u_long cmd, void *data); -static void userdisk_print(int verbose); +static int userdisk_print(int verbose); struct devsw userboot_disk = { "disk", @@ -110,13 +110,20 @@ userdisk_cleanup(void) /* * Print information about disks */ -static void +static int userdisk_print(int verbose) { struct disk_devdesc dev; char line[80]; int i; + if (userdisk_maxunit == 0) + return (0); + + printf("%s devices:", userboot_disk.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (i = 0; i < userdisk_maxunit; i++) { sprintf(line, " disk%d: Guest drive image\n", i); pager_output(line); diff --git a/usr/src/boot/sys/boot/zfs/zfs.c b/usr/src/boot/sys/boot/zfs/zfs.c index f8d95662b5..ea6734ff5e 100644 --- a/usr/src/boot/sys/boot/zfs/zfs.c +++ b/usr/src/boot/sys/boot/zfs/zfs.c @@ -525,6 +525,13 @@ zfs_dev_print(int verbose) char line[80]; int ret = 0; + if (STAILQ_EMPTY(&zfs_pools)) + return (0); + + printf("%s devices:", zfs_dev.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + if (verbose) { return (spa_all_status()); } -- 2.11.4.GIT