CVS commit: src/usr.sbin/ofctl

2020-06-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jun  6 22:33:23 UTC 2020

Modified Files:
src/usr.sbin/ofctl: ofctl.c

Log Message:
Update for proplib(3) API changes.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/ofctl/ofctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ofctl

2020-06-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jun  6 22:33:23 UTC 2020

Modified Files:
src/usr.sbin/ofctl: ofctl.c

Log Message:
Update for proplib(3) API changes.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/ofctl/ofctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ofctl/ofctl.c
diff -u src/usr.sbin/ofctl/ofctl.c:1.14 src/usr.sbin/ofctl/ofctl.c:1.15
--- src/usr.sbin/ofctl/ofctl.c:1.14	Mon May 28 12:42:45 2018
+++ src/usr.sbin/ofctl/ofctl.c	Sat Jun  6 22:33:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofctl.c,v 1.14 2018/05/28 12:42:45 wiz Exp $	*/
+/*	$NetBSD: ofctl.c,v 1.15 2020/06/06 22:33:23 thorpej 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.14 2018/05/28 12:42:45 wiz Exp $");
+__RCSID("$NetBSD: ofctl.c,v 1.15 2020/06/06 22:33:23 thorpej Exp $");
 #endif /* not lint */
 
 #include 
@@ -108,7 +108,7 @@ of_tree_mkprop(struct of_node *node, pro
 	prop_data_t obj;
 	const char *name;
 
-	name = prop_dictionary_keysym_cstring_nocopy(key);
+	name = prop_dictionary_keysym_value(key);
 	obj = prop_dictionary_get_keysym(propdict, key);
 
 	prop = malloc(sizeof(*prop) + strlen(name) + 1);
@@ -131,8 +131,10 @@ of_tree_mkprop(struct of_node *node, pro
 	of_prop_count++;
 
 	prop->prop_length = prop_data_size(obj);
-	if (prop->prop_length)
-		prop->prop_data = prop_data_data(obj);
+	if (prop->prop_length) {
+		prop->prop_data = malloc(prop->prop_length);
+		prop_data_copy_value(obj, prop->prop_data, prop->prop_length);
+	}
 }
 
 static struct of_node *
@@ -163,7 +165,7 @@ of_tree_fill(prop_dictionary_t dict, str
 	prop_array_t children;
 	unsigned int i, count;
 
-	node->of_nodeid = prop_number_unsigned_integer_value(
+	node->of_nodeid = prop_number_unsigned_value(
 	prop_dictionary_get(dict, "node"));
 
 	propdict = prop_dictionary_get(dict, "properties");
@@ -224,7 +226,7 @@ of_proplib_mkprop(int fd, int nodeid, ch
 		free(ofio.of_buf);
 		return NULL;
 	}
-	obj = prop_data_create_data(ofio.of_buf, ofio.of_buflen);
+	obj = prop_data_create_copy(ofio.of_buf, ofio.of_buflen);
 	free(ofio.of_buf);
 	return obj;
 }
@@ -249,7 +251,7 @@ of_proplib_tree_fill(int fd, int nodeid)
 
 	dict = prop_dictionary_create();
 	prop_dictionary_set(dict, "node",
-	prop_number_create_unsigned_integer(nodeid));
+	prop_number_create_unsigned(nodeid));
 
 	propdict = prop_dictionary_create();
 	for (;;) {



CVS commit: src/usr.sbin/ofctl

2018-05-28 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon May 28 12:42:45 UTC 2018

Modified Files:
src/usr.sbin/ofctl: ofctl.c

Log Message:
Sort options in usage.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/ofctl/ofctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ofctl

2018-05-28 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon May 28 12:42:45 UTC 2018

Modified Files:
src/usr.sbin/ofctl: ofctl.c

Log Message:
Sort options in usage.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/ofctl/ofctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ofctl/ofctl.c
diff -u src/usr.sbin/ofctl/ofctl.c:1.13 src/usr.sbin/ofctl/ofctl.c:1.14
--- src/usr.sbin/ofctl/ofctl.c:1.13	Sat May 26 10:21:41 2018
+++ src/usr.sbin/ofctl/ofctl.c	Mon May 28 12:42:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofctl.c,v 1.13 2018/05/26 10:21:41 jmcneill Exp $	*/
+/*	$NetBSD: ofctl.c,v 1.14 2018/05/28 12:42:45 wiz 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.13 2018/05/26 10:21:41 jmcneill Exp $");
+__RCSID("$NetBSD: ofctl.c,v 1.14 2018/05/28 12:42:45 wiz Exp $");
 #endif /* not lint */
 
 #include 
@@ -513,7 +513,7 @@ main(int argc, char **argv)
 		}
 	}
 	if (errflag)
-		errx(1, "usage: ofctl [-plv] [-f file] [-r propfile] [-w propfile] [node...]");
+		errx(1, "usage: ofctl [-lpv] [-f file] [-r propfile] [-w propfile] [node...]");
 
 	if (propfilein != NULL) {
 		of_proplib = prop_dictionary_internalize_from_file(propfilein);



CVS commit: src/usr.sbin/ofctl

2018-05-28 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon May 28 12:42:02 UTC 2018

Modified Files:
src/usr.sbin/ofctl: ofctl.8

Log Message:
Document -l, -r, and -w, based on input by jmcneill@

Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/ofctl/ofctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ofctl

2018-05-28 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon May 28 12:42:02 UTC 2018

Modified Files:
src/usr.sbin/ofctl: ofctl.8

Log Message:
Document -l, -r, and -w, based on input by jmcneill@

Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/ofctl/ofctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ofctl/ofctl.8
diff -u src/usr.sbin/ofctl/ofctl.8:1.6 src/usr.sbin/ofctl/ofctl.8:1.7
--- src/usr.sbin/ofctl/ofctl.8:1.6	Sat May 26 12:40:06 2018
+++ src/usr.sbin/ofctl/ofctl.8	Mon May 28 12:42:02 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ofctl.8,v 1.6 2018/05/26 12:40:06 wiz Exp $
+.\"	$NetBSD: ofctl.8,v 1.7 2018/05/28 12:42:02 wiz 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 May 26, 2018
+.Dd May 28, 2018
 .Dt OFCTL 8
 .Os
 .Sh NAME
@@ -35,8 +35,10 @@
 .Nd display the OpenPROM or OpenFirmware device tree
 .Sh SYNOPSIS
 .Nm
-.Op Fl pv
+.Op Fl lpv
 .Op Fl f Ar file
+.Op Fl r Ar propfile
+.Op Fl w Ar propfile
 .Op Ar node
 .Sh DESCRIPTION
 .Nm
@@ -54,7 +56,7 @@ When given the name of a specific node,
 will display that node and its child nodes.
 .Pp
 The options are as follows:
-.Bl -tag -offset indent -width 8n
+.Bl -tag -offset indent -width 12n
 .It Fl f Ar file
 On systems with OpenPROM, use
 .Ar file
@@ -64,10 +66,25 @@ On systems with OpenFirmware, use
 .Ar file
 instead of the default
 .Pa /dev/openfirm .
+.It Fl l
+Dump a partial tree starting from
+.Ar node .
 .It Fl p
 Display each node's properties.
+.It Fl r Ar propfile
+Instead of reading from the openprom or openfirm device,
+use the proplib file
+.Ar propfile
+as input.
+See also
+.Fl w .
 .It Fl v
 Display the full path name for each node.
+.It Fl w Ar propfile
+Write the device tree to the proplib file
+.Ar propfile .
+See also
+.Fl r .
 .El
 .Sh FILES
 .Bl -tag -width "/dev/openprom "



Re: CVS commit: src/usr.sbin/ofctl

2018-05-28 Thread Jared McNeill
The -l flag dumps a partial tree starting with the node specified by 
'file'. The format of the output is the same as when you run ofctl with no 
arguments (this dumps the full tree, equivalent of 'ofctl -l /').


It looks like -r and -w will tell ofctl to read from or write to an 
externalized proplib file instead of using the openfirm ioctl interface.


On Sat, 26 May 2018, Thomas Klausner wrote:


Thank you!

Do you know what the -l, -r, and -w options do? Those are missing from the man 
page.

Cheers,
Thomas

On Sat, May 26, 2018 at 10:21:41AM +, Jared D. McNeill wrote:

Module Name:src
Committed By:   jmcneill
Date:   Sat May 26 10:21:41 UTC 2018

Modified Files:
src/usr.sbin/ofctl: ofctl.8 ofctl.c

Log Message:
Add -v flag which prints the full path of each device node when dumping
the full tree.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/ofctl/ofctl.8
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/ofctl/ofctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Modified files:

Index: src/usr.sbin/ofctl/ofctl.8
diff -u src/usr.sbin/ofctl/ofctl.8:1.4 src/usr.sbin/ofctl/ofctl.8:1.5
--- src/usr.sbin/ofctl/ofctl.8:1.4  Thu Sep 25 22:44:51 2008
+++ src/usr.sbin/ofctl/ofctl.8  Sat May 26 10:21:41 2018
@@ -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 "

Index: src/usr.sbin/ofctl/ofctl.c
diff -u src/usr.sbin/ofctl/ofctl.c:1.12 src/usr.sbin/ofctl/ofctl.c:1.13
--- src/usr.sbin/ofctl/ofctl.c:1.12 Wed Dec 23 13:42:24 2015
+++ src/usr.sbin/ofctl/ofctl.c  Sat May 26 10:21:41 2018
@@ -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

 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_devi
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);







CVS commit: src/usr.sbin/ofctl

2018-05-26 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat May 26 12:40:06 UTC 2018

Modified Files:
src/usr.sbin/ofctl: ofctl.8

Log Message:
Merge single-letter options. Use more markup.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/ofctl/ofctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ofctl/ofctl.8
diff -u src/usr.sbin/ofctl/ofctl.8:1.5 src/usr.sbin/ofctl/ofctl.8:1.6
--- src/usr.sbin/ofctl/ofctl.8:1.5	Sat May 26 10:21:41 2018
+++ src/usr.sbin/ofctl/ofctl.8	Sat May 26 12:40:06 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ofctl.8,v 1.5 2018/05/26 10:21:41 jmcneill Exp $
+.\"	$NetBSD: ofctl.8,v 1.6 2018/05/26 12:40:06 wiz Exp $
 .\"
 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -35,8 +35,7 @@
 .Nd display the OpenPROM or OpenFirmware device tree
 .Sh SYNOPSIS
 .Nm
-.Op Fl p
-.Op Fl v
+.Op Fl pv
 .Op Fl f Ar file
 .Op Ar node
 .Sh DESCRIPTION
@@ -72,9 +71,9 @@ Display the full path name for each node
 .El
 .Sh FILES
 .Bl -tag -width "/dev/openprom "
-.It /dev/openprom
+.It Pa /dev/openprom
 The openprom device on systems with OpenPROM.
-.It /dev/openfirm
+.It Pa /dev/openfirm
 The openfirm device on systems with OpenFirmware.
 .El
 .Sh SEE ALSO



CVS commit: src/usr.sbin/ofctl

2018-05-26 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat May 26 12:40:06 UTC 2018

Modified Files:
src/usr.sbin/ofctl: ofctl.8

Log Message:
Merge single-letter options. Use more markup.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/ofctl/ofctl.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/usr.sbin/ofctl

2018-05-26 Thread Thomas Klausner
Thank you!

Do you know what the -l, -r, and -w options do? Those are missing from the man 
page.

Cheers,
 Thomas
 
On Sat, May 26, 2018 at 10:21:41AM +, Jared D. McNeill wrote:
> Module Name:  src
> Committed By: jmcneill
> Date: Sat May 26 10:21:41 UTC 2018
> 
> Modified Files:
>   src/usr.sbin/ofctl: ofctl.8 ofctl.c
> 
> Log Message:
> Add -v flag which prints the full path of each device node when dumping
> the full tree.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/ofctl/ofctl.8
> cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/ofctl/ofctl.c
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
> 

> Modified files:
> 
> Index: src/usr.sbin/ofctl/ofctl.8
> diff -u src/usr.sbin/ofctl/ofctl.8:1.4 src/usr.sbin/ofctl/ofctl.8:1.5
> --- src/usr.sbin/ofctl/ofctl.8:1.4Thu Sep 25 22:44:51 2008
> +++ src/usr.sbin/ofctl/ofctl.8Sat May 26 10:21:41 2018
> @@ -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 "
> 
> Index: src/usr.sbin/ofctl/ofctl.c
> diff -u src/usr.sbin/ofctl/ofctl.c:1.12 src/usr.sbin/ofctl/ofctl.c:1.13
> --- src/usr.sbin/ofctl/ofctl.c:1.12   Wed Dec 23 13:42:24 2015
> +++ src/usr.sbin/ofctl/ofctl.cSat May 26 10:21:41 2018
> @@ -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
>  
>  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_devi
>   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);
> 



CVS commit: src/usr.sbin/ofctl

2018-05-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat May 26 10:21:41 UTC 2018

Modified Files:
src/usr.sbin/ofctl: ofctl.8 ofctl.c

Log Message:
Add -v flag which prints the full path of each device node when dumping
the full tree.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/ofctl/ofctl.8
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/ofctl/ofctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ofctl/ofctl.8
diff -u src/usr.sbin/ofctl/ofctl.8:1.4 src/usr.sbin/ofctl/ofctl.8:1.5
--- src/usr.sbin/ofctl/ofctl.8:1.4	Thu Sep 25 22:44:51 2008
+++ src/usr.sbin/ofctl/ofctl.8	Sat May 26 10:21:41 2018
@@ -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 "

Index: src/usr.sbin/ofctl/ofctl.c
diff -u src/usr.sbin/ofctl/ofctl.c:1.12 src/usr.sbin/ofctl/ofctl.c:1.13
--- src/usr.sbin/ofctl/ofctl.c:1.12	Wed Dec 23 13:42:24 2015
+++ src/usr.sbin/ofctl/ofctl.c	Sat May 26 10:21:41 2018
@@ -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
 
 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_devi
 	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);



CVS commit: src/usr.sbin/ofctl

2018-05-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat May 26 10:21:41 UTC 2018

Modified Files:
src/usr.sbin/ofctl: ofctl.8 ofctl.c

Log Message:
Add -v flag which prints the full path of each device node when dumping
the full tree.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/ofctl/ofctl.8
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/ofctl/ofctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ofctl

2015-12-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Dec 23 13:42:24 UTC 2015

Modified Files:
src/usr.sbin/ofctl: ofctl.c

Log Message:
Implement OF_finddevice, now ofctl -p  works


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/ofctl/ofctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ofctl

2015-12-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Dec 23 13:42:24 UTC 2015

Modified Files:
src/usr.sbin/ofctl: ofctl.c

Log Message:
Implement OF_finddevice, now ofctl -p  works


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/ofctl/ofctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ofctl/ofctl.c
diff -u src/usr.sbin/ofctl/ofctl.c:1.11 src/usr.sbin/ofctl/ofctl.c:1.12
--- src/usr.sbin/ofctl/ofctl.c:1.11	Mon May 18 05:51:53 2009
+++ src/usr.sbin/ofctl/ofctl.c	Wed Dec 23 13:42:24 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofctl.c,v 1.11 2009/05/18 05:51:53 mrg Exp $	*/
+/*	$NetBSD: ofctl.c,v 1.12 2015/12/23 13:42:24 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.11 2009/05/18 05:51:53 mrg Exp $");
+__RCSID("$NetBSD: ofctl.c,v 1.12 2015/12/23 13:42:24 jmcneill Exp $");
 #endif /* not lint */
 
 #include 
@@ -97,6 +97,8 @@ int OF_nextprop(int, const char *, void 
 
 struct of_prop *of_tree_getprop(int, const char *);
 
+static int of_fd = -1;
+
 static void
 of_tree_mkprop(struct of_node *node, prop_dictionary_t propdict,
 prop_dictionary_keysym_t key)
@@ -304,7 +306,10 @@ of_proplib_init(const char *file)
 		err(1, "OFIOCGETNEXT(%d, %#x)", fd, rootid);
 
 	dict = of_proplib_tree_fill(fd, rootid);
-	close(fd);
+
+	/* keep the device open for the benefit of OF_finddevice */
+	of_fd = fd;
+
 	return dict;
 }
 
@@ -386,18 +391,22 @@ OF_peer(int peerid)
 int
 OF_finddevice(const char *name)
 {
-#if 0
 	struct ofiocdesc ofio;
 	
 	ofio.of_nodeid = 0;
-	ofio.of_name = argv[optind++];
-	ofio.of_namelen = strlen(ofio.of_name);
+	ofio.of_name = __UNCONST(name);
+	ofio.of_namelen = strlen(name);
 	ofio.of_buf = NULL;
 	ofio.of_buflen = 0;
-	if (ioctl(of_fd, OFIOCFINDDEVICE, ) < 0)
-		err(1, "OFIOCFINDDEVICE(%d, \"%s\")", of_fd, ofio.of_name);
-#endif
-	return 0;
+	if (ioctl(of_fd, OFIOCFINDDEVICE, ) < 0) {
+		if (errno == ENOENT) {
+			err(1, "OF node '%s' not found", name);
+		} else {
+			err(1, "OFIOCFINDDEVICE(%d, \"%s\")", of_fd, name);
+		}
+	}
+
+	return ofio.of_nodeid;
 }
 
 struct of_prop *
@@ -529,12 +538,19 @@ main(int argc, char **argv)
 			device_type[len] = '\0';
 		oflist(phandle, device_type, 0, of_buf, sizeof(of_buf));
 	} else {
-#if 0
-		pandle = OF_finddevice(argv[optind++]);
+		phandle = OF_finddevice(argv[optind++]);
+		device_type[0] = '\0';
+		len = OF_getprop(phandle, "device_type", device_type,
+		sizeof(device_type));
+		if (len <= 0)
+			len = OF_getprop(phandle, "name", device_type,
+			sizeof(device_type));
+		if (len >= 0)
+			device_type[len] = '\0';
 
 		if (argc == optind) {
 			if (lflag)
-oflist(phandle, 0, of_buf, sizeof(of_buf));
+oflist(phandle, device_type, 0, of_buf, sizeof(of_buf));
 			else
 ofprop(phandle);
 		} else {
@@ -542,9 +558,6 @@ main(int argc, char **argv)
 ofgetprop(phandle, argv[optind]);
 			}
 		}
-#else
-		printf("%s: OF_finddevice not yet implemented\n", argv[optind]);
-#endif
 	}
 	exit(0);
 }



CVS commit: src/usr.sbin/ofctl

2010-06-20 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Jun 20 21:30:27 UTC 2010

Modified Files:
src/usr.sbin/ofctl: Makefile

Log Message:
Make ofctl for ofppc machines.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/ofctl/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ofctl/Makefile
diff -u src/usr.sbin/ofctl/Makefile:1.6 src/usr.sbin/ofctl/Makefile:1.7
--- src/usr.sbin/ofctl/Makefile:1.6	Sun Dec 13 05:01:33 2009
+++ src/usr.sbin/ofctl/Makefile	Sun Jun 20 21:30:26 2010
@@ -1,8 +1,11 @@
 #	from: @(#)Makefile	5.8 (Berkeley) 7/28/90
-#	$NetBSD: Makefile,v 1.6 2009/12/13 05:01:33 nakayama Exp $
+#	$NetBSD: Makefile,v 1.7 2010/06/20 21:30:26 matt Exp $
 
-.if ${MACHINE} == sparc64 || ${MACHINE} == macppc \
-	|| ${MACHINE} == shark || ${MACHINE} == sparc
+.if ${MACHINE} == sparc64 \
+	|| ${MACHINE} == macppc \
+	|| ${MACHINE} == ofppc \
+	|| ${MACHINE} == shark \
+	|| ${MACHINE} == sparc
 
 PROG=	ofctl
 



CVS commit: src/usr.sbin/ofctl

2009-04-25 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sun Apr 26 04:54:27 UTC 2009

Modified Files:
src/usr.sbin/ofctl: ofctl.c

Log Message:
Fix WARNS=4 issues (-Wcast-qual -Wsign-compare)
Fixes PR bin/41283


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/ofctl/ofctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ofctl/ofctl.c
diff -u src/usr.sbin/ofctl/ofctl.c:1.9 src/usr.sbin/ofctl/ofctl.c:1.10
--- src/usr.sbin/ofctl/ofctl.c:1.9	Mon Jul 21 13:36:59 2008
+++ src/usr.sbin/ofctl/ofctl.c	Sun Apr 26 04:54:27 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofctl.c,v 1.9 2008/07/21 13:36:59 lukem Exp $	*/
+/*	$NetBSD: ofctl.c,v 1.10 2009/04/26 04:54:27 lukem 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.9 2008/07/21 13:36:59 lukem Exp $);
+__RCSID($NetBSD: ofctl.c,v 1.10 2009/04/26 04:54:27 lukem Exp $);
 #endif /* not lint */
 
 #include stdio.h
@@ -55,7 +55,7 @@
 
 static void oflist(int, const char *, int, void *, size_t);
 static void ofprop(int);
-static void ofgetprop(int, char *);
+static void ofgetprop(int, const char *);
 #if 0
 static int isstrprint(const char *, size_t, int);
 #endif
@@ -91,11 +91,11 @@
 int OF_child(int);
 int OF_peer(int);
 int OF_finddevice(const char *);
-int OF_getproplen(int, char *);
-int OF_getprop(int, char *, void *, size_t);
-int OF_nextprop(int, char *, void *);
+int OF_getproplen(int, const char *);
+int OF_getprop(int, const char *, void *, size_t);
+int OF_nextprop(int, const char *, void *);
 
-struct of_prop *of_tree_getprop(int, char *);
+struct of_prop *of_tree_getprop(int, const char *);
 
 static void
 of_tree_mkprop(struct of_node *node, prop_dictionary_t propdict,
@@ -401,7 +401,7 @@
 }
 
 struct of_prop *
-of_tree_getprop(int nodeid, char *name)
+of_tree_getprop(int nodeid, const char *name)
 {
 	struct of_node *node;
 	struct of_prop *prop;
@@ -431,14 +431,14 @@
 }
 
 int
-OF_getproplen(int nodeid, char *name)
+OF_getproplen(int nodeid, const char *name)
 {
 	struct of_prop *prop = of_tree_getprop(nodeid, name);
-	return (prop != NULL) ? prop-prop_length : -1;
+	return (prop != NULL) ? (int)prop-prop_length : -1;
 }
 
 int
-OF_getprop(int nodeid, char *name, void *buf, size_t len)
+OF_getprop(int nodeid, const char *name, void *buf, size_t len)
 {
 	struct of_prop *prop = of_tree_getprop(nodeid, name);
 	if (prop == NULL)
@@ -450,7 +450,7 @@
 }
 
 int
-OF_nextprop(int nodeid, char *name, void *nextname)
+OF_nextprop(int nodeid, const char *name, void *nextname)
 {
 	struct of_prop *prop = of_tree_getprop(nodeid, name);
 	if (prop == NULL)
@@ -897,7 +897,7 @@
 };
 
 static void
-ofgetprop(int node, char *name)
+ofgetprop(int node, const char *name)
 {
 	u_int8_t of_buf[4097];
 	int len;