2002-07-17 01:46:48 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2002 Dima Dorfman.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2013-04-21 10:08:33 +00:00
|
|
|
.Dd April 21, 2013
|
2002-12-09 13:06:34 +00:00
|
|
|
.Dt DEVFS 8
|
2002-07-17 01:46:48 +00:00
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm devfs
|
|
|
|
.Nd "DEVFS control"
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm
|
|
|
|
.Op Fl m Ar mount-point
|
2002-12-09 13:06:34 +00:00
|
|
|
.Ar keyword
|
2002-07-17 01:46:48 +00:00
|
|
|
.Ar argument ...
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility provides an interface to manipulate properties of
|
|
|
|
.Xr devfs 5
|
|
|
|
mounts.
|
|
|
|
.Pp
|
2003-07-26 12:41:44 +00:00
|
|
|
The
|
|
|
|
.Ar keyword
|
|
|
|
argument determines the context for
|
2002-07-17 01:46:48 +00:00
|
|
|
the rest of the arguments.
|
|
|
|
For example,
|
|
|
|
most of the commands related to the rule subsystem must be preceded by the
|
|
|
|
.Cm rule
|
|
|
|
keyword.
|
|
|
|
The following flags are common to all keywords:
|
2012-06-09 07:18:53 +00:00
|
|
|
.Bl -tag -width 15n
|
2002-07-17 01:46:48 +00:00
|
|
|
.It Fl m Ar mount-point
|
|
|
|
Operate on
|
|
|
|
.Ar mount-point ,
|
|
|
|
which is expected to be a
|
|
|
|
.Xr devfs 5
|
|
|
|
mount.
|
|
|
|
If this option is not specified,
|
|
|
|
.Nm
|
|
|
|
operates on
|
|
|
|
.Pa /dev .
|
|
|
|
.El
|
2002-07-28 03:58:12 +00:00
|
|
|
.Ss Rule Subsystem
|
2002-07-17 01:46:48 +00:00
|
|
|
The
|
|
|
|
.Xr devfs 5
|
|
|
|
rule subsystem provides a way for the administrator of a system to control
|
|
|
|
the attributes of DEVFS nodes.
|
|
|
|
.\" XXX devfs node? entry? what?
|
|
|
|
Each DEVFS mount-point has a
|
|
|
|
.Dq ruleset ,
|
|
|
|
or a list of rules,
|
|
|
|
associated with it.
|
|
|
|
When a device driver creates a new node,
|
|
|
|
all the rules in the ruleset associated with each mount-point are applied
|
|
|
|
(see below) before the node becomes visible to the userland.
|
|
|
|
This permits the administrator to change the properties,
|
|
|
|
including the visibility,
|
|
|
|
of certain nodes.
|
|
|
|
For example, one might want to hide all disk nodes in a
|
|
|
|
.Xr jail 2 Ns 's
|
|
|
|
.Pa /dev .
|
|
|
|
.Ss Rule Manipulation
|
|
|
|
Rule manipulation commands follow the
|
|
|
|
.Cm rule
|
|
|
|
keyword.
|
|
|
|
The following flags are common to all of the rule manipulation commands:
|
2012-06-09 07:18:53 +00:00
|
|
|
.Bl -tag -width 15n
|
2002-07-17 01:46:48 +00:00
|
|
|
.It Fl s Ar ruleset
|
|
|
|
Operate on the ruleset with the number
|
|
|
|
.Ar ruleset .
|
|
|
|
If this is not specified,
|
|
|
|
the commands operate on the ruleset currently associated with the
|
|
|
|
specified mount-point.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The following commands are recognized:
|
2012-06-09 07:18:53 +00:00
|
|
|
.Bl -tag -width 15n
|
2002-07-17 01:46:48 +00:00
|
|
|
.It Cm rule add Oo Ar rulenum Oc Ar rulespec
|
|
|
|
Add the rule described by
|
|
|
|
.Ar rulespec
|
|
|
|
(defined below)
|
|
|
|
to the ruleset.
|
|
|
|
The rule has the number
|
|
|
|
.Ar rulenum
|
|
|
|
if it is explicitly specified;
|
|
|
|
otherwise, the rule number is automatically determined by the kernel.
|
2002-12-09 13:06:34 +00:00
|
|
|
.It Cm rule apply Ar rulenum | rulespec
|
2002-07-17 01:46:48 +00:00
|
|
|
Apply rule number
|
|
|
|
.Ar rulenum
|
|
|
|
or the rule described by
|
|
|
|
.Ar rulespec
|
|
|
|
to the mount-point.
|
2002-12-09 13:06:34 +00:00
|
|
|
Rules that are
|
|
|
|
.Dq applied
|
|
|
|
have their conditions checked against all nodes
|
2004-11-06 11:16:56 +00:00
|
|
|
in the mount-point and the actions taken if they match.
|
2002-07-17 01:46:48 +00:00
|
|
|
.It Cm rule applyset
|
|
|
|
Apply all the rules in the ruleset to the mount-point
|
2002-12-09 13:06:34 +00:00
|
|
|
(see above for the definition of
|
|
|
|
.Dq apply ) .
|
2002-07-17 01:46:48 +00:00
|
|
|
.It Cm rule del Ar rulenum
|
|
|
|
Delete rule number
|
|
|
|
.Ar rulenum
|
|
|
|
from the ruleset.
|
|
|
|
.It Cm rule delset
|
|
|
|
Delete all rules from the ruleset.
|
|
|
|
.It Cm rule show Op Ar rulenum
|
|
|
|
Display the rule number
|
|
|
|
.Ar rulenum ,
|
|
|
|
or all the rules in the ruleset.
|
|
|
|
The output lines (one line per rule) are expected to be valid
|
|
|
|
.Ar rulespec Ns s .
|
|
|
|
.It Cm rule showsets
|
|
|
|
Report the numbers of existing rulesets.
|
|
|
|
.It Cm ruleset Ar ruleset
|
|
|
|
Set ruleset number
|
|
|
|
.Ar ruleset
|
|
|
|
as the current ruleset for the mount-point.
|
|
|
|
.El
|
|
|
|
.Ss Rule Specification
|
|
|
|
Rules have two parts: the conditions and the actions.
|
2004-11-06 11:16:56 +00:00
|
|
|
The conditions determine which DEVFS nodes the rule matches
|
2002-07-17 01:46:48 +00:00
|
|
|
and the actions determine what should be done when a rule matches a node.
|
|
|
|
For example, a rule can be written that sets the GID to
|
2005-02-27 17:22:36 +00:00
|
|
|
.Dq Li operator
|
|
|
|
for all devices of type tape.
|
2002-07-28 06:45:30 +00:00
|
|
|
If the first token of a rule specification is a single dash
|
2002-12-09 13:06:34 +00:00
|
|
|
.Pq Sq Fl ,
|
2002-07-28 06:45:30 +00:00
|
|
|
rules are read from the standard input and the rest of the specification
|
|
|
|
is ignored.
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
|
|
|
The following conditions are recognized.
|
|
|
|
Conditions are ANDed together when matching a device;
|
|
|
|
if OR is desired, multiple rules can be written.
|
2012-06-09 07:18:53 +00:00
|
|
|
.Bl -tag -width 15n
|
2002-07-17 01:46:48 +00:00
|
|
|
.It Cm path Ar pattern
|
|
|
|
Matches any node with a path that matches
|
2004-11-06 11:16:56 +00:00
|
|
|
.Ar pattern ,
|
|
|
|
which is interpreted as a
|
2002-07-17 01:46:48 +00:00
|
|
|
.Xr glob 3 Ns -style
|
|
|
|
pattern.
|
|
|
|
.It Cm type Ar devtype
|
|
|
|
Matches any node that is of type
|
|
|
|
.Ar devtype .
|
|
|
|
Valid types are
|
2002-12-09 13:06:34 +00:00
|
|
|
.Cm disk , mem , tape
|
2002-07-17 01:46:48 +00:00
|
|
|
and
|
2002-12-09 13:06:34 +00:00
|
|
|
.Cm tty .
|
2002-07-17 01:46:48 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The following actions are recognized.
|
|
|
|
Although there is no explicit delimiter between conditions and actions,
|
|
|
|
they may not be intermixed.
|
2012-06-09 07:18:53 +00:00
|
|
|
.Bl -tag -width 15n
|
2002-07-17 01:46:48 +00:00
|
|
|
.It Cm group Ar gid
|
|
|
|
Set the GID of the node to
|
|
|
|
.Ar gid ,
|
|
|
|
which may be a group name
|
|
|
|
(looked up in
|
|
|
|
.Pa /etc/group )
|
|
|
|
or number.
|
|
|
|
.It Cm hide
|
|
|
|
Hide the node.
|
|
|
|
Nodes may later be revived manually with
|
2004-11-06 11:16:56 +00:00
|
|
|
.Xr mknod 8
|
2002-07-17 01:46:48 +00:00
|
|
|
or with the
|
|
|
|
.Cm unhide
|
|
|
|
action.
|
|
|
|
.It Cm include Ar ruleset
|
|
|
|
Apply all the rules in ruleset number
|
|
|
|
.Ar ruleset
|
|
|
|
to the node.
|
|
|
|
This does not necessarily result in any changes to the node
|
|
|
|
(e.g., if none of the rules in the included ruleset match).
|
2010-02-21 10:29:45 +00:00
|
|
|
Include commands in the referenced
|
|
|
|
.Ar ruleset
|
|
|
|
are not resolved.
|
2002-07-17 01:46:48 +00:00
|
|
|
.It Cm mode Ar filemode
|
|
|
|
Set the file mode to
|
|
|
|
.Ar filemode ,
|
2004-11-06 11:03:59 +00:00
|
|
|
which is interpreted as in
|
|
|
|
.Xr chmod 1 .
|
2002-07-17 01:46:48 +00:00
|
|
|
.It Cm user Ar uid
|
|
|
|
Set the UID to
|
|
|
|
.Ar uid ,
|
|
|
|
which may be a user name
|
|
|
|
(looked up in
|
|
|
|
.Pa /etc/passwd )
|
|
|
|
or number.
|
|
|
|
.It Cm unhide
|
|
|
|
Unhide the node.
|
|
|
|
.El
|
2002-07-28 03:58:12 +00:00
|
|
|
.Sh IMPLEMENTATION NOTES
|
2004-11-06 11:16:56 +00:00
|
|
|
Rulesets are created by the kernel at the first reference
|
2002-07-17 01:46:48 +00:00
|
|
|
and destroyed when the last reference disappears.
|
|
|
|
E.g., a ruleset is created when a rule is added to it or when it is set
|
2004-11-06 11:16:56 +00:00
|
|
|
as the current ruleset for a mount-point, and
|
|
|
|
a ruleset is destroyed when the last rule in it is deleted
|
2002-07-17 01:46:48 +00:00
|
|
|
and no other references to it exist
|
2004-11-06 11:16:56 +00:00
|
|
|
(i.e., it is not included by any rules and it is not the current ruleset
|
2002-07-17 01:46:48 +00:00
|
|
|
for any mount-point).
|
2002-07-28 03:58:12 +00:00
|
|
|
.Pp
|
2002-07-17 01:46:48 +00:00
|
|
|
Ruleset number 0 is the default ruleset for all new mount-points.
|
|
|
|
It is always empty, cannot be modified or deleted, and does not show up
|
|
|
|
in the output of
|
|
|
|
.Cm showsets .
|
2002-07-28 03:58:12 +00:00
|
|
|
.Pp
|
2002-07-17 01:46:48 +00:00
|
|
|
Rules and rulesets are unique to the entire system,
|
|
|
|
not a particular mount-point.
|
|
|
|
I.e., a
|
|
|
|
.Cm showsets
|
|
|
|
will return the same information regardless of the mount-point specified with
|
|
|
|
.Fl m .
|
2004-11-06 11:16:56 +00:00
|
|
|
The mount-point is only relevant when changing what its current ruleset is
|
2002-07-17 01:46:48 +00:00
|
|
|
or when using one of the apply commands.
|
2005-06-14 11:24:56 +00:00
|
|
|
.Sh FILES
|
2012-06-09 07:18:53 +00:00
|
|
|
.Bl -tag -width "Pa /usr/share/examples/etc/devfs.conf" -compact
|
2005-06-14 11:24:56 +00:00
|
|
|
.It Pa /etc/defaults/devfs.rules
|
2006-11-05 19:37:27 +00:00
|
|
|
Default
|
|
|
|
.Nm
|
|
|
|
configuration file.
|
2005-06-14 11:24:56 +00:00
|
|
|
.It Pa /etc/devfs.rules
|
2006-11-05 19:37:27 +00:00
|
|
|
Local
|
|
|
|
.Nm
|
2010-02-21 10:29:45 +00:00
|
|
|
configuration file. Rulesets in here override those in
|
2012-03-29 05:02:12 +00:00
|
|
|
.Pa /etc/defaults/devfs.rules
|
|
|
|
with the same ruleset number, otherwise the two files are effectively merged.
|
2006-11-05 19:37:27 +00:00
|
|
|
.It Pa /etc/devfs.conf
|
|
|
|
Boot-time
|
|
|
|
.Nm
|
|
|
|
configuration file.
|
|
|
|
.It Pa /usr/share/examples/etc/devfs.conf
|
|
|
|
Example boot-time
|
|
|
|
.Nm
|
|
|
|
configuration file.
|
2005-06-14 11:24:56 +00:00
|
|
|
.El
|
2002-07-28 03:58:12 +00:00
|
|
|
.Sh EXAMPLES
|
2002-07-17 01:46:48 +00:00
|
|
|
When the system boots,
|
|
|
|
the only ruleset that exists is ruleset number 0;
|
|
|
|
since the latter may not be modified, we have to create another ruleset
|
|
|
|
before adding rules.
|
2002-12-09 13:06:34 +00:00
|
|
|
Note that since most of the following examples do not specify
|
2002-07-17 01:46:48 +00:00
|
|
|
.Fl m ,
|
|
|
|
the operations are performed on
|
|
|
|
.Pa /dev
|
|
|
|
(this only matters for things that might change the properties of nodes).
|
|
|
|
.Pp
|
|
|
|
Specify that ruleset 10 should be the current ruleset for
|
|
|
|
.Pa /dev
|
2013-04-21 10:08:33 +00:00
|
|
|
(if it does not already exist, it is created):
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
2013-04-21 10:08:33 +00:00
|
|
|
.Dl "devfs ruleset 10"
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
|
|
|
Add a rule that causes all nodes that have a path that matches
|
2002-12-09 13:06:34 +00:00
|
|
|
.Dq Li speaker
|
2002-07-17 01:46:48 +00:00
|
|
|
(this is only
|
|
|
|
.Pa /dev/speaker )
|
|
|
|
to have the file mode 666 (read and write for all).
|
|
|
|
Note that if any such nodes already exist, their mode will not be changed
|
|
|
|
unless this rule (or ruleset) is explicitly applied (see below).
|
|
|
|
The mode
|
|
|
|
.Em will
|
|
|
|
be changed if the node is created
|
|
|
|
.Em after
|
|
|
|
the rule is added
|
|
|
|
(e.g., the
|
|
|
|
.Pa atspeaker
|
2013-04-21 10:08:33 +00:00
|
|
|
module is loaded after the above rule is added):
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
2013-04-21 10:08:33 +00:00
|
|
|
.Dl "devfs rule add path speaker mode 666"
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
|
|
|
Apply all the rules in the current ruleset to all the existing nodes.
|
2013-04-21 10:08:33 +00:00
|
|
|
E.g., if the below rule was added after
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pa /dev/speaker
|
|
|
|
was created,
|
2004-11-06 11:16:56 +00:00
|
|
|
this command will cause its file mode to be changed to 666
|
2013-04-21 10:08:33 +00:00
|
|
|
as prescribed by the rule:
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
2013-04-21 10:08:33 +00:00
|
|
|
.Dl "devfs rule applyset"
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
2002-12-09 13:06:34 +00:00
|
|
|
For all devices with a path that matches
|
|
|
|
.Dq Li snp* ,
|
2005-03-18 20:21:46 +00:00
|
|
|
set the file mode to 660 and the GID to
|
2002-12-09 13:06:34 +00:00
|
|
|
.Dq Li snoopers .
|
2002-07-17 01:46:48 +00:00
|
|
|
This permits users in the
|
2002-12-09 13:06:34 +00:00
|
|
|
.Dq Li snoopers
|
2002-07-17 01:46:48 +00:00
|
|
|
group to use the
|
|
|
|
.Xr snp 4
|
2013-04-21 10:08:33 +00:00
|
|
|
devices
|
|
|
|
(quoting the argument to
|
|
|
|
.Cm path
|
|
|
|
is often necessary to disable the shell's globbing features):
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
2013-04-21 10:08:33 +00:00
|
|
|
.Dl devfs rule add path "snp*" mode 660 group snoopers
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
|
|
|
Add a rule to ruleset number 20.
|
|
|
|
Since this ruleset is not the current ruleset for any mount-points,
|
|
|
|
this rule is never applied automatically (unless ruleset 20 becomes
|
2013-04-21 10:08:33 +00:00
|
|
|
a current ruleset for some mount-point at a later time):
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
2013-04-21 10:08:33 +00:00
|
|
|
.Dl "devfs rule -s 20 add type disk group wheel"
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
2013-04-21 10:08:33 +00:00
|
|
|
Explicitly apply all rules in ruleset number 20 to the DEVFS mount on
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pa /my/jail/dev .
|
2002-12-09 13:06:34 +00:00
|
|
|
It does not matter that ruleset 20 is not the current ruleset for that
|
2013-04-21 10:08:33 +00:00
|
|
|
mount-point; the rules are still applied:
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
2013-04-21 10:08:33 +00:00
|
|
|
.Dl "devfs -m /my/jail/dev rule -s 20 applyset"
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
2013-04-21 10:08:33 +00:00
|
|
|
Since the following rule has no conditions, the action
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pq Cm hide
|
2013-04-21 10:08:33 +00:00
|
|
|
will be applied to all nodes:
|
2002-07-17 01:46:48 +00:00
|
|
|
.Pp
|
2013-04-21 10:08:33 +00:00
|
|
|
.Dl "devfs rule apply hide"
|
2002-07-28 06:45:30 +00:00
|
|
|
.Pp
|
2013-04-21 10:08:33 +00:00
|
|
|
Since hiding all nodes is not very useful, we can undo it.
|
|
|
|
The following applies
|
2002-07-28 06:45:30 +00:00
|
|
|
.Cm unhide
|
|
|
|
to all the nodes,
|
2013-04-21 10:08:33 +00:00
|
|
|
causing them to reappear:
|
2002-07-28 06:45:30 +00:00
|
|
|
.Pp
|
2013-04-21 10:08:33 +00:00
|
|
|
.Dl "devfs rule apply unhide"
|
2002-07-28 06:45:30 +00:00
|
|
|
.Pp
|
|
|
|
Add all the rules from the file
|
|
|
|
.Pa my_rules
|
2013-04-21 10:08:33 +00:00
|
|
|
to ruleset 10:
|
2002-07-28 06:45:30 +00:00
|
|
|
.Pp
|
2013-04-21 10:08:33 +00:00
|
|
|
.Dl "devfs rule -s 10 add - < my_rules"
|
2002-07-28 06:45:30 +00:00
|
|
|
.Pp
|
2013-04-21 10:08:33 +00:00
|
|
|
The below copies all the rules from ruleset 20 into ruleset 10.
|
2002-07-28 06:45:30 +00:00
|
|
|
The rule numbers are preserved,
|
|
|
|
but ruleset 10 may already have rules with non-conflicting numbers
|
|
|
|
(these will be preserved).
|
2013-04-21 10:08:33 +00:00
|
|
|
Since
|
|
|
|
.Cm show
|
|
|
|
outputs valid rules,
|
|
|
|
this feature can be used to copy rulesets:
|
|
|
|
.Pp
|
|
|
|
.Dl "devfs rule -s 20 show | devfs rule -s 10 add -"
|
2002-07-17 01:46:48 +00:00
|
|
|
.Sh SEE ALSO
|
2003-07-26 12:41:44 +00:00
|
|
|
.Xr chmod 1 ,
|
2002-07-17 01:46:48 +00:00
|
|
|
.Xr jail 2 ,
|
|
|
|
.Xr glob 3 ,
|
|
|
|
.Xr devfs 5 ,
|
2006-11-05 19:37:27 +00:00
|
|
|
.Xr devfs.conf 5 ,
|
|
|
|
.Xr devfs.rules 5 ,
|
2002-07-17 01:46:48 +00:00
|
|
|
.Xr chown 8 ,
|
|
|
|
.Xr jail 8 ,
|
|
|
|
.Xr mknod 8
|
|
|
|
.Sh AUTHORS
|
|
|
|
.An Dima Dorfman
|