When -v is specified with -p dev, print the same verbose output as
when listing the whole tree. The list, however, is from the requested device to the root (so it backwards from the normal tree). Sponsored by: Netflix
This commit is contained in:
parent
524a12ed10
commit
582f8754ad
@ -39,7 +39,7 @@
|
||||
.Nm
|
||||
.Fl u
|
||||
.Nm
|
||||
.Fl p Ar dev
|
||||
.Fl p Ar dev Op Fl v
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
@ -64,6 +64,7 @@ the IRQ consumers together.
|
||||
Display all devices in the driver tree, not just those that are attached or
|
||||
busy.
|
||||
Without this flag, only those devices that have attached are reported.
|
||||
This flag also displays verbose information about each device.
|
||||
.It Fl p Ar dev
|
||||
Display the path of
|
||||
.Ar dev
|
||||
|
@ -131,6 +131,22 @@ print_device_rman_resources(struct devinfo_rman *rman, void *arg)
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void
|
||||
print_dev(struct devinfo_dev *dev)
|
||||
{
|
||||
|
||||
printf("%s", dev->dd_name[0] ? dev->dd_name : "unknown");
|
||||
if (vflag && *dev->dd_pnpinfo)
|
||||
printf(" pnpinfo %s", dev->dd_pnpinfo);
|
||||
if (vflag && *dev->dd_location)
|
||||
printf(" at %s", dev->dd_location);
|
||||
if (!(dev->dd_flags & DF_ENABLED))
|
||||
printf(" (disabled)");
|
||||
else if (dev->dd_flags & DF_SUSPENDED)
|
||||
printf(" (suspended)");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Print information about a device.
|
||||
*/
|
||||
@ -144,15 +160,7 @@ print_device(struct devinfo_dev *dev, void *arg)
|
||||
indent = (int)(intptr_t)arg;
|
||||
for (i = 0; i < indent; i++)
|
||||
printf(" ");
|
||||
printf("%s", dev->dd_name[0] ? dev->dd_name : "unknown");
|
||||
if (vflag && *dev->dd_pnpinfo)
|
||||
printf(" pnpinfo %s", dev->dd_pnpinfo);
|
||||
if (vflag && *dev->dd_location)
|
||||
printf(" at %s", dev->dd_location);
|
||||
if (!(dev->dd_flags & DF_ENABLED))
|
||||
printf(" (disabled)");
|
||||
else if (dev->dd_flags & DF_SUSPENDED)
|
||||
printf(" (suspended)");
|
||||
print_dev(dev);
|
||||
printf("\n");
|
||||
if (rflag) {
|
||||
ia.indent = indent + 4;
|
||||
@ -197,17 +205,6 @@ print_rman(struct devinfo_rman *rman, void *arg __unused)
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void __dead2
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "%s\n%s\n%s\n",
|
||||
"usage: devinfo [-rv]",
|
||||
" devinfo -u",
|
||||
" devifno -p dev");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
print_path(struct devinfo_dev *dev, void *xname)
|
||||
{
|
||||
@ -215,22 +212,38 @@ print_path(struct devinfo_dev *dev, void *xname)
|
||||
int rv;
|
||||
|
||||
if (strcmp(dev->dd_name, name) == 0) {
|
||||
printf("%s", dev->dd_name);
|
||||
print_dev(dev);
|
||||
if (vflag)
|
||||
printf("\n");
|
||||
return (1);
|
||||
}
|
||||
|
||||
rv = devinfo_foreach_device_child(dev, print_path, xname);
|
||||
if (rv == 1)
|
||||
printf(" %s", dev->dd_name[0] ? dev->dd_name : "unknown");
|
||||
if (rv == 1) {
|
||||
printf(" ");
|
||||
print_dev(dev);
|
||||
if (vflag)
|
||||
printf("\n");
|
||||
}
|
||||
return (rv);
|
||||
}
|
||||
|
||||
static void __dead2
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "%s\n%s\n%s\n",
|
||||
"usage: devinfo [-rv]",
|
||||
" devinfo -u",
|
||||
" devifno -p dev [-v]");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct devinfo_dev *root;
|
||||
int c, uflag;
|
||||
char *path;
|
||||
char *path = NULL;
|
||||
|
||||
uflag = 0;
|
||||
while ((c = getopt(argc, argv, "p:ruv")) != -1) {
|
||||
@ -264,7 +277,8 @@ main(int argc, char *argv[])
|
||||
if (path) {
|
||||
if (devinfo_foreach_device_child(root, print_path, (void *)path) == 0)
|
||||
errx(1, "%s: Not found", path);
|
||||
printf("\n");
|
||||
if (!vflag)
|
||||
printf("\n");
|
||||
} else if (uflag) {
|
||||
/* print resource usage? */
|
||||
devinfo_foreach_rman(print_rman, NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user