From 5c5ebc1dee30dd44f2d9681d342567e19b16bc25 Mon Sep 17 00:00:00 2001 From: jmcneill Date: Sat, 26 May 2018 10:21:41 +0000 Subject: [PATCH] Add -v flag which prints the full path of each device node when dumping the full tree. --- usr.sbin/ofctl/ofctl.8 | 7 +++++-- usr.sbin/ofctl/ofctl.c | 12 +++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/usr.sbin/ofctl/ofctl.8 b/usr.sbin/ofctl/ofctl.8 index 45ad93d5a536..37470b51cb08 100644 --- a/usr.sbin/ofctl/ofctl.8 +++ b/usr.sbin/ofctl/ofctl.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: ofctl.8,v 1.4 2008/09/25 22:44:51 reed Exp $ +.\" $NetBSD: ofctl.8,v 1.5 2018/05/26 10:21:41 jmcneill Exp $ .\" .\" Copyright (c) 2006 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd September 29, 2006 +.Dd May 26, 2018 .Dt OFCTL 8 .Os .Sh NAME @@ -36,6 +36,7 @@ .Sh SYNOPSIS .Nm .Op Fl p +.Op Fl v .Op Fl f Ar file .Op Ar node .Sh DESCRIPTION @@ -66,6 +67,8 @@ instead of the default .Pa /dev/openfirm . .It Fl p Display each node's properties. +.It Fl v +Display the full path name for each node. .El .Sh FILES .Bl -tag -width "/dev/openprom " diff --git a/usr.sbin/ofctl/ofctl.c b/usr.sbin/ofctl/ofctl.c index 8ca571124d78..ac7a8fabca82 100644 --- a/usr.sbin/ofctl/ofctl.c +++ b/usr.sbin/ofctl/ofctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofctl.c,v 1.12 2015/12/23 13:42:24 jmcneill Exp $ */ +/* $NetBSD: ofctl.c,v 1.13 2018/05/26 10:21:41 jmcneill Exp $ */ /*- * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright (c) 2006, 2007\ The NetBSD Foundation, Inc. All rights reserved."); -__RCSID("$NetBSD: ofctl.c,v 1.12 2015/12/23 13:42:24 jmcneill Exp $"); +__RCSID("$NetBSD: ofctl.c,v 1.13 2018/05/26 10:21:41 jmcneill Exp $"); #endif /* not lint */ #include @@ -62,6 +62,7 @@ static int isstrprint(const char *, size_t, int); static int lflag; static int pflag; +static int vflag; struct of_node { TAILQ_ENTRY(of_node) of_sibling; @@ -500,10 +501,11 @@ main(int argc, char **argv) const char *propfilein = NULL; const char *propfileout = NULL; - while ((c = getopt(argc, argv, "f:lpr:w:")) != EOF) { + while ((c = getopt(argc, argv, "f:lpr:vw:")) != EOF) { switch (c) { case 'l': lflag++; break; case 'p': pflag++; break; + case 'v': vflag++; break; case 'f': file = optarg; break; case 'r': propfilein = optarg; break; case 'w': propfileout = optarg; break; @@ -511,7 +513,7 @@ main(int argc, char **argv) } } if (errflag) - errx(1, "usage: ofctl [-pl] [-f file] [-r propfile] [-w propfile] [node...]"); + errx(1, "usage: ofctl [-plv] [-f file] [-r propfile] [-w propfile] [node...]"); if (propfilein != NULL) { of_proplib = prop_dictionary_internalize_from_file(propfilein); @@ -694,7 +696,7 @@ oflist(int node, const char *parent_device_type, int depth, int len; while (node != 0) { int child; - if (pflag == 0) { + if (pflag == 0 && vflag == 0) { len = ofname(node, of_buf, of_buflen-1); printf("%08x: %*s%s", node, depth * 2, "", (char *) of_buf);