1e530e044SWarner Losh.\" 2f86e6000SWarner Losh.\" Copyright (c) 2002 M. Warner Losh <imp@FreeBSD.org> 3e530e044SWarner Losh.\" 4e530e044SWarner Losh.\" Redistribution and use in source and binary forms, with or without 5e530e044SWarner Losh.\" modification, are permitted provided that the following conditions 6e530e044SWarner Losh.\" are met: 7e530e044SWarner Losh.\" 1. Redistributions of source code must retain the above copyright 8e530e044SWarner Losh.\" notice, this list of conditions and the following disclaimer. 9e530e044SWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright 10e530e044SWarner Losh.\" notice, this list of conditions and the following disclaimer in the 11e530e044SWarner Losh.\" documentation and/or other materials provided with the distribution. 12e530e044SWarner Losh.\" 13e530e044SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14e530e044SWarner Losh.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15e530e044SWarner Losh.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16e530e044SWarner Losh.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17e530e044SWarner Losh.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18e530e044SWarner Losh.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19e530e044SWarner Losh.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20e530e044SWarner Losh.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21e530e044SWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22e530e044SWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23e530e044SWarner Losh.\" SUCH DAMAGE. 24e530e044SWarner Losh.\" 25*bad324acSFelix Johnson.Dd October 19, 2021 26e530e044SWarner Losh.Dt DEVD 8 27e530e044SWarner Losh.Os 28e530e044SWarner Losh.Sh NAME 29e530e044SWarner Losh.Nm devd 30f1e65894SRuslan Ermilov.Nd "device state change daemon" 31e530e044SWarner Losh.Sh SYNOPSIS 32e530e044SWarner Losh.Nm 336a2ae0ebSAlan Somers.Op Fl dnq 348334958aSJoseph Koshy.Op Fl f Ar file 35e1334f93SIan Lepore.Op Fl l Ar num 36e530e044SWarner Losh.Sh DESCRIPTION 37e530e044SWarner LoshThe 38e530e044SWarner Losh.Nm 39e530e044SWarner Loshdaemon provides a way to have userland programs run when certain 40e530e044SWarner Loshkernel events happen. 41e530e044SWarner Losh.Pp 42e530e044SWarner LoshThe following options are accepted. 435ef35a98SRuslan Ermilov.Bl -tag -width ".Fl f Ar file" 44e530e044SWarner Losh.It Fl d 456d1014a3SAlan SomersRun in the foreground instead of becoming a daemon and log additional information for debugging. 468334958aSJoseph Koshy.It Fl f Ar file 478334958aSJoseph KoshyUse configuration file 488334958aSJoseph Koshy.Ar file 498334958aSJoseph Koshyinstead of the default 508334958aSJoseph Koshy.Pa /etc/devd.conf . 518334958aSJoseph KoshyIf option 528334958aSJoseph Koshy.Fl f 538334958aSJoseph Koshyis specified more than once, the last file specified is used. 54e1334f93SIan Lepore.It Fl l Ar num 559102691eSAlan SomersLimit concurrent socket connections to 56e1334f93SIan Lepore.Ar num . 57e1334f93SIan LeporeThe default connection limit is 10. 585a882d77SWarner Losh.It Fl n 59d5986facSRuslan ErmilovDo not process all pending events before becoming a daemon. 60ffd1bc06SRalf S. EngelschallInstead, call daemon right away. 616a2ae0ebSAlan Somers.It Fl q 622c71b835SSevan JaniyanQuiet mode. 632c71b835SSevan JaniyanOnly log messages at priority LOG_WARNING or above. 64e530e044SWarner Losh.El 65e530e044SWarner Losh.Sh IMPLEMENTATION NOTES 66f1e65894SRuslan ErmilovThe 67e530e044SWarner Losh.Nm 68f1e65894SRuslan Ermilovutility 691a1aec6aSJohn Baldwinis a system daemon that runs in the background all the time. 701a1aec6aSJohn BaldwinWhenever a device is added to or removed from the device tree, 711a1aec6aSJohn Baldwin.Nm 726616a2c7SJohn Baldwinwill execute actions specified in 736616a2c7SJohn Baldwin.Xr devd.conf 5 . 746616a2c7SJohn BaldwinFor example, 751a1aec6aSJohn Baldwin.Nm 766616a2c7SJohn Baldwinmight execute 776616a2c7SJohn Baldwin.Xr dhclient 8 78f1e65894SRuslan Ermilovwhen an Ethernet adapter is added to the system, and kill the 796616a2c7SJohn Baldwin.Xr dhclient 8 806616a2c7SJohn Baldwininstance when the same adapter is removed. 816616a2c7SJohn BaldwinAnother example would be for 826616a2c7SJohn Baldwin.Nm 836616a2c7SJohn Baldwinto use a table to locate and load via 846616a2c7SJohn Baldwin.Xr kldload 8 856616a2c7SJohn Baldwinthe proper driver for an unrecognized device that is added to the system. 86e530e044SWarner Losh.Pp 87f1e65894SRuslan ErmilovThe 88e530e044SWarner Losh.Nm 89f1e65894SRuslan Ermilovutility 90e530e044SWarner Loshhooks into the 91e530e044SWarner Losh.Xr devctl 4 92e530e044SWarner Loshdevice driver. 93e530e044SWarner LoshThis device driver has hooks into the device configuration system. 94e530e044SWarner LoshWhen nodes are added or deleted from the tree, this device will 951a1aec6aSJohn Baldwindeliver information about the event to 96e530e044SWarner Losh.Nm . 97e530e044SWarner LoshOnce 98e530e044SWarner Losh.Nm 99e530e044SWarner Loshhas parsed the message, it will search its action list for that kind 1001a1aec6aSJohn Baldwinof event and perform the action with the highest matching value. 101e530e044SWarner LoshFor most mundane uses, the default handlers are adequate. 102e530e044SWarner LoshHowever, for more advanced users, the power is present to tweak every 103e530e044SWarner Loshaspect of what happens. 104e530e044SWarner Losh.Pp 105f1e65894SRuslan ErmilovThe 1061a1aec6aSJohn Baldwin.Nm 107f1e65894SRuslan Ermilovutility 108f1e65894SRuslan Ermilovreads 109f1e65894SRuslan Ermilov.Pa /etc/devd.conf 1108334958aSJoseph Koshyor the alternate configuration file specified with a 1118334958aSJoseph Koshy.Fl f 1128334958aSJoseph Koshyoption and uses that file to drive the rest of the process. 113e530e044SWarner LoshWhile the format of this file is described in 114f1e65894SRuslan Ermilov.Xr devd.conf 5 , 115e530e044SWarner Loshsome basics are covered here. 116*bad324acSFelix Johnson.Pp 117f1e65894SRuslan ErmilovIn the 118f1e65894SRuslan Ermilov.Ic options 119f1e65894SRuslan Ermilovsection, one can define multiple directories to search 120e530e044SWarner Loshfor config files. 121*bad324acSFelix JohnsonThe default config file specifies 122*bad324acSFelix Johnson.Pa /etc/devd 123*bad324acSFelix Johnsonand 124*bad324acSFelix Johnson.Pa /usr/local/etc/devd 125*bad324acSFelix Johnsonas directories to search. 12621414470SRuslan ErmilovAll files in these directories whose names match the pattern 127e33bdcedSCeri Davies.Pa *.conf 128e33bdcedSCeri Daviesare parsed. 129e530e044SWarner LoshThese files are intended to be installed by third party vendors that 1301a1aec6aSJohn Baldwinwish to hook into the 1311a1aec6aSJohn Baldwin.Nm 1321a1aec6aSJohn Baldwinsystem without modifying the user's other 133e530e044SWarner Loshconfig files. 134251bedd1SWarner Losh.Pp 1359102691eSAlan SomersSince 1369102691eSAlan Somers.Xr devctl 4 1379102691eSAlan Somersallows only one active reader, 138251bedd1SWarner Losh.Nm 1399102691eSAlan Somersmultiplexes it, forwarding all events to any number of connected clients. 1409102691eSAlan SomersClients connect by opening the SOCK_SEQPACKET 1412410103cSRuslan Ermilov.Ux 1422410103cSRuslan Ermilovdomain socket at 1439102691eSAlan Somers.Pa /var/run/devd.seqpacket.pipe . 1448334958aSJoseph Koshy.Sh FILES 1459102691eSAlan Somers.Bl -tag -width ".Pa /var/run/devd.seqpacket.pipe" -compact 1468334958aSJoseph Koshy.It Pa /etc/devd.conf 1478334958aSJoseph KoshyThe default 1488334958aSJoseph Koshy.Nm 1498334958aSJoseph Koshyconfiguration file. 1509102691eSAlan Somers.It Pa /var/run/devd.seqpacket.pipe 1518334958aSJoseph KoshyThe socket used by 1528334958aSJoseph Koshy.Nm 1538334958aSJoseph Koshyto communicate with its clients. 1549102691eSAlan Somers.It Pa /var/run/devd.pipe 155d931b81aSAlan SomersA deprecated socket retained for use with old clients. 1568334958aSJoseph Koshy.El 157e530e044SWarner Losh.Sh SEE ALSO 158e530e044SWarner Losh.Xr devctl 4 , 159d50b2720SGleb Smirnoff.Xr devd.conf 5 1602c71b835SSevan Janiyan.Sh HISTORY 1612c71b835SSevan JaniyanThe 1622c71b835SSevan Janiyan.Nm 1632c71b835SSevan Janiyanutility first appeared in 1642c71b835SSevan Janiyan.Fx 5.0 . 165e530e044SWarner Losh.Sh AUTHORS 166e530e044SWarner Losh.An M. Warner Losh 167