GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
DEVD.CONF(5) FreeBSD File Formats Manual DEVD.CONF(5)

devd.conf
configuration file for devd(8)

A 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.

The following statements are supported:

Specifies various matching criteria and actions to perform when a newly attached device matches said criteria.
Specifies various matching criteria and actions to perform when a newly detached device matches said criteria.
Specifies various matching criteria and actions to perform when no device driver currently loaded in the kernel claims a (new) device.
Specifies various matching criteria and actions to perform when the kernel sends an event notification to userland.
Specifies various options and parameters for the operation of devd(8).

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.

Each statement, except options has a priority (an arbitrary number) associated with it, where ‘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.

The general syntax of a statement is:

statement priority {
	substatement "value";
	...
	substatement "value";
};

The following sub-statements are supported within the options statement.
/some/path”;
Adds the given directory to the list of directories from which devd(8) will read all files named "*.conf" as further configuration files. Any number of directory statements can be used.
/var/run/devd.pid”;
Specifies PID file.
regexp-name(some|regexp)”;
Creates a regular expression and assigns it to the variable regexp-name. The variable is available throughout the rest of the configuration file. If the string begins with ‘!’, it matches if the regular expression formed by the rest of the string does not match. All regular expressions have an implicit ‘^$’ around them.

The following sub-statements are supported within the attach and detach statements.

command”;
Command to execute upon a successful match. Example “/etc/pccard_ether $device-name start”.
string”;
This is shorthand for “matchclass” “string””.
“string”;
This is shorthand for “matchdevice-name” “string””. This matches a device named string, which is allowed to be a regular expression or a variable previously created containing a regular expression. The “device-name” variable is available for later use with the action statement.
variable” “value”;
Matches the content of value against variable; the content of value may be a regular expression. Not required during attach nor detach events since the device-name statement takes care of all device matching. For a partial list of variables, see below.
string”;
For network devices, media-type will match devices that have the given media type. Valid media types are: “Ethernet”, “Tokenring”, “FDDI”, “802.11”, and “ATM”.
string”;
This is shorthand for “matchsubdevice” “string””.

The following sub-statements are supported within the nomatch statement.

command”;
Same as above.
variable” “value”;
Matches the content of value against variable; the content of value may be a regular expression. For a partial list of variables, see below.

The following sub-statements are supported within the notify statement. The “notify” variable is available inside this statement and contains, a value, depending on which system and subsystem that delivered the event.

command”;
Command to execute upon a successful match. Example “/etc/rc.d/power_profile $notify”.
system | subsystem | type | notify” “value”;
Any number of match statements can exist within a notify statement; value can be either a fixed string or a regular expression. Below is a list of available systems, subsystems, and types.
string”;
See above.

A partial list of variables and their possible values that can be used together with the match statement. The variables are published by the bus based on characteristics of the device that generated the event (for device events). Variables for other classes of events are dependent on those events.

The entire message from the current event.
The entire message from the current event, after the initial type character.
The time this event was processed, in seconds since 1970 dot fraction.
Device name of parent bus.
Device node path if one is created by the devfs(5) filesystem.
Device class.
Executable name (kernel).
Path to core file (kernel).
Device ID.
Device Class (USB).
Device Sub-class (USB).
Name of attached/detached device.
Endpoint count (USB).
Card functions.
Interface ID (USB).
Interface Class (USB).
Interface Protocol (USB).
Interface Sub-class (USB).
Jail name for the process triggering the rule (RCTL).
Peripheral mode (USB).
Match the value of the “notify” variable.
Parent device.
PID of the process triggering the rule (RCTL).
Hub port number (USB).
Product ID (USB).
Hardware revision (USB).
Real UID of the process triggering the rule (RCTL).
Rule (RCTL).
Serial Number (USB).
Card slot.
Sub-vendor ID (PCI).
Sub-device ID (PCI).
Matches a subsystem of a system, see below.
Matches a system type, see below.
Type of notification, see below.
Vendor ID.

A partial list of systems, subsystems, and types used within the notify mechanism.

System Subsystem Type Description
Events related to the ACPI Subsystem.
AC line state ($notify=0x00 is offline, 0x01 is online).
Button state ($notify=0x00 is power, 0x01 is sleep).
Battery events.
Dock state ($notify=0x00 is undocked, 0x01 is docked).
Lid state ($notify=0x00 is closed, 0x01 is open).
Processor state/configuration ($notify=0x81 is a change in available Cx states).
Resume notification.
Suspend notification.
Thermal zone events.

System Subsystem Type Description
The power button on an Amiga has been pressed.

System Subsystem Type Description
Events related to the cam(4) system.
Events related to peripheral devices.
Generic errors.
Command timeouts.

System Subsystem Type Description
Events related to the carp(4) protocol.
CARP vhid@inet The “subsystem” contains the actual CARP vhid and the name of the network interface on which the event took place.
CARP vhid@inet MASTER Node become the master for a virtual host.
CARP vhid@inet BACKUP Node become the backup for a virtual host.

System Subsystem Type Description
Events related to the coretemp(4) device.
Notification that the CPU core has reached critical temperature.
String containing the temperature of the core that has become too hot.

System Subsystem Type Description
The devfs(5) node is created.
The devfs(5) node is destroyed.

System Subsystem Type Description
inet IFATTACH Notification when the default VNET instance of the inet interface is attached.

System Subsystem Type Description
Events related to the geom(4) framework. The difference compared to DEVFS is that GEOM only includes disk-like devices.
A geom(4) provider is created.
A geom(4) provider is destroyed.
The physical path of a device has changed.
The rotation rate of the disk has changed.
Physical media has changed.
A geom(4) provider size has changed.

System Subsystem Type Description
inet The “subsystem” is the actual name of the network interface on which the event took place.
inet Carrier status changed to UP.
inet Carrier status changed to DOWN.
inet The network interface is attached to the system.
inet The network interface is detached from the system.

System Subsystem Type Description
Notification that the system has woken from the suspended state. Note: this notification is deprecated and will be removed in FreeBSD 14.0.

System Subsystem Type Description
Notification that a process has crashed and dumped core.
Notification that the system has woken from the suspended state.

System Subsystem Type Description
Notification of events from various types of Power Management Units.
Notifications of AC power related events.
An over-voltage condition was detected on the AC power line.
Power has been applied to the AC power line.
Power has been removed from the AC power line.
absent Battery is no longer absent.
charged The battery has become charged.
charging The battery has started charging.
disconnected The battery has been disconnected.
high-temp The battery reported a temperature over the limit.
low-temp The battery reported a temperature under the limit.
plugged The battery has become plugged (eg connected).
shutdown-threshold The power in the battery has fallen below the shutdown threshold.
warning-threshold The power in the battery has fallen below the warn the user threshold.
pressed A button on a adb(4) or pmu(4) has been pressed.
One of the keys on the adb(4) keyboard has been pressed.
brightness A brightness level change has been requested. Direction is in the $notify variable.
mute The mute key
volume A volume level change has been requested. Direction is in the $notify variable.
eject An ejection has been requested.
close The pmc(4) device has detected the lid closing.
open The pmc(4) device has detected the lid openinging.
ACLINE The pmc(4) device has deteted an AC line state ($notify=0x00 is offline, 0x01 is online).
overvoltage An over-voltage condition on the power lines for the USB power pins.
plugged A device has been plugged into a USB device.
undervoltage An under-voltage condition on the power lines for the USB power pins.
unplugged A device has been unplugged into a USB device.

System Subsystem Type Description
Events related to the rctl(8) framework.
A rule with action specified as "devctl" was triggered.

System Subsystem Type Description
Events related to the USB subsystem.
USB device is attached to the system.
USB device is detached to the system.
USB interface is attached to a device.
USB interface is detached from a device.

System Subsystem Type Description
Events from the vfs system.
Events that change what is mounted to the system.
Notification of a filesystem is mounted for the first time.
Notification of a filesystem is remounted (whether or not the options actually change).
Notification of a filesystem being unmounted.

System Subsystem Type Description
BELL RING Notification that the console bell has rung. See vt(4) for details.

System Subsystem Type Description
ZFS Events about the ZFS subsystem. See zfsd(8) and /etc/devd/zfs.conf for details.

A link state change to UP on the interface “fxp0” would result in the following notify event:

system=IFNET subsystem=fxp0 type=LINK_UP

An AC line state change to “offline” would result in the following event:

system=ACPI subsystem=ACAD notify=0x00

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.

C-style comments start with the two characters ‘/*’ (slash, star) and end with ‘*/’ (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.

C-style comments cannot be nested. For example, the following is not valid because the entire comment ends with the first ‘*/’:

/* 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. */

C++-style comments start with the two characters ‘//’ (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 ‘//’ pair. For example:

// This is the start of a comment.  The next line
// is a new comment, even though it is logically
// part of the previous comment.

To prevent issues with special shell characters, the following happens for each variable $foo.
  1. The characters “$'” are inserted.
  2. The string “$foo” is removed.
  3. The value of the foo variable is inserted into the buffer with all single quote characters prefixed by a backslash.

See sh(1) for what this construct means. It is safe in all context, except one: inside single quotes. If foo=meta and bar=var, then a rule like the following:

action "echo '$foo $bar'";
will be presented to the shell via system(3) as
echo '$'meta' $'var''
which produces the following output:
$meta $var
as its output. This is an unanticipated result. A future version of this software will change this behavior. Users are discouraged from using single quotes inside action value without due care.

The above should be written as

action "echo $foo' '$bar"
to produce a single argument to echo. Given the above expansion, juxtaposing bare variables with single quote expressions will produce the right output, regardless of the value of the variable.

/etc/devd.conf
The devd(8) configuration file.

#
# 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!";
};

#
# Match a USB device type
#
notify 0 {
	match "system"			"USB";
	match "subsystem"		"INTERFACE";
	match "type"			"ATTACH";
	match "intclass"		"0x0e";
	action "logger USB video device attached";
};

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

#
# Stop ath and iwn devices as they are detached from
# the system.
#
detach 0 {
        device-name "(ath|iwn)[0-9]+";
        action "/etc/pccard_ether $device-name stop";
};

The installed /etc/devd.conf has many additional examples.

cam(4), coretemp(4), devfs(5), re_format(7), devd(8)

The variable expansion's interaction with single quotes is suboptimal and surprising.
November 3, 2021 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 5 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.