xref: /freebsd/share/man/man5/devfs.rules.5 (revision 55141f2c8991b2a6adbf30bb0fe3e6cbc303f06d)
1.\" Copyright (c) 2004 Roland Smith <rsmith@xs4all.nl>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.Dd December 1, 2020
26.Dt DEVFS.RULES 5
27.Os
28.Sh NAME
29.Nm devfs.rules
30.Nd devfs configuration information
31.Sh DESCRIPTION
32The
33.Nm
34file provides an easy way to create and apply
35.Xr devfs 8
36rules, even for devices that are not available at boot.
37.Pp
38For devices available at boot, see
39.Xr devfs.conf 5 .
40.Pp
41The format of this file is simple.
42Empty lines and lines beginning with a hash sign
43.Pq Ql #
44are ignored.
45A line between brackets denotes the start of a ruleset.
46In the brackets should be the name of the ruleset and its number,
47separated by an equal sign.
48.Pp
49Other lines are rule specifications as documented in
50.Xr devfs 8 ,
51in the section
52.Sx "Rule Specification" .
53These lines are prepended with
54.Dq Li rule
55and are passed to
56.Xr devfs 8
57by the startup scripts of the system.
58It is important to put path elements that contain
59.Xr glob 3
60special characters between quotes.
61.Pp
62Rulesets should have a unique name and number.
63.Pp
64All rules that follow a ruleset declaration belong to that ruleset, until a
65new ruleset is started.
66.Pp
67One custom ruleset has to be enabled in
68.Pa /etc/rc.conf ,
69otherwise it will not be applied to the
70.Pa /dev
71file system by the default system startup process.
72For example, to enable a
73.Dq Li localrules
74ruleset for the
75.Pa /dev
76file system, you would have to use something like this in your
77.Pa rc.conf
78file:
79.Bd -literal -offset indent
80devfs_system_ruleset="localrules"
81.Ed
82.Pp
83The rules are loaded at boot via the devfs service.
84To load modified rules after the system has booted, run the command:
85.Bd -literal -offset indent
86service devfs restart
87.Ed
88.Sh FILES
89.Bl -tag -compact -width Pa
90.It Pa /etc/defaults/devfs.rules
91Default
92.Nm
93configuration file.
94.It Pa /etc/devfs.rules
95Local
96.Nm
97configuration file.
98Rulesets in here override those in
99.Pa /etc/defaults/devfs.rules
100with the same ruleset number, otherwise the two files are effectively merged.
101.El
102.Sh EXAMPLES
103To make all the partitions of
104.Xr da 4
105devices readable and writable by their owner and the
106.Dq Li usb
107group, the following rule may be used:
108.Pp
109.Dl "[localrules=10]"
110.Dl "add path 'da*s*' mode 0660 group usb"
111.Pp
112The first line declares and starts a new ruleset, with the name
113.Va localrules
114and the number 10.
115.Pp
116To give
117.Xr usbconfig 8
118and
119.Xr libusb 3
120enabled applications permission to all usb devices for their owner and the
121.Dq Li usb
122group, a similar rule may be used:
123.Pp
124.Dl "add path 'usb/*' mode 0660 group usb"
125.Sh SEE ALSO
126.Xr glob 3 ,
127.Xr devfs 5 ,
128.Xr devfs.conf 5 ,
129.Xr devfs 8 ,
130.Xr service 8
131.Sh AUTHORS
132This manual page was written by
133.An Roland Smith Aq Mt rsmith@xs4all.nl .
134