@@ -1,4 +1,4 @@
-.\" $NetBSD: drvctl.8,v 1.5 2008/02/16 02:00:37 dyoung Exp $
+.\" $NetBSD: drvctl.8,v 1.5.10.1 2009/05/03 22:49:51 snj 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
@@ -1,4 +1,4 @@
-/* $NetBSD: drvctl.c,v 1.6 2008/01/27 01:38:33 dyoung Exp $ */
+/* $NetBSD: drvctl.c,v 1.6.10.1 2009/05/03 22:49:51 snj 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 < laa.l_children; i++)
- printf("%s %s\n", laa.l_devname, laa.l_childname[i]);
+ for (i = 0; i < 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));