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
This commit is contained in:
parent
2ec31e84cc
commit
77d81a4dab
@ -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))
|
||||
|
@ -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);
|
||||
|
@ -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"));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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:",
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user