aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/devinfo/devinfo.83
-rw-r--r--usr.sbin/devinfo/devinfo.c64
2 files changed, 41 insertions, 26 deletions
diff --git a/usr.sbin/devinfo/devinfo.8 b/usr.sbin/devinfo/devinfo.8
index 7b264d903d59..72fd73dba82c 100644
--- a/usr.sbin/devinfo/devinfo.8
+++ b/usr.sbin/devinfo/devinfo.8
@@ -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
diff --git a/usr.sbin/devinfo/devinfo.c b/usr.sbin/devinfo/devinfo.c
index 5bc97fe8acef..c4ec2eeccfd0 100644
--- a/usr.sbin/devinfo/devinfo.c
+++ b/usr.sbin/devinfo/devinfo.c
@@ -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);