svn commit: r308827 - in head/sys/boot: common efi/libefi i386/libfirewire i386/libi386 mips/beri/loader pc98/libpc98 uboot/lib usb/storage userboot/userboot zfs
Toomas Soome
tsoome at FreeBSD.org
Sat Nov 19 08:54:24 UTC 2016
Author: tsoome
Date: Sat Nov 19 08:54:21 2016
New Revision: 308827
URL: https://svnweb.freebsd.org/changeset/base/308827
Log:
lsdev device name section headers should be printed by dv_print callback.
lsdev command does walk over devsw list, prints list element name and
will use dv_print() callback to print the device list.
Unfortunately this approach will add unneeded noise when there are no
particular devices detected.
To remove "empty" device section headers, the dv_print() callback
should print the header instead.
In addition, fixed dv_print callback for md module.
Reviewed by: imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D8551
Modified:
head/sys/boot/common/commands.c
head/sys/boot/common/dev_net.c
head/sys/boot/common/md.c
head/sys/boot/efi/libefi/efinet.c
head/sys/boot/efi/libefi/efipart.c
head/sys/boot/i386/libfirewire/firewire.c
head/sys/boot/i386/libi386/bioscd.c
head/sys/boot/i386/libi386/biosdisk.c
head/sys/boot/i386/libi386/pxe.c
head/sys/boot/mips/beri/loader/beri_disk_cfi.c
head/sys/boot/mips/beri/loader/beri_disk_sdcard.c
head/sys/boot/pc98/libpc98/bioscd.c
head/sys/boot/pc98/libpc98/biosdisk.c
head/sys/boot/uboot/lib/disk.c
head/sys/boot/usb/storage/umass_loader.c
head/sys/boot/userboot/userboot/host.c
head/sys/boot/userboot/userboot/userboot_disk.c
head/sys/boot/zfs/zfs.c
Modified: head/sys/boot/common/commands.c
==============================================================================
--- head/sys/boot/common/commands.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/common/commands.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -497,10 +497,8 @@ 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;
- devsw[i]->dv_print(verbose);
+ if (devsw[i]->dv_print(verbose))
+ break;
} else {
sprintf(line, "%s: (unknown)\n", devsw[i]->dv_name);
if (pager_output(line))
Modified: head/sys/boot/common/dev_net.c
==============================================================================
--- head/sys/boot/common/dev_net.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/common/dev_net.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -332,11 +332,18 @@ net_print(int verbose)
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++) {
- printf("\t%s%d:", "net", cnt++);
+ printf("\t%s%d:", netdev.dv_name, cnt++);
if (verbose) {
printf(" (%s%d)", drv->netif_bname,
drv->netif_ifs[i].dif_unit);
Modified: head/sys/boot/common/md.c
==============================================================================
--- head/sys/boot/common/md.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/common/md.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -63,7 +63,7 @@ static int md_init(void);
static int md_strategy(void *, int, daddr_t, size_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"));
}
Modified: head/sys/boot/efi/libefi/efinet.c
==============================================================================
--- head/sys/boot/efi/libefi/efinet.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/efi/libefi/efinet.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -353,6 +353,10 @@ efinet_dev_print(int verbose)
EFI_HANDLE h;
int unit, ret = 0;
+ 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)) {
printf(" %s%d:", efinet_dev.dv_name, unit);
Modified: head/sys/boot/efi/libefi/efipart.c
==============================================================================
--- head/sys/boot/efi/libefi/efipart.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/efi/libefi/efipart.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -172,6 +172,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)) {
snprintf(line, sizeof(line), " %s%d:",
Modified: head/sys/boot/i386/libfirewire/firewire.c
==============================================================================
--- head/sys/boot/i386/libfirewire/firewire.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/i386/libfirewire/firewire.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -155,6 +155,10 @@ fw_print(int verbose)
int i, ret = 0;
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)
Modified: head/sys/boot/i386/libi386/bioscd.c
==============================================================================
--- head/sys/boot/i386/libi386/bioscd.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/i386/libi386/bioscd.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -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++) {
snprintf(line, sizeof(line), " cd%d: Device 0x%x\n", i,
bcinfo[i].bc_sp.sp_devicespec);
Modified: head/sys/boot/i386/libi386/biosdisk.c
==============================================================================
--- head/sys/boot/i386/libi386/biosdisk.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/i386/libi386/biosdisk.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -328,6 +328,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,
Modified: head/sys/boot/i386/libi386/pxe.c
==============================================================================
--- head/sys/boot/i386/libi386/pxe.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/i386/libi386/pxe.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -389,6 +389,9 @@ pxe_print(int verbose)
if (pxe_call == NULL)
return (0);
+ printf("%s devices:", pxedisk.dv_name);
+ if (pager_output("\n") != 0)
+ return (1);
if (verbose) {
snprintf(line, sizeof(line), " pxe0: %s:%s\n",
inet_ntoa(rootip), rootpath);
Modified: head/sys/boot/mips/beri/loader/beri_disk_cfi.c
==============================================================================
--- head/sys/boot/mips/beri/loader/beri_disk_cfi.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/mips/beri/loader/beri_disk_cfi.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -119,6 +119,10 @@ beri_cfi_disk_print(int verbose)
char line[80];
int ret;
+ printf("%s devices:", beri_cfi_disk.dv_name);
+ if ((ret = pager_output("\n")) != 0)
+ return (ret);
+
snprintf(line, sizeof(line), " cfi%d CFI flash device\n", 0);
ret = pager_output(line);
if (ret != 0)
Modified: head/sys/boot/mips/beri/loader/beri_disk_sdcard.c
==============================================================================
--- head/sys/boot/mips/beri/loader/beri_disk_sdcard.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/mips/beri/loader/beri_disk_sdcard.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -125,6 +125,10 @@ beri_sdcard_disk_print(int verbose)
char line[80];
int ret;
+ printf("%s devices:", beri_sdcard_disk.dv_name);
+ if ((ret = pager_output("\n")) != 0)
+ return (ret);
+
snprintf(line, sizeof(line), " sdcard%d Altera SD card drive\n", 0);
ret = pager_output(line);
if (ret != 0)
Modified: head/sys/boot/pc98/libpc98/bioscd.c
==============================================================================
--- head/sys/boot/pc98/libpc98/bioscd.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/pc98/libpc98/bioscd.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -179,6 +179,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);
Modified: head/sys/boot/pc98/libpc98/biosdisk.c
==============================================================================
--- head/sys/boot/pc98/libpc98/biosdisk.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/pc98/libpc98/biosdisk.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -258,6 +258,13 @@ bd_print(int verbose)
struct open_disk *od;
struct pc98_partition *dptr;
+ 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:\n",
i, 'A' + i);
Modified: head/sys/boot/uboot/lib/disk.c
==============================================================================
--- head/sys/boot/uboot/lib/disk.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/uboot/lib/disk.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -245,6 +245,13 @@ stor_print(int verbose)
static char line[80];
int i, ret = 0;
+ 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;
Modified: head/sys/boot/usb/storage/umass_loader.c
==============================================================================
--- head/sys/boot/usb/storage/umass_loader.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/usb/storage/umass_loader.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -175,6 +175,10 @@ 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));
ret = pager_output(" umass0 UMASS device\n");
Modified: head/sys/boot/userboot/userboot/host.c
==============================================================================
--- head/sys/boot/userboot/userboot/host.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/userboot/userboot/host.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -139,6 +139,10 @@ host_dev_print(int verbose)
{
char line[80];
+ printf("%s devices:", host_dev.dv_name);
+ if (pager_output("\n") != 0)
+ return (1);
+
snprintf(line, sizeof(line), " host%d: Host filesystem\n", 0);
return (pager_output(line));
}
Modified: head/sys/boot/userboot/userboot/userboot_disk.c
==============================================================================
--- head/sys/boot/userboot/userboot/userboot_disk.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/userboot/userboot/userboot_disk.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -123,6 +123,13 @@ userdisk_print(int verbose)
char line[80];
int i, ret = 0;
+ 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++) {
snprintf(line, sizeof(line),
" disk%d: Guest drive image\n", i);
Modified: head/sys/boot/zfs/zfs.c
==============================================================================
--- head/sys/boot/zfs/zfs.c Sat Nov 19 08:12:57 2016 (r308826)
+++ head/sys/boot/zfs/zfs.c Sat Nov 19 08:54:21 2016 (r308827)
@@ -521,6 +521,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());
}
More information about the svn-src-all
mailing list