xref: /freebsd/share/man/man5/devfs.rules.5 (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
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.\" $FreeBSD$
26.\"
27.Dd December 1, 2020
28.Dt DEVFS.RULES 5
29.Os
30.Sh NAME
31.Nm devfs.rules
32.Nd devfs configuration information
33.Sh DESCRIPTION
34The
35.Nm
36file provides an easy way to create and apply
37.Xr devfs 8
38rules, even for devices that are not available at boot.
39.Pp
40For devices available at boot, see
41.Xr devfs.conf 5 .
42.Pp
43The format of this file is simple.
44Empty lines and lines beginning with a hash sign
45.Pq Ql #
46are ignored.
47A line between brackets denotes the start of a ruleset.
48In the brackets should be the name of the ruleset and its number,
49separated by an equal sign.
50.Pp
51Other lines are rule specifications as documented in
52.Xr devfs 8 ,
53in the section
54.Sx "Rule Specification" .
55These lines are prepended with
56.Dq Li rule
57and are passed to
58.Xr devfs 8
59by the startup scripts of the system.
60It is important to put path elements that contain
61.Xr glob 3
62special characters between quotes.
63.Pp
64Rulesets should have a unique name and number.
65.Pp
66All rules that follow a ruleset declaration belong to that ruleset, until a
67new ruleset is started.
68.Pp
69One custom ruleset has to be enabled in
70.Pa /etc/rc.conf ,
71otherwise it will not be applied to the
72.Pa /dev
73file system by the default system startup process.
74For example, to enable a
75.Dq Li localrules
76ruleset for the
77.Pa /dev
78file system, you would have to use something like this in your
79.Pa rc.conf
80file:
81.Bd -literal -offset indent
82devfs_system_ruleset="localrules"
83.Ed
84.Pp
85The rules are loaded at boot via the devfs service.
86To load modified rules after the system has booted, run the command:
87.Bd -literal -offset indent
88service devfs restart
89.Ed
90.Sh FILES
91.Bl -tag -compact -width Pa
92.It Pa /etc/defaults/devfs.rules
93Default
94.Nm
95configuration file.
96.It Pa /etc/devfs.rules
97Local
98.Nm
99configuration file.
100Rulesets in here override those in
101.Pa /etc/defaults/devfs.rules
102with the same ruleset number, otherwise the two files are effectively merged.
103.El
104.Sh EXAMPLES
105To make all the partitions of
106.Xr da 4
107devices readable and writable by their owner and the
108.Dq Li usb
109group, the following rule may be used:
110.Pp
111.Dl "[localrules=10]"
112.Dl "add path 'da*s*' mode 0660 group usb"
113.Pp
114The first line declares and starts a new ruleset, with the name
115.Va localrules
116and the number 10.
117.Pp
118To give
119.Xr usbconfig 8
120and
121.Xr libusb 3
122enabled applications permission to all usb devices for their owner and the
123.Dq Li usb
124group, a similar rule may be used:
125.Pp
126.Dl "add path 'usb/*' mode 0660 group usb"
127.Sh SEE ALSO
128.Xr glob 3 ,
129.Xr devfs 5 ,
130.Xr devfs.conf 5 ,
131.Xr devfs 8 ,
132.Xr service 8
133.Sh AUTHORS
134This manual page was written by
135.An Roland Smith Aq Mt rsmith@xs4all.nl .
136