devfsctl.8: Add a description of the rule syntax.
[dragonfly.git] / usr.sbin / devfsctl / devfsctl.8
1 .\"
2 .\" Copyright (c) 2009
3 .\"     The DragonFly Project.  All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\"
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in
13 .\"    the documentation and/or other materials provided with the
14 .\"    distribution.
15 .\" 3. Neither the name of The DragonFly Project nor the names of its
16 .\"    contributors may be used to endorse or promote products derived
17 .\"    from this software without specific, prior written permission.
18 .\"
19 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
23 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .Dd August 13, 2009
33 .Os
34 .Dt DEVFSCTL 8
35 .Sh NAME
36 .Nm devfsctl
37 .Nd manipulate devfs rules
38 .Sh SYNOPSIS
39 .Nm
40 .Fl a
41 .Fl f Ar file
42 .Op Fl m Ar mount_point
43 .Nm
44 .Fl d
45 .Fl f Ar file
46 .Nm
47 .Fl c
48 .Op Fl m Ar mount_point
49 .Nm
50 .Fl r
51 .Op Fl m Ar mount_point
52 .Nm
53 .Fl h
54 .Sh DESCRIPTION
55 The
56 .Nm
57 provides an interface to manipulate the in-kernel
58 .Xr devfs 5
59 ruleset.
60 .Pp
61 The options are as follows:
62 .Bl -tag -width indent
63 .It Fl a
64 Load the ruleset specified by
65 .Fl f
66 and apply it.
67 It will not overwrite currently applied rules,
68 but just append the new ones.
69 .It Fl c
70 Clear the current ruleset.
71 This does not reset the device nodes, but only clear out all stored rules
72 so that they are not applied to new nodes.
73 It is therefore recommended to use this command in conjunction with
74 .Fl r .
75 .It Fl d
76 Reads ruleset specified by
77 .Fl f
78 and then dumps its contents to stdout.
79 The rules will not be applied.
80 This option cannot be used in conjuction with any other option.
81 It is useful for checking the correct syntax and order of the specified ruleset
82 and will show the final interpretation as it would be applied.
83 .It Fl f Ar file
84 Specifies the file containing the ruleset to be loaded.
85 See
86 .Xr devfs.conf 5
87 for more information on rule syntax.
88 This option is a requirement for
89 .Fl a
90 and
91 .Fl d .
92 .It Fl h
93 Shows a usage message with a short description of
94 .Nm Ap s
95 options.
96 .It Fl m Ar mount_point
97 Specifies the mount point to which the loaded rules shall apply.
98 If this option is not specified, the rules will apply to all
99 .Xr devfs 5
100 mountpoints.
101 The
102 .Ar mount_point
103 argument does not accept wildcards and must be an absolute path.
104 .It Fl r
105 Reset all
106 .Xr devfs 5
107 nodes to their original status.
108 This does not clear the current ruleset and it is hence recommended
109 to use this command together with
110 .Fl c .
111 .El
112 .Sh RULE SYNTAX
113 Rules are specified one rule per line, with whitespace separated values.
114 Empty lines and lines beginning with a
115 .Dq #
116 are ignored.
117 Once applied, the rules are in effect for existing device nodes as well
118 as future ones.
119 Rules are applied in the order specified, thus later rules will override
120 prior ones.
121 .Pp
122 Names used in
123 .Xr devfs 5
124 rules can be either device names (? and * wildcards are allowed), device
125 types or existing groups.
126 Groups are referenced in rules by prefixing them with
127 .Sq @ .
128 A device type is one of the following list of special names:
129 .Pp
130 .Bl -tag -offset indent -width ".Li D_DISK" -compact
131 .It Li D_DISK
132 disk devices/slices/partitions
133 .It Li D_TAPE
134 tape devices
135 .It Li D_MEM
136 (kernel) memory devices
137 .It Li D_TTY
138 tty devices
139 .El
140 .Pp
141 Rule lines are of the following format:
142 .Bd -literal -offset indent
143 .Ic action Cm argument ...
144 .Ed
145 .Pp
146 Valid actions are
147 .Ic group ,
148 .Ic include ,
149 .Ic hide ,
150 .Ic jail ,
151 .Ic link ,
152 .Ic perm
153 and
154 .Ic show :
155 .Bl -tag -width indent -offset indent
156 .It Ic group Ar group_name Ar name ...
157 This will group the specified names into a group of the specified
158 .Ar group_name .
159 .It Ic include Ar file
160 Includes the specified rule file and processes its rules.
161 .It Ic hide Ar name
162 This will hide the device node(s) specified by
163 .Ar name .
164 A hidden node will not appear in directory listings and all operations on
165 it will fail, except if it is open already.
166 By default, everything except
167 .Xr pty 4
168 nodes is shown.
169 .It Ic jail Ar yes|no
170 A
171 .Sq Ar yes
172 argument will cause all following rules to only apply to mounts of
173 .Xr devfs
174 inside a
175 .Xr jail 8 ,
176 until a
177 .Dq Ic jail Ar no
178 is reached.
179 .It Ic link Ar device Ar path
180 .Ic link
181 rules will create a link node at the specified
182 .Ar link_path
183 to the given
184 .Ar device .
185 The path is relative to the mountpoint being operated on (see
186 .Xr devfsctl 8 Ap s
187 .Fl m
188 option), which is usually
189 .Pa /dev .
190 .Pp
191 Note that for
192 .Ic link
193 rules, the
194 .Ar device
195 has to be a single device node and specifying a device type or group (unless
196 it contains only one node) is not possible.
197 .It Ic perm Ar name Ar user:group Ar mode
198 A
199 .Ic perm
200 rule will applies the specified mode (octal, see
201 .Xr chmod 1 )
202 and ownership (see
203 .Xr chown 2 )
204 to
205 .Ar name .
206 .It Ic show Ar name
207 This will show previously hidden nodes again.
208 .El
209 .Sh FILES
210 .Bl -tag -width ".Pa /etc/devfs" -compact
211 .It Pa /etc/devfs/*
212 devfs ruleset files
213 .El
214 .Sh EXAMPLES
215 Examples of valid names:
216 .Bd -literal -offset indent
217 bpf*
218 tun0
219 D_DISK
220 serno/*s3
221 @groupA
222 .Ed
223 .Pp
224 Examples of valid rules:
225 .Bd -literal -offset indent
226 group   foo     da*     ri*
227 group   foo     ad*
228 group   foo     md*
229
230 perm    da0     uucp:dialer 0644
231 link    foo     bar
232 hide    @foo
233 show    D_DISK
234 group   g1      a b f g
235 group   g2      c d
236 group   g3      @g1 h @g2 i j k D_MEM
237 jail    yes
238 hide    @g3
239 perm    @g3     root:wheel 0644
240 jail    no
241 group   cdrom   cd*     acd*
242 group   disks   da*
243 group   disks   ad*
244 group   drives  @disks  @cdrom
245
246 group   test    @disks  @g2     y
247 show    @drives
248 show    @disks
249 show    @test
250 link    da0     "my drives/my new da0"
251 .Ed
252 .Sh SEE ALSO
253 .Xr devfs 5 ,
254 .Xr devfs.conf 5 ,
255 .Xr mount_devfs 8
256 .Sh HISTORY
257 The
258 .Nm
259 utility appeared in
260 .Dx 2.3 .
261 .Sh AUTHORS
262 .An Alex Hornung