From owner-svn-src-all@freebsd.org Thu Dec 21 19:19:44 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AFA0DE846BB; Thu, 21 Dec 2017 19:19:44 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8697074581; Thu, 21 Dec 2017 19:19:44 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBLJJhnr096001; Thu, 21 Dec 2017 19:19:43 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBLJJhsY095999; Thu, 21 Dec 2017 19:19:43 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201712211919.vBLJJhsY095999@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Thu, 21 Dec 2017 19:19:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327068 - head/usr.sbin/devinfo X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/usr.sbin/devinfo X-SVN-Commit-Revision: 327068 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Dec 2017 19:19:44 -0000 Author: imp Date: Thu Dec 21 19:19:43 2017 New Revision: 327068 URL: https://svnweb.freebsd.org/changeset/base/327068 Log: 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 Modified: head/usr.sbin/devinfo/devinfo.8 head/usr.sbin/devinfo/devinfo.c Modified: head/usr.sbin/devinfo/devinfo.8 ============================================================================== --- head/usr.sbin/devinfo/devinfo.8 Thu Dec 21 18:58:14 2017 (r327067) +++ head/usr.sbin/devinfo/devinfo.8 Thu Dec 21 19:19:43 2017 (r327068) @@ -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 Modified: head/usr.sbin/devinfo/devinfo.c ============================================================================== --- head/usr.sbin/devinfo/devinfo.c Thu Dec 21 18:58:14 2017 (r327067) +++ head/usr.sbin/devinfo/devinfo.c Thu Dec 21 19:19:43 2017 (r327068) @@ -131,6 +131,22 @@ print_device_rman_resources(struct devinfo_rman *rman, 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 __unus 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);