Sun May 3 22:49:52 2009 UTC ()
Pull up following revision(s) (requested by joerg in ticket #675):
	sbin/drvctl/drvctl.8: revision 1.6
	sbin/drvctl/drvctl.c: revision 1.8 via patch
If drvctl -l is used without argument, print the root device nodes.


(snj)
diff -r1.5 -r1.5.10.1 src/sbin/drvctl/drvctl.8
diff -r1.6 -r1.6.10.1 src/sbin/drvctl/drvctl.c

cvs diff -r1.5 -r1.5.10.1 src/sbin/drvctl/drvctl.8 (expand / switch to unified diff)

--- src/sbin/drvctl/drvctl.8 2008/02/16 02:00:37 1.5
+++ src/sbin/drvctl/drvctl.8 2009/05/03 22:49:51 1.5.10.1
@@ -1,57 +1,57 @@ @@ -1,57 +1,57 @@
1.\" $NetBSD: drvctl.8,v 1.5 2008/02/16 02:00:37 dyoung Exp $ 1.\" $NetBSD: drvctl.8,v 1.5.10.1 2009/05/03 22:49:51 snj Exp $
2.\" 2.\"
3.\" Copyright (c) 2004 3.\" Copyright (c) 2004
4.\" Matthias Drochner. All rights reserved. 4.\" Matthias Drochner. All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE. 25.\" SUCH DAMAGE.
26.\" 26.\"
27.Dd Feburary 15, 2008 27.Dd April 4, 2009
28.Dt DRVCTL 8 28.Dt DRVCTL 8
29.Os 29.Os
30.Sh NAME 30.Sh NAME
31.Nm drvctl 31.Nm drvctl
32.Nd tool to rescan busses and detach devices on user request 32.Nd tool to rescan busses and detach devices on user request
33.Sh SYNOPSIS 33.Sh SYNOPSIS
34.Nm 34.Nm
35.Fl r 35.Fl r
36.Op Fl a Ar attribute 36.Op Fl a Ar attribute
37.Ar busdevice 37.Ar busdevice
38.Op locator ... 38.Op locator ...
39.Nm 39.Nm
40.Fl d 40.Fl d
41.Ar device 41.Ar device
42.Nm 42.Nm
43.Fl l 43.Fl l
44.Ar device 44.Op Ar device
45.Nm 45.Nm
46.Fl p 46.Fl p
47.Ar device 47.Ar device
48.Nm 48.Nm
49.Fl Q 49.Fl Q
50.Ar device 50.Ar device
51.Nm 51.Nm
52.Fl R 52.Fl R
53.Ar device 53.Ar device
54.Nm 54.Nm
55.Fl S 55.Fl S
56.Ar device 56.Ar device
57.Sh DESCRIPTION 57.Sh DESCRIPTION
@@ -68,26 +68,29 @@ The following options are available: @@ -68,26 +68,29 @@ The following options are available:
68Give the interface attribute where children are to be 68Give the interface attribute where children are to be
69attached to (and which defines the interpretation of 69attached to (and which defines the interpretation of
70the locator information). 70the locator information).
71This will only be needed in rare cases where the bus 71This will only be needed in rare cases where the bus
72has multiple attributes. 72has multiple attributes.
73.It Fl d 73.It Fl d
74Detach the device driver from the device given by the 74Detach the device driver from the device given by the
75.Ar device 75.Ar device
76argument. 76argument.
77.It Fl l 77.It Fl l
78List the children of the device specified by the 78List the children of the device specified by the
79.Ar device 79.Ar device
80argument. 80argument.
 81If
 82.Ar device
 83is not specified, query for roots of the device tree instead.
81.It Fl p 84.It Fl p
82Get the properties for the device specified by the 85Get the properties for the device specified by the
83.Ar device 86.Ar device
84argument. 87argument.
85The properties are displayed as an XML property list. 88The properties are displayed as an XML property list.
86.It Fl Q 89.It Fl Q
87Resume the ancestors of 90Resume the ancestors of
88.Ar device , 91.Ar device ,
89.Ar device 92.Ar device
90itself, and all of its descendants. 93itself, and all of its descendants.
91.It Fl R 94.It Fl R
92Resume both the ancestors of 95Resume both the ancestors of
93.Ar device 96.Ar device

cvs diff -r1.6 -r1.6.10.1 src/sbin/drvctl/drvctl.c (expand / switch to unified diff)

--- src/sbin/drvctl/drvctl.c 2008/01/27 01:38:33 1.6
+++ src/sbin/drvctl/drvctl.c 2009/05/03 22:49:51 1.6.10.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: drvctl.c,v 1.6 2008/01/27 01:38:33 dyoung Exp $ */ 1/* $NetBSD: drvctl.c,v 1.6.10.1 2009/05/03 22:49:51 snj Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2004 4 * Copyright (c) 2004
5 * Matthias Drochner. All rights reserved. 5 * Matthias Drochner. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer. 11 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -39,27 +39,27 @@ @@ -39,27 +39,27 @@
39 39
40#define OPEN_MODE(mode) \ 40#define OPEN_MODE(mode) \
41 (((mode) == 'd' || (mode) == 'r') ? O_RDWR \ 41 (((mode) == 'd' || (mode) == 'r') ? O_RDWR \
42 : O_RDONLY) 42 : O_RDONLY)
43 43
44static void usage(void); 44static void usage(void);
45 45
46static void 46static void
47usage(void) 47usage(void)
48{ 48{
49 49
50 fprintf(stderr, "Usage: %s -r [-a attribute] busdevice [locator ...]\n" 50 fprintf(stderr, "Usage: %s -r [-a attribute] busdevice [locator ...]\n"
51 " %s -d device\n" 51 " %s -d device\n"
52 " %s -l device\n" 52 " %s -l [device]\n"
53 " %s -p device\n" 53 " %s -p device\n"
54 " %s -Q device\n" 54 " %s -Q device\n"
55 " %s -R device\n" 55 " %s -R device\n"
56 " %s -S device\n", 56 " %s -S device\n",
57 getprogname(), getprogname(), getprogname(), getprogname(), 57 getprogname(), getprogname(), getprogname(), getprogname(),
58 getprogname(), getprogname(), getprogname()); 58 getprogname(), getprogname(), getprogname());
59 exit(1); 59 exit(1);
60} 60}
61 61
62int 62int
63main(int argc, char **argv) 63main(int argc, char **argv)
64{ 64{
65 int c, mode; 65 int c, mode;
@@ -94,27 +94,27 @@ main(int argc, char **argv) @@ -94,27 +94,27 @@ main(int argc, char **argv)
94 break; 94 break;
95 case 'a': 95 case 'a':
96 attr = optarg; 96 attr = optarg;
97 break; 97 break;
98 case '?': 98 case '?':
99 default: 99 default:
100 usage(); 100 usage();
101 } 101 }
102 } 102 }
103 103
104 argc -= optind; 104 argc -= optind;
105 argv += optind; 105 argv += optind;
106 106
107 if (argc < 1 || mode == 0) 107 if ((argc < 1 && mode != 'l') || mode == 0)
108 usage(); 108 usage();
109 109
110 fd = open(DRVCTLDEV, OPEN_MODE(mode), 0); 110 fd = open(DRVCTLDEV, OPEN_MODE(mode), 0);
111 if (fd < 0) 111 if (fd < 0)
112 err(2, "open %s", DRVCTLDEV); 112 err(2, "open %s", DRVCTLDEV);
113 113
114 switch (mode) { 114 switch (mode) {
115 case 'Q': 115 case 'Q':
116 paa.flags = DEVPM_F_SUBTREE; 116 paa.flags = DEVPM_F_SUBTREE;
117 /*FALLTHROUGH*/ 117 /*FALLTHROUGH*/
118 case 'R': 118 case 'R':
119 strlcpy(paa.devname, argv[0], sizeof(paa.devname)); 119 strlcpy(paa.devname, argv[0], sizeof(paa.devname));
120 120
@@ -124,43 +124,48 @@ main(int argc, char **argv) @@ -124,43 +124,48 @@ main(int argc, char **argv)
124 case 'S': 124 case 'S':
125 strlcpy(paa.devname, argv[0], sizeof(paa.devname)); 125 strlcpy(paa.devname, argv[0], sizeof(paa.devname));
126 126
127 if (ioctl(fd, DRVSUSPENDDEV, &paa) == -1) 127 if (ioctl(fd, DRVSUSPENDDEV, &paa) == -1)
128 err(3, "DRVSUSPENDDEV"); 128 err(3, "DRVSUSPENDDEV");
129 break; 129 break;
130 case 'd': 130 case 'd':
131 strlcpy(daa.devname, argv[0], sizeof(daa.devname)); 131 strlcpy(daa.devname, argv[0], sizeof(daa.devname));
132 132
133 if (ioctl(fd, DRVDETACHDEV, &daa) == -1) 133 if (ioctl(fd, DRVDETACHDEV, &daa) == -1)
134 err(3, "DRVDETACHDEV"); 134 err(3, "DRVDETACHDEV");
135 break; 135 break;
136 case 'l': 136 case 'l':
137 strlcpy(laa.l_devname, argv[0], sizeof(laa.l_devname)); 137 if (argc == 0)
 138 *laa.l_devname = '\0';
 139 else
 140 strlcpy(laa.l_devname, argv[0], sizeof(laa.l_devname));
138 141
139 if (ioctl(fd, DRVLISTDEV, &laa) == -1) 142 if (ioctl(fd, DRVLISTDEV, &laa) == -1)
140 err(3, "DRVLISTDEV"); 143 err(3, "DRVLISTDEV");
141 144
142 children = laa.l_children; 145 children = laa.l_children;
143 146
144 laa.l_childname = malloc(children * sizeof(laa.l_childname[0])); 147 laa.l_childname = malloc(children * sizeof(laa.l_childname[0]));
145 if (laa.l_childname == NULL) 148 if (laa.l_childname == NULL)
146 err(5, "DRVLISTDEV"); 149 err(5, "DRVLISTDEV");
147 if (ioctl(fd, DRVLISTDEV, &laa) == -1) 150 if (ioctl(fd, DRVLISTDEV, &laa) == -1)
148 err(3, "DRVLISTDEV"); 151 err(3, "DRVLISTDEV");
149 if (laa.l_children > children) 152 if (laa.l_children > children)
150 err(6, "DRVLISTDEV: number of children grew"); 153 err(6, "DRVLISTDEV: number of children grew");
151 154
152 for (i = 0; i < laa.l_children; i++) 155 for (i = 0; i < laa.l_children; i++) {
153 printf("%s %s\n", laa.l_devname, laa.l_childname[i]); 156 printf("%s%s%s\n", laa.l_devname, (argc ? " " : ""),
 157 laa.l_childname[i]);
 158 }
154 break; 159 break;
155 case 'r': 160 case 'r':
156 memset(&raa, 0, sizeof(raa)); 161 memset(&raa, 0, sizeof(raa));
157 strlcpy(raa.busname, argv[0], sizeof(raa.busname)); 162 strlcpy(raa.busname, argv[0], sizeof(raa.busname));
158 if (attr) 163 if (attr)
159 strlcpy(raa.ifattr, attr, sizeof(raa.ifattr)); 164 strlcpy(raa.ifattr, attr, sizeof(raa.ifattr));
160 if (argc > 1) { 165 if (argc > 1) {
161 locs = malloc((argc - 1) * sizeof(int)); 166 locs = malloc((argc - 1) * sizeof(int));
162 if (!locs) 167 if (!locs)
163 err(5, "malloc int[%d]", argc - 1); 168 err(5, "malloc int[%d]", argc - 1);
164 for (i = 0; i < argc - 1; i++) 169 for (i = 0; i < argc - 1; i++)
165 locs[i] = atoi(argv[i + 1]); 170 locs[i] = atoi(argv[i + 1]);
166 raa.numlocators = argc - 1; 171 raa.numlocators = argc - 1;