tail head cat sleep
QR code linking to this page

Manual Pages  — DEVD.CONF

NAME

devd.conf – configuration file for devd(8)

CONTENTS

DESCRIPTION

General Syntax

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:
attach Specifies various matching criteria and actions to perform when a newly attached device matches said criteria.
detach Specifies various matching criteria and actions to perform when a newly detached device matches said criteria.
nomatch
  Specifies various matching criteria and actions to perform when no device driver currently loaded in the kernel claims a (new) device.
notify Specifies various matching criteria and actions to perform when the kernel sends an event notification to userland.
options
  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";
};

Sub-statements

The following sub-statements are supported within the options statement.
directory "/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.
pid-file " /var/run/devd.pid";
  Specifies PID file.
set 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 ‘amp;!’, 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.
action "command";
  Command to execute upon a successful match. Example "/etc/pccard_ether $device-name start".
class "string";
  This is shorthand for " match "class ""string"".
device-name "string";
  This is shorthand for " match "device-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.
match "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.
media-type "string";
  For network devices, media-type will match devices that have the given media type. Valid media types are: "Ethernet", "802.11", and "ATM".
subdevice "string";
  This is shorthand for " match "subdevice ""string"".

The following sub-statements are supported within the nomatch statement.
action "command";
  Same as above.
match "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.
action "command";
  Command to execute upon a successful match. Example "/etc/rc.d/power_profile $notify".
match "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.
media-type "string";
  See above.

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

Variable Description
* The entire message from the current event.
_ The entire message from the current event, after the initial type character.
timestamp The time this event was processed, in seconds since 1970 dot fraction.
bus Device name of parent bus.
cdev Device node path if one is created by the devfs(5) filesystem.
class Device class.
comm Executable name (kernel).
core Path to core file (kernel).
device Device ID.
devclass Device Class (USB).
devsubclass Device Sub-class (USB).
device-name Name of attached/detached device.
endpoints Endpoint count (USB).
function Card functions.
interface Interface ID (USB).
intclass Interface Class (USB).
intprotocol Interface Protocol (USB).
intsubclass Interface Sub-class (USB).
jail Jail name for the process triggering the rule (RCTL).
mode Peripheral mode (USB).
notify Match the value of the "notify" variable.
parent Parent device.
pid PID of the process triggering the rule (RCTL).
port Hub port number (USB).
product Product ID (USB).
release Hardware revision (USB).
ruid Real UID of the process triggering the rule (RCTL).
rule Rule (RCTL).
sernum Serial Number (USB).
slot Card slot.
subvendor Sub-vendor ID (PCI).
subdevice Sub-device ID (PCI).
subsystem Matches a subsystem of a system, see below.
system Matches a system type, see below.
type Type of notification, see below.
vendor Vendor ID.

Notify matching

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

System
Subsystem Type Description
ACPIEvents related to the ACPI Subsystem.
ACPIACADAC line state ($notify=0x00 is offline, 0x01 is online).
ACPIButtonButton state ($notify=0x00 is power, 0x01 is sleep).
ACPICMBATBattery events.
ACPIDockDock state ($notify=0x00 is undocked, 0x01 is docked).
ACPILidLid state ($notify=0x00 is closed, 0x01 is open).
ACPIPROCESSORProcessor state/configuration ($notify=0x81 is a change in available Cx states).
ACPIResumeResume notification.
ACPISuspendSuspend notification.
ACPIThermalThermal zone events.

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

System
Subsystem Type Description
CAMEvents related to the cam(4) system.
CAMperiphEvents related to peripheral devices.
CAMperipherrorGeneric errors.
CAMperiphtimeoutCommand timeouts.

System
Subsystem Type Description
CARPEvents related to the carp(4) protocol.

CARP
vhid@inetThe "subsystem" contains the actual CARP vhid and the name of the network interface on which the event took place.

CARP
vhid@inet MASTERNode become the master for a virtual host.

CARP
vhid@inet BACKUPNode become the backup for a virtual host.

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

System
Subsystem Type Description
IFNET
IFNET inetThe "subsystem" is the actual name of the network interface on which the event took place.
IFNET inetLINK_UPCarrier status changed to UP.
IFNET inetLINK_DOWNCarrier status changed to DOWN.
IFNET inetATTACHThe network interface is attached to the system.
IFNET inetDETACHThe network interface is detached from the system.

System
Subsystem Type Description
DEVFS
DEVFSCDEVCREATEThe devfs(5) node is created.
DEVFSCDEVDESTROYThe devfs(5) node is destroyed.

System
Subsystem Type Description
ETHERNET inet IFATTACHNotification when the default VNET instance of the inet interface is attached.

System
Subsystem Type Description
GEOMEvents related to the geom(4) framework. The difference compared to DEVFS is that GEOM only includes disk-like devices.
GEOMDEVCREATEA geom(4) device node is created.
GEOMDEVDESTROYA geom(4) device node is destroyed.
GEOMDEVGEOM::physpathThe physical path of a device has changed.
GEOMDEVGEOM::rotation_rateThe rotation rate of the disk has changed.
GEOMDEVMEDIACHANGEPhysical media has changed.
GEOMDEVSIZECHANGEA geom(4) provider size has changed.

System
Subsystem Type Description
kernpowerresumeNotification 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
kernelsignalcoredumpNotification that a process has crashed and dumped core.
kernelpowerresumeNotification that the system has woken from the suspended state.

System
Subsystem Type Description
PMUNotification of events from various types of Power Management Units.
PMUACNotifications of AC power related events.
PMUACovervoltageAn over-voltage condition was detected on the AC power line.
PMUACpluggedPower has been applied to the AC power line.
PMUACunpluggedPower has been removed from the AC power line.
PMUBattery
PMUBattery absentBattery is no longer absent.
PMUBattery chargedThe battery has become charged.
PMUBattery chargingThe battery has started charging.
PMUBattery disconnectedThe battery has been disconnected.
PMUBattery high-tempThe battery reported a temperature over the limit.
PMUBattery low-tempThe battery reported a temperature under the limit.
PMUBattery pluggedThe battery has become plugged (eg connected).
PMUBattery shutdown-thresholdThe power in the battery has fallen below the shutdown threshold.
PMUBattery warning-thresholdThe power in the battery has fallen below the warn the user threshold.
PMUButton pressedA button on a adb(4) or pmu(4) has been pressed.
PMUkeysOne of the keys on the adb(4) keyboard has been pressed.
PMUkeys brightnessA brightness level change has been requested. Direction is in the $notify variable.
PMUkeys muteThe mute key
PMUkeys volumeA volume level change has been requested. Direction is in the $notify variable.
PMUkeys ejectAn ejection has been requested.
PMUlid closeThe pmc(4) device has detected the lid closing.
PMUlid openThe pmc(4) device has detected the lid openinging.
PMUPOWER ACLINEThe pmc(4) device has deteted an AC line state ($notify=0x00 is offline, 0x01 is online).
PMUUSB overvoltageAn over-voltage condition on the power lines for the USB power pins.
PMUUSB pluggedA device has been plugged into a USB device.
PMUUSB undervoltageAn under-voltage condition on the power lines for the USB power pins.
PMUUSB unpluggedA device has been unplugged into a USB device.

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

System
Subsystem Type Description
USBEvents related to the USB subsystem.
USBDEVICEATTACHUSB device is attached to the system.
USBDEVICEDETACHUSB device is detached to the system.
USBINTERFACEATTACHUSB interface is attached to a device.
USBINTERFACEDETACHUSB interface is detached from a device.

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

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.

FILES

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

EXAMPLES

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

SEE ALSO

BUGS

The variable expansion's interaction with single quotes is suboptimal and surprising.

DEVD.CONF (5) September 22, 2022

tail head cat sleep
QR code linking to this page


Please direct any comments about this manual page service to Ben Bullock. Privacy policy.