Skip to content

Commit

Permalink
7593 lsdev device name section headers should be printed by dv_print …
Browse files Browse the repository at this point in the history
…callback.

Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
  • Loading branch information
tsoome authored and richlowe committed Dec 4, 2016
1 parent 5b5a71c commit 502b33a
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 27 deletions.
3 changes: 0 additions & 3 deletions usr/src/boot/sys/boot/common/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 12 additions & 10 deletions usr/src/boot/sys/boot/common/dev_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down
11 changes: 8 additions & 3 deletions usr/src/boot/sys/boot/common/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"));
}
4 changes: 4 additions & 0 deletions usr/src/boot/sys/boot/efi/libefi/efinet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions usr/src/boot/sys/boot/efi/libefi/efipart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 11 additions & 4 deletions usr/src/boot/sys/boot/i386/libfirewire/firewire.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions usr/src/boot/sys/boot/i386/libi386/bioscd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions usr/src/boot/sys/boot/i386/libi386/biosdisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions usr/src/boot/sys/boot/i386/libi386/pxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
11 changes: 9 additions & 2 deletions usr/src/boot/sys/boot/uboot/lib/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions usr/src/boot/sys/boot/usb/storage/umass_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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");
Expand Down
6 changes: 5 additions & 1 deletion usr/src/boot/sys/boot/userboot/userboot/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
11 changes: 9 additions & 2 deletions usr/src/boot/sys/boot/userboot/userboot/userboot_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions usr/src/boot/sys/boot/zfs/zfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit 502b33a

Please sign in to comment.