Module Name:    src
Committed By:   joerg
Date:           Sat Apr  4 22:05:47 UTC 2009

Modified Files:
        src/sbin/drvctl: drvctl.8 drvctl.c

Log Message:
If drvctl -l is used without argument, print the root device nodes.


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

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

Modified files:

Index: src/sbin/drvctl/drvctl.8
diff -u src/sbin/drvctl/drvctl.8:1.5 src/sbin/drvctl/drvctl.8:1.6
--- src/sbin/drvctl/drvctl.8:1.5	Sat Feb 16 02:00:37 2008
+++ src/sbin/drvctl/drvctl.8	Sat Apr  4 22:05:47 2009
@@ -1,4 +1,4 @@
-.\" $NetBSD: drvctl.8,v 1.5 2008/02/16 02:00:37 dyoung Exp $
+.\" $NetBSD: drvctl.8,v 1.6 2009/04/04 22:05:47 joerg Exp $
 .\"
 .\" Copyright (c) 2004
 .\" 	Matthias Drochner.  All rights reserved.
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd Feburary 15, 2008
+.Dd April 4, 2009
 .Dt DRVCTL 8
 .Os
 .Sh NAME
@@ -41,7 +41,7 @@
 .Ar device
 .Nm
 .Fl l
-.Ar device
+.Op Ar device
 .Nm
 .Fl p
 .Ar device
@@ -78,6 +78,9 @@
 List the children of the device specified by the
 .Ar device
 argument.
+If
+.Ar device
+is not specified, query for roots of the device tree instead.
 .It Fl p
 Get the properties for the device specified by the
 .Ar device

Index: src/sbin/drvctl/drvctl.c
diff -u src/sbin/drvctl/drvctl.c:1.7 src/sbin/drvctl/drvctl.c:1.8
--- src/sbin/drvctl/drvctl.c:1.7	Mon Mar 16 13:35:37 2009
+++ src/sbin/drvctl/drvctl.c	Sat Apr  4 22:05:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: drvctl.c,v 1.7 2009/03/16 13:35:37 lukem Exp $ */
+/* $NetBSD: drvctl.c,v 1.8 2009/04/04 22:05:47 joerg Exp $ */
 
 /*
  * Copyright (c) 2004
@@ -49,7 +49,7 @@
 
 	fprintf(stderr, "Usage: %s -r [-a attribute] busdevice [locator ...]\n"
 	    "       %s -d device\n"
-	    "       %s -l device\n"
+	    "       %s -l [device]\n"
 	    "       %s -p device\n"
 	    "       %s -Q device\n"
 	    "       %s -R device\n"
@@ -104,7 +104,7 @@
 	argc -= optind;
 	argv += optind;
 
-	if (argc < 1 || mode == 0)
+	if ((argc < 1 && mode != 'l') || mode == 0)
 		usage();
 
 	fd = open(DRVCTLDEV, OPEN_MODE(mode), 0);
@@ -134,7 +134,10 @@
 			err(3, "DRVDETACHDEV");
 		break;
 	case 'l':
-		strlcpy(laa.l_devname, argv[0], sizeof(laa.l_devname));
+		if (argc == 0)
+			*laa.l_devname = '\0';
+		else
+			strlcpy(laa.l_devname, argv[0], sizeof(laa.l_devname));
 
 		if (ioctl(fd, DRVLISTDEV, &laa) == -1)
 			err(3, "DRVLISTDEV");
@@ -149,8 +152,10 @@
 		if (laa.l_children > children)
 			err(6, "DRVLISTDEV: number of children grew");
 
-		for (i = 0; i < (int)laa.l_children; i++)
-			printf("%s %s\n", laa.l_devname, laa.l_childname[i]);
+		for (i = 0; i < (int)laa.l_children; i++) {
+			printf("%s%s%s\n", laa.l_devname, (argc ? " " : ""),
+			    laa.l_childname[i]);
+		}
 		break;
 	case 'r':
 		memset(&raa, 0, sizeof(raa));

Reply via email to