<commit_before>.\"
.\" Copyright (c) 2002 <NAME>
.\" 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. The name of the author may not be used to endorse or promote products
.\"    derived from this software without specific prior written permission.
.\"
.\" 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$
.\"
.\" The section on comments was taken from named.conf.5, which has the
.\" following copyright:
.\" Copyright (c) 1999-2000 by Internet Software Consortium
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
.\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
.\" CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
.\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
.\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
.\" SOFTWARE.
.\"
.Dd October 17, 2002
.Dt DEVD.CONF 5
.Os
.Sh NAME
.Nm devd.conf
.Nd configuration file for
.Xr devd 8
.Sh DESCRIPTION
.Ss General Syntax
A
.Xr devd 8
configuration consists of two general features, statements
and comments.
All statements end with a semicolon.
Many statements can contain substatements, which are also
terminated with a semicolon.
.Pp
The following statements are supported:
.Bl -tag -width ".Ic options"
.It Ic options
specifies various options and parameters for the operation of
.Xr devd 8 .
.It Ic attach
specifies various matching criteria and actions to perform when
a newly attached device matches said criteria.
.It Ic detach
specifies various matching criteria and actions to perform when
a newly detached device matches said criteria.
.It Ic nomatch
specifies various matching criteria and actions to perform when
no device driver currently loaded in the kernel claims a (new)
device.
.El
.Pp
Statements may occur in any order in the configuration file, and may be
repeated as often as required.
Further details on the syntax and meaning of each statement and their
substatements are explained below.
.Pp
Comments may appear anywhere that whitespace may appear in a
configuration file.
To appeal to programmers of all kinds, they can
be written in C, C++, or shell/Perl constructs.
.Pp
C-style comments start with the two characters
.Ql /*
(slash, star) and end with
.Ql */
(star, slash).
Because they are completely delimited with these characters,
they can be used to comment only a portion of a line or to span
multiple lines.
.Pp
C-style comments cannot be nested.
For example, the following is
not valid because the entire comment ends with the first
.Ql */ :
.Bd -literal -offset indent
/* This is the start of a comment.
   This is still part of the comment.
/* This is an incorrect attempt at nesting a comment. */
   This is no longer in any comment. */
.Ed
.Pp
C++-style comments start with the two characters
.Ql //
(slash, slash) and continue to the end of the physical line.
They cannot be continued across multiple physical lines; to have
one logical comment span multiple lines, each line must use the
.Ql //
pair.
For example:
.Bd -literal -offset indent
// This is the start of a comment.  The next line
// is a new comment, even though it is logically
// part of the previous comment.
.Ed
.Sh FILES
.Bl -tag -width ".Pa /etc/devd.conf" -compact
.It Pa /etc/devd.conf
The
.Xr devd 8
configuration file.
.El
.Sh SEE ALSO
.Xr devd 8<commit_msg>MFC: devd.conf.5 v1.9 >   flesh out the devd.conf man page...  Mostly from the PR, but did a couple >   gramatical tweaks along w/ sorting the list, and adding that serial is >   available for USB....<commit_after>.\"
.\" Copyright (c) 2002 <NAME>
.\" 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. The name of the author may not be used to endorse or promote products
.\"    derived from this software without specific prior written permission.
.\"
.\" 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$
.\"
.\" The section on comments was taken from named.conf.5, which has the
.\" following copyright:
.\" Copyright (c) 1999-2000 by Internet Software Consortium
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
.\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
.\" CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
.\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
.\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
.\" SOFTWARE.
.\"
.Dd October 7, 2006
.Dt DEVD.CONF 5
.Os
.Sh NAME
.Nm devd.conf
.Nd configuration file for
.Xr devd 8
.Sh DESCRIPTION
.Ss General Syntax
A
.Xr devd 8
configuration consists of two general features, statements
and comments.
All statements end with a semicolon.
Many statements can contain substatements, which are also
terminated with a semicolon.
.Pp
The following statements are supported:
.Bl -tag -width ".Ic options"
.It Ic attach
Specifies various matching criteria and actions to perform when
a newly attached device matches said criteria.
.It Ic detach
Specifies various matching criteria and actions to perform when
a newly detached device matches said criteria.
.It Ic nomatch
Specifies various matching criteria and actions to perform when
no device driver currently loaded in the kernel claims a (new)
device.
.It Ic notify
Specifies various matching criteria and actions to perform when the kernel
sends an event notification to userland.
.It Ic options
Specifies various options and parameters for the operation of
.Xr devd 8 .
.El
.Pp
Statements may occur in any order in the configuration file, and may be
repeated as often as required.
Further details on the syntax and meaning of each statement and their
substatements are explained below.
.Pp
Each statement, except
.Dq options
has a priority (an arbitrary number) associated with it, where
.Ql 0
is defined as the lowest priority.
If two statements match the same event, only the action of the statement with
highest priority will be executed.
In this way generic statements can be overridden for devices or
notifications that require special attention.
.Pp
The general syntax of a statement is:
.Pp
.Bd -literal -offset indent
statement priority {
	substatement "value";
	...
	substatement "value";
};
.Ed
.Pp
.Ss Sub-statements
The following sub-statements are supported within the
.Dq options
statement.
.Bl -tag -width ".Ic directory"
.It Ic directory \*q/some/path\*q;
Adds the given directory to the list of directories from which
.Xr devd 8
will read
configuration files. Any number of
.Dq directory
statements can be used.
.It Ic pid-file \*q/var/run/devd.pid\*q;
Specifies pid file.
.It Ic set regexp-name \*q(some|regexp)\*q;
Creates a regular expression and assigns it to the variable
.Va regexp-name .
The variable is avaiable throughout the rest of
the configuration file.
All regular expressions have an implicit
.Ql Li ^$
around them.
.El
.Pp
The following sub-statements are supported within the
.Dq attach
and
.Dq detach
statements.
.Bl -tag -width ".Ic directory"
.It Ic action \*qcommand\*q;
Command to execute upon a successful match.
Example
.Ic /etc/pccard_ether $device-name start
.It Ic class \*qstring\*q;
This is shorthand for
.Dq match \*qclass\*q .
.It Ic device-name \*qstring\*q;
This is shorthand for
.Dq match \*qdevice-name\*q .
This matches a device named
.Va string ;
which is allowed to be a regular expression or a variable previously created
containing a regular expression.
The
.Va device-name
variable
is avaiable for later use with the action-statement.
.It Ic match \*qvariable\*q \*qvalue\*q;
Matches the content of
.Va value
against
.Va variable ,
the content of
.Va value
may be a regular expression.
Not required during
.Dq Li attach
nor
.Dq Li detach
events since the
.Dq Li device-name
statement takes care of all device matching.
For a partial list of variables, see below.
.It Ic media-type \*qstring\*q;
This is shorthand for
.Dq match \*qdevice-name\*q .
.It Ic subdevice \*qstring\*q;
This is shorthand for
.Dq match \*qsubdevice\*q .
.El
.Pp
The following sub-statements are supported within the
.Dq nomatch
statement.
.Bl -tag -width ".Ic directory"
.It Ic action \*qcommand\*q;
Same as above.
.It Ic match \*qvariable\*q \*qvalue\*q;
Matches the content of
.Va value
against
.Va variable ,
the content of
.Va value
may be a regular expression.
For a partial list of variables, see below.
.El
.Pp
The following sub-statements are supported within the
.Dq notify
statement.
The
.Dq Li notify
variable is avaiable inside this statement and contains, a value, depending
on which system and subsystem that delivered the event.
.Bl -tag -width ".Ic directory"
.It Ic action \*qcommand\*q;
Command to execute upon a successful match. Example
.Ic /etc/rc.d/power_profile $notify
.It Ic match \*qsystem|subsystem|type|notify\*q \*qvalue\*q;
Any number of
.Dq match
statements can exists within a
.Dq notify
statement.
.Va value
can be either a fixed string or a regular expression.
Below is a list of avaiable systems, subsystems, and types.
.El
.Ss Variables that can be used with the match statement
A partial list of variables and their possible values that can be used together
with the
.Dq match
statement.
.Pp
.Bl -tag -width "manufacturer" -compact
.It Ic Variable
.Ic Description
.It bus
Device name of parent bus
.It cisproduct
CIS-product
.It cisvendor
CIS-vendor
.It class
Device class
.It device
Device ID
.It device-name
Name of attached/detached device
.It function
Card functions
.It manufacturer
Manufacturer ID (pccard)
.It notify
Match the value of the
.Dq Li notify
variable.
.It product
Product ID (pccard)
.It serial
Serial Number (USB)
.It slot
Card slot
.It subvendor
Sub-vendor ID
.It subdevice
Sub-device ID
.It subsystem
Matches a subsystem of a system, see below
.It system
Matches a system type, see below
.It type
Type of notification, see below
.It vendor
Vendor ID
.El
.Ss Notify matching
A Partial list of systems, subsystems, and types used within the
.Dq notify
mechanism.
.Pp
.Bl -tag -width "IFNET" -compact
.It Ic System
.It ACPI
Events related to the ACPI subsystem.
.Bl -tag -compact
.It Ic Subsystem
.It ACAD
AC Line state ($notify=0x00 is offline, 0x01 is online).
.It Button
Button state ($notify=0x00 is power, 0x01 is sleep).
.It CMBAT
Battery events.
.It Lid
Lid state ($notify=0x00 is closed, 0x01 is open).
.It Thermal
Thermal zone events.
.El
.Pp
.It IFNET
Events related to the network subsystem.
.Bl -tag -compact
.It Ic Subsystem
.It [interface]
The
.Dq subsystem
is the actual name of the network interface on which the event
took place.
.Bl -tag -compact
.It Ic Type
.It LINK_UP
Carrier status changed to UP.
.It LINK_DOWN
Carrier status changed to DOWN.
.El
.El
.El
.Pp
A link state change to UP on the interface
.Dq fxp0
would result in the following notify event:
.Bd -literal -offset indent
system=IFNET, subsystem=fxp0, type=LINK_UP
.Ed
.Pp
An AC line state change to
.Dq offline
would result in the following event:
.Bd -literal -offset indent
system=ACPI, subsystem=ACAD, notify=0x00
.Ed
.Ss Comments
Comments may appear anywhere that whitespace may appear in a
configuration file.
To appeal to programmers of all kinds, they can
be written in C, C++, or shell/Perl constructs.
.Pp
C-style comments start with the two characters
.Ql /*
(slash, star) and end with
.Ql */
(star, slash).
Because they are completely delimited with these characters,
they can be used to comment only a portion of a line or to span
multiple lines.
.Pp
C-style comments cannot be nested.
For example, the following is
not valid because the entire comment ends with the first
.Ql */ :
.Bd -literal -offset indent
/* This is the start of a comment.
   This is still part of the comment.
/* This is an incorrect attempt at nesting a comment. */
   This is no longer in any comment. */
.Ed
.Pp
C++-style comments start with the two characters
.Ql //
(slash, slash) and continue to the end of the physical line.
They cannot be continued across multiple physical lines; to have
one logical comment span multiple lines, each line must use the
.Dq //
pair.
For example:
.Bd -literal -offset indent
// This is the start of a comment.  The next line
// is a new comment, even though it is logically
// part of the previous comment.
.Ed
.Sh EXAMPLES
.Bd -literal
#
# This will catch link down events on the interfaces fxp0 and ath0
#
notify 0 {
	match "system"			"IFNET";
	match "subsystem"		"(fxp0|ath0)";
	match "type"			"LINK_DOWN";
	action "logger $subsystem is DOWN";
};

#
# Match lid open/close events
# These can be combined to a single event, by passing the
# value of $notify to the external script.
#
notify 0 {
	match "system"			"ACPI";
	match "subsystem"		"Lid";
	match "notify"			"0x00";
	action "logger Lid closed, we can sleep now!";
};

notify 0 {
	match "system"			"ACPI";
	match "subsystem"		"Lid";
	match "notify"			"0x01";
	action "logger Lid opened, the sleeper must awaken!";
};

#
# Try to configure ath and wi devices with pccard_ether
# as they are attached.
#
attach 0 {
        device-name "(ath|wi)[0-9]+";
        action "/etc/pccard_ether $device-name start";
};

#
# Stop ath and wi devices as they are detached from
# the system.
#
detach 0 {
        device-name "(ath|wi)[0-9]+";
        action "/etc/pccard_ether $device-name stop";
};
.Ed
.Pp
The installed
.Pa /etc/devd.conf
has many additional examples.
.Sh FILES
.Bl -tag -width ".Pa /etc/devd.conf" -compact
.It Pa /etc/devd.conf
The
.Xr devd 8
configuration file.
.El
.Sh SEE ALSO
.Xr devd 8
{'fraction_non_alphanumeric': 0.07756658670111337, 'fraction_numerical': 0.0061511964077012975, 'mean_word_length': 3.7275370747310266, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1033010', 'n_tokens_mistral': 5030, 'n_tokens_neox': 4578, 'n_words': 2474}