History log of /freebsd-head/sbin/devd/devd.cc
Revision Date Author Comments
698c7e1887bf144ae58a1d2f46f68a796fa02af2 13-Dec-2019 mav <mav@FreeBSD.org> Fix $() handling, broken since the beginning at r108014.

Due to off-by-one error in brackets counting it consumed the rest of the
string, preventing later variables expansions.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.
a476ba06d5016dd96ede66d0a2bb7c2a73d19810 04-Dec-2019 imp <imp@FreeBSD.org> Regularize my copyright notice

o Remove All Rights Reserved from my notices
o imp@FreeBSD.org everywhere
o regularize punctiation, eliminate date ranges
o Make sure that it's clear that I don't claim All Rights reserved by listing
All Rights Reserved on same line as other copyright holders (but not
me). Other such holders are also listed last where it's clear.
76423570504581c90b5dbe356e047bf2df61d665 22-Sep-2018 imp <imp@FreeBSD.org> We don't need shell protection for when we're expanding matches.
Don't add it. This should fix when we do regepx matches against
variables we've set and fix wifi bring up.

PR: 231441
Approved by: re@ (kib)
Differential Revision: https://reviews.freebsd.org/D17267
bdfd6fdefa6ba983a5732126d1116caf47697881 29-Jul-2018 eadler <eadler@FreeBSD.org> Revert "devd: use C++ style casts"

It seems that nullptr is not yet supported by all compilers used by
FreeBSD. :(
1fcffc8bf39c5d9e3a04ace0ce0d7801ffc45d96 29-Jul-2018 eadler <eadler@FreeBSD.org> devd: use C++ style casts
44b812e9b2aa3887c7ee531c59d45ba6bb86130f 29-Jul-2018 eadler <eadler@FreeBSD.org> devd: use static where possible
dc8d1c8d510a5d49b6f34be982c51b0ed8005048 28-Jun-2018 imp <imp@FreeBSD.org> We're not, yet, at C++11 capable on all our plaforms.

Use a possibly slower, but C++98 compatibe way to iterate through the
string.

Noticed by: g++ 4.2.1 and Mark Millard
7a13e318986e65864a83aceba44953e7b4577365 27-Jun-2018 imp <imp@FreeBSD.org> Safely quote all variable expansions.

When expanding a variable set by a message from the kernel, safely
quote all arguments expanded when creating a command line for the
shell.

Reviewd by: Shawn Webb, Oliver Pinter, brd@
Sponsored by: Netflix
d474dd3b7e1f73a0ccbe616b40b4a6b07b966d62 23-May-2018 eadler <eadler@FreeBSD.org> devd: Move variable declaration to header

Reminder by: imp
bbaf7ae7ad0ff2843e5414bda4dbd9364d0269c2 23-May-2018 eadler <eadler@FreeBSD.org> devd: compile at WARNS=6

Verified with "make universe TARGETS='amd64 arm arm64 i386 sparc64'"
840eb4b2e34c2f0db650b325a03268c1902d72f1 23-May-2018 eadler <eadler@FreeBSD.org> devd: correct two warnings

- catching a polymorphic type by value
- "output between 16 and 95 bytes into a destination of size 80"
1f7ec30542b6936efd3c5d041b6f7ffc1d587f3f 16-Apr-2018 brooks <brooks@FreeBSD.org> Remove support for FDDI and token ring media types in userland utilities.

Reviewed by: kib
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D15077
b994bb09e7631bb758c730fd85ceb01449ccac4a 15-Feb-2018 eadler <eadler@FreeBSD.org> devd: don't pass &fds in useless parameters to select(2)

select(2) should be declared as restrict. In addition the only fd in
the fdset is open O_RDONLY, and it's not a socket that can provide OOB
notifications,

Reviewed by: ian, imp, vangyzen
dae41a2e6bc28b87e07fade97fab60d9156e593c 26-Jan-2018 eadler <eadler@FreeBSD.org> devd: minor nits

- mark usage as noreturn
- config does not need a virtual destructor
872b698bd4a1bfc0bf008c09228e6fd238809c75 20-Nov-2017 pfg <pfg@FreeBSD.org> General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
5ba8ef95c5f4e116d0fa696ed6e0cc1d29f4740c 20-Jun-2017 asomers <asomers@FreeBSD.org> devd(8): Remove pidfile on shutdown

MFC after: 3 weeks
Sponsored by: Spectra Logic Corp
051928ab3c7fa1c5fbd7e5dc33a8c947e2e846d0 24-Mar-2017 imp <imp@FreeBSD.org> Use a more stream-lined version of fix_value.

Submitted by: ian@
27fcf5063f876152b0da6d6136b96be74deac444 23-Mar-2017 imp <imp@FreeBSD.org> Implement quote escaping. String values may now contain " if you
it is preceded by \.

foo="I \"like\" C++"

gives the value 'I "like" C++' to the variable 'foo'. If a character
other than " follows the \, both the \ and that character are passed
through.

Differential Revision: https://reviews.freebsd.org/D6286
Sponsored by: Netflix
7e6cabd06e6caa6a02eeb86308dc0cb3f27e10da 28-Feb-2017 imp <imp@FreeBSD.org> Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96
b4406e17e9e4084b5f6c4f425039ae67956c1ea5 19-Jan-2017 asomers <asomers@FreeBSD.org> Fix build of devd with GCC 4.2

Reported by: olivier
Pointy-hat-to: asomers
MFC after: 27 days
X-MFC-with: 312395
Sponsored by: Spectra Logic Corp
41803adfd46383416f7b16a3c0e6079c2aedf82a 18-Jan-2017 asomers <asomers@FreeBSD.org> Fix several Coverity CIDs in devd

CID 1362055, 1362054: File descriptor leaks during shutdown
CID 1362013: Potential null-termination fail with long network device names
CID 1362097: Uncaught exception during memory pressure
CID 1362017, 1362016: Unchecked errors, possibly resulting in weird behavior
if two devd instances start at the same time.
CID 1362015: Unchecked error that will probably never fail

Reported by: Coverity
CID: 1362055 1362054 1362013 1362097 1362017 1362016 1362015
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
00980aa77539981d4d1e3e97de48f110ef43e02f 01-Dec-2016 imp <imp@FreeBSD.org> Simplify test.
00d578928eca75be320b36d37543a7e2a4f9fbdb 27-May-2016 grehan <grehan@FreeBSD.org> Create branch for bhyve graphics import.
02ef7784f5b2272db77fa87b83dd1d3f4f4583a3 03-Apr-2016 imp <imp@FreeBSD.org> Add a timestamp variable to the environment. This is when the event
was read from the kernel by devd.
a5f0ce1fd75ae19f01d9e1ade052999191cae22e 03-Apr-2016 imp <imp@FreeBSD.org> Make $_ match the docs.
2b800612daf9f1e49be89fbebf8432f23f01cbc4 28-Mar-2016 imp <imp@FreeBSD.org> Sometimes, it's useful to export the entire line to an external
program without listening to the devd socket for all events. Define
two new pseudo variables $*, the entire event from devctl and $_,
the entire event without the type character, since it might be easier
to use in some circumstances.
1b837fdf71654caab7c47e99243ae1310269a286 11-Jan-2016 asomers <asomers@FreeBSD.org> MFC r292020

Increase devd's client socket buffer size to 256KB. This is not as large as
it looks, because we'll hit the sockbuf's mbuf limit long before hitting its
data limit. A 256KB data limit allows creating a ZFS pool on about 450
drives without overflowing the client socket buffers.
dc83b58bbee523b7400472f573a44887cbd0642a 07-Jan-2016 bdrewery <bdrewery@FreeBSD.org> MFC r289677:

Fix a ton of speelling errors
c85e616e29482200cd0a47fa6c85165a98a4caaf 10-Dec-2015 ngie <ngie@FreeBSD.org> MFhead @ r292053
61cc3892e13aef6d2a6c2bae4d3ca49a9797eebc 09-Dec-2015 asomers <asomers@FreeBSD.org> Increase devd's client socket buffer size to 256KB. This is not as large as
it looks, because we'll hit the sockbuf's mbuf limit long before hitting its
data limit. A 256KB data limit allows creating a ZFS pool on about 450
drives without overflowing the client socket buffers.

MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D4476
21a3003f8f5c49c0acbcb49462e5b221076076d0 21-Oct-2015 eadler <eadler@FreeBSD.org> Fix a ton of speelling errors

arc lint is helpful

Reviewed By: allanjude, wblock, #manpages, chris@bsdjunk.com
Differential Revision: https://reviews.freebsd.org/D3337
5efc9173fa69c32dee331f42b6cd63d4b6da7125 20-Aug-2014 asomers <asomers@FreeBSD.org> MFC devd-related changes

r270004
Convert devd's client socket to type SOCK_SEQPACKET.

This change consists of two merges from projects/zfsd/head along with the
addition of an ATF test case for the new functionality.

sbin/devd/tests/Makefile
sbin/devd/tests/client_test.c
Add ATF test cases for reading events from both devd socket types.

r266519:
sbin/devd/devd.8
sbin/devd/devd.cc
Create a new socket, of type SOCK_SEQPACKET, for communicating with
clients. SOCK_SEQPACKET sockets preserve record boundaries,
simplying code in the client. The old SOCK_STREAM socket is retained
for backwards-compatibility with existing clients.

r269993:
sbin/devd/devd.8
Fix grammar bug.

r270019 (from bz)
Remove bogus ; at the end of the if condition in order to unbreak gcc builds
after r270004.

MFC after: 4 days
X-MFX with: r270004
c511ec0ad85c2a70edc55e4d611ddcb3314bd7f2 14-Aug-2014 asomers <asomers@FreeBSD.org> Convert devd's client socket to type SOCK_SEQPACKET.

This change consists of two merges from projects/zfsd/head along with the
addition of an ATF test case for the new functionality.

sbin/devd/tests/Makefile
sbin/devd/tests/client_test.c
Add ATF test cases for reading events from both devd socket types.

r266519:
sbin/devd/devd.8
sbin/devd/devd.cc
Create a new socket, of type SOCK_SEQPACKET, for communicating with
clients. SOCK_SEQPACKET sockets preserve record boundaries,
simplying code in the client. The old SOCK_STREAM socket is retained
for backwards-compatibility with existing clients.

r269993:
sbin/devd/devd.8
Fix grammar bug.

CR: https://reviews.freebsd.org/rS266519
MFC after: 5 days
Sponsored by: Spectra Logic
b357774f50743f92e6f3a63766ab5243e3a56265 31-Mar-2014 mjg <mjg@FreeBSD.org> MFC r263758:
Update userspace users of hw.bus.devctl_disable.

This switches the code to use hw.bus.devctl_queue instead.
340d7c934c82e33ea87de998ec1e55d1f170c555 28-Mar-2014 asomers <asomers@FreeBSD.org> MFC r262914

sbin/devd/devd.8
sbin/devd/devd.cc
Add a -q flag to devd that will suppress syslog logging at
LOG_NOTICE or below.
00964cfdfb63860aab46afa0574666b16517e7ae 26-Mar-2014 mjg <mjg@FreeBSD.org> Update userspace users of hw.bus.devctl_disable.

This fixes breakage resulting from r263754.

Reported by: AN <andy@neu.net>
Reviewed by: imp
Pointy hat to: me
94889417b97b6a9e30e7d591f83784988e4b2888 07-Mar-2014 asomers <asomers@FreeBSD.org> sbin/devd/devd.8
sbin/devd/devd.cc
Add a -q flag to devd that will suppress syslog logging at
LOG_NOTICE or below.

Requested by: ian@ and imp@
MFC after: 3 weeks
Sponsored by: Spectra Logic Corporation
eb1a5f8de9f7ea602c373a710f531abbf81141c4 21-Feb-2014 gjb <gjb@FreeBSD.org> Move ^/user/gjb/hacking/release-embedded up one directory, and remove
^/user/gjb/hacking since this is likely to be merged to head/ soon.

Sponsored by: The FreeBSD Foundation
6b686ee50aa7ef91e77ead42af6e89e77fd7057a 10-Jan-2014 asomers <asomers@FreeBSD.org> MFC 259339
sbin/devd/devd.cc
Increase the size of devd's client socket's send buffer from the
default (8k) to 128k. This prevents clients from getting
POLLHUPped during event storms. For example, during zpool creation,
the kernel emits a resource.fs.zfs.statechange event for every vdev
in the pool. A 128k buffer is large enough to hold the statechange
events for a pool with nearly 800 drives.

MFC 259362
sbin/devd/devd.cc
Promoting the SIGINFO handler's log message from LOG_INFO to
LOG_NOTICE, and promoting the "Processing event ..." message from
LOG_DEBUG to LOG_INFO. Setting the logfile to LOG_NOTICE with this
change will have the same result as setting it to LOG_INFO without
this change. Setting it to LOG_INFO with this change will include
the useful "Processing event ..." messages that were previously at
LOG_DEBUG, without including useless messages like "Pushing table".

The intent of this change is that one can log "Processing event ..."
without logging "Pushing table" and related messages that are sent
for every event. The number of lines actually logged is reduced by
about 75% by making this change and setting syslog to LOG_INFO vs
setting syslog to LOG_DEBUG.

etc/syslog.conf
Changing the recommended loglevel to notice instead of info.
6b01bbf146ab195243a8e7d43bb11f8835c76af8 27-Dec-2013 gjb <gjb@FreeBSD.org> Copy head@r259933 -> user/gjb/hacking/release-embedded for initial
inclusion of (at least) arm builds with the release.

Sponsored by: The FreeBSD Foundation
ba9a398e57ac2c83c9a4c772d65dbd67b8953a5f 13-Dec-2013 asomers <asomers@FreeBSD.org> sbin/devd/devd.cc
Promoting the SIGINFO handler's log message from LOG_INFO to
LOG_NOTICE, and promoting the "Processing event ..." message from
LOG_DEBUG to LOG_INFO. Setting the logfile to LOG_NOTICE with this
change will have the same result as setting it to LOG_INFO without
this change. Setting it to LOG_INFO with this change will include
the useful "Processing event ..." messages that were previously at
LOG_DEBUG, without including useless messages like "Pushing table".

The intent of this change is that one can log "Processing event ..."
without logging "Pushing table" and related messages that are sent
for every event. The number of lines actually logged is reduced by
about 75% by making this change and setting syslog to LOG_INFO vs
setting syslog to LOG_DEBUG.

etc/syslog.conf
Changing the recommended loglevel to notice instead of info.

Sponsored by: Spectra Logic Corp
MFC after: 4 weeks
e12149b5f4f1a59a8e4fbd2bfb8b3b9befa9b06d 13-Dec-2013 asomers <asomers@FreeBSD.org> sbin/devd/devd.cc
Increase the size of devd's client socket's send buffer from the
default (8k) to 128k. This prevents clients from getting
POLLHUPped during event storms. For example, during zpool creation,
the kernel emits a resource.fs.zfs.statechange event for every vdev
in the pool. A 128k buffer is large enough to hold the statechange
events for a pool with nearly 800 drives.

Reviewed by: ian, imp
Approved by: ken (mentor)
Sponsored by: Spectra Logic Corp
MFC after: 4 weeks
ef49ef71992236a6dba0657c2b3691f52f75f39e 07-Nov-2013 avg <avg@FreeBSD.org> devd: lower priority of action execution logging to info

Reviewed by: asomers
57892feb9b97b080b26404c1648bcaaf7a04abbb 07-Nov-2013 avg <avg@FreeBSD.org> devd: fix a typo in a comment

Reviewed by: asomers
801a6742bc5d69b3293dc04787d4cd932512f6de 08-Jul-2013 asomers <asomers@FreeBSD.org> Correct the printf format specifier for total_events.
Add __printflike argument checking for devdlog().

Reported by: pjd
Approved by: gibbs (co-mentor)
9906aefa83b151c15370d858dc46d32cdd26ddf2 02-Jul-2013 asomers <asomers@FreeBSD.org> Explicitly include <cstdarg> to fix compilation with libc++. It is implicitly
included by libstdc++.

Reported By: Oliver Hartmann
Approved by: gibbs (co-mentor, implicit)
43aec3b2a7b84716825ba1dc95941aaa100bf03c 01-Jul-2013 asomers <asomers@FreeBSD.org> style(9) fixes, including the removal of page break characters. No functional
changes.

Approved by: gibbs (co-mentor)
ac1ae1504aee457d87f82dbf667b995a1fa6a4ac 01-Jul-2013 asomers <asomers@FreeBSD.org> Add a SIGINFO handler to devd. It will send useful statistics to syslog or
stderr as appropriate. Currently, the only statistic printed is the number of
events received.

Reviewed by: eadler
Approved by: gibbs (co-mentor)
16596db60f50f7a2f26b1e45158d41df037b88c3 01-Jul-2013 asomers <asomers@FreeBSD.org> Add syslog(3) support to devd(8).

sbin/devd/devd.cc
All output will now go to syslog(3) if devd is daemonized, or stderr
if it's running in the foreground.

sbin/devd/devd.8
Remove the "-D" flag. Filtering messages by priority now
happens in the usual syslog way. For performance reasons, a few
extra-verbose debugging statements are now conditional on the "-d" (do
not daemonize) flag.

etc/syslog.conf
etc/newsyslog.conf
Direct messages from devd(8) to /var/log/devd.log, but leave it
disabled by default

Reviewed by: eadler
Approved by: gibbs (co-mentor)
MFC after: never (removed a command-line option from devd)
ce753441d59d3ea068e08e808214672f9e9ebb75 02-May-2013 eadler <eadler@FreeBSD.org> Prefer using the C++ version of the standard headers. These place the
names within the std namespace (and possibly within the global
namespace).

The main advantage is that the C++ versions can provide optimized
versions or simplified interfaces.
ed67ac528d559ab7d3f138a9f4994fc34c829b6f 04-Mar-2013 eadler <eadler@FreeBSD.org> devd: Correct typo in comment.

Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
Approved by: cperciva (mentor)
a3065a2b5815458e9a0892406baf3a73bcedd626 04-Mar-2013 eadler <eadler@FreeBSD.org> devd: Use simpler dst += *x instead of str.append(x, 1).

Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
Approved by: cperciva (mentor)
d359c8655e620cafcc9a7fc6df00c221b1385eae 04-Mar-2013 eadler <eadler@FreeBSD.org> devd: Use string::empty() instea of string::length() == 0.

Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
Approved by: cperciva (mentor)
447034a196dd85fa9d26e5dd15075da57386eec5 04-Mar-2013 eadler <eadler@FreeBSD.org> devd: Avoid unnecessary temporary objects (and simplify the code) when handling std::string.

Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
Approved by: cperciva (mentor)
229e6c166677faa7fb2ebb61f7184420fd6a63e2 04-Mar-2013 eadler <eadler@FreeBSD.org> devd: Simplify while (1) { if (x) break; } to while (!x) {}.

Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
Approved by: cperciva (mentor)
8f1c733aff0017da90fc3540141effc306d8f6a0 04-Mar-2013 eadler <eadler@FreeBSD.org> devd: Remove call to _exit() from signal handler, which also sets a stop flag.

Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
Approved by: cperciva (mentor)
707e0c270aebac8ef4c74bcb4c2926332c7a232f 04-Mar-2013 eadler <eadler@FreeBSD.org> devd: Use volatile sig_atomic_t for the flag set by a signal handler.

Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
Approved by: cperciva (mentor)
5175512e239622e91230d350a1a2986774b17698 04-Mar-2013 eadler <eadler@FreeBSD.org> Constify where possible.

Approved by: cperciva (mentor)
85fcf6286dd7a0721e5b300d232483d5bb13b1a8 30-Jan-2013 ian <ian@FreeBSD.org> Improve devd startup time, by tweaking some string handling routines that are
heavily used when parsing config files. Mostly these changes avoid making
temporary copies of the strings, and avoid doing byte at a time append
operations, on the most-used code path.

On a 1.2 GHz ARM processor this reduces the time to parse the config files
from 13 to 6 seconds.

Reviewed by: imp
Approved by: cognet (mentor)
3e5ced1b98dca63d150904313752d2ee1cf72802 30-Jan-2013 ian <ian@FreeBSD.org> Fix a descriptor leak in devd. Clients reading /var/run/devd.pipe can close
their socket connection any time, and devd only notices that when it gets an
error trying to write an event to the client. On a system with no device
change activity, clients could connect and disappear repeatedly without devd
noticing, leading to an ever-growing list of open socket descriptors in devd.

Now devd uses poll(2) looking for POLLHUP on all existing clients every time
a new client connection is established, and also periodically (once a minute)
to proactively find zombie clients and reap the socket descriptors. It also
now has a connection limit, configurable with a new -l <num> command line arg.
When the maximum number of connections is reached it stops accepting new
connections until some current clients drop off.

Reviewed by: imp
Approved by: cognet (mentor)
d63ec4c24b02575838256ea35e13bf20df348995 06-Dec-2012 eadler <eadler@FreeBSD.org> Prefer the use of initalizer lists to ctor assignment.

Approved by: cperciva
MFC after: 2 weeks
76f827328bff797fb7cf44ba938fedf5f11ab20f 06-Dec-2012 eadler <eadler@FreeBSD.org> Avoid the creation of a temporary object by using the prefix operator
for non-primitive types.

Approved by: cperciva
MFC after: 2 weeks
be40a13e591d429128dff12fe9d55a513ed76e4e 06-Dec-2012 eadler <eadler@FreeBSD.org> Constify where possible

Approved by: cperciva
MFC after: 2 weeks
ab2b1f57e9cea68bf7483479d6e2e84fe7886d5f 05-Dec-2012 dim <dim@FreeBSD.org> Fix an old bug in devd, where it uses std::sort() to sort the various
lists it reads from its configuration files on the priority field.

Because some items in the lists have the same priority, and std::sort()
is not stable, the exact order in which the items are enumerated does
not have to correspond to the order they appear in the configuration
files.

Apparently this was never noticed with libstdc++, but with libc++ it
could cause the "uhid" entry from /etc/devd/usb.conf to be used instead
of the "ums" entry (which is earlier in the file). This caused the
problem described in the PR: the USB mouse module was never loaded, and
the other actions (such as starting moused) were not executed.

To fix the problem, make devd use std:stable_sort() instead.

Reported by: Jan Beich <jbeich@tormail.org>
PR: bin/172958
MFC after: 2 weeks
66da4b41b33657686a22e405117852035b6cc042 22-Sep-2012 pjd <pjd@FreeBSD.org> Use O_CLOEXEC for open instead of separate fcntl(2) call.
2c17ed141e10a6836b6be341077010eacbd69e92 01-Jun-2012 dim <dim@FreeBSD.org> Make devd build with libc++.

MFC after: 3 days
6700bd7cede882c4ef37ce098d1564008df7d3b4 06-Jan-2012 glebius <glebius@FreeBSD.org> Fix build.
fb5f47d254fc4d1fb1cd611706bdfab3515ff8e6 26-Oct-2011 hrs <hrs@FreeBSD.org> - Add support for a "!" character in regex matching in devd(8). It inverts
the logic (true/false) of the matching.

- Add "!usbus[0-9]+" to IFNET ATTACH notification handler in the default
devd.conf to prevent rc.d/netif from running when usbus[0-9]+ is attached.

Reviewed by: imp
dac2186be3d97d67c08deafc8cd99fa98e1fafae 21-Nov-2010 kevlo <kevlo@FreeBSD.org> Fix missing closedir()

Reviewed by: imp
09f9c897d33c41618ada06fbbcf1a9b3812dee53 19-Oct-2010 jamie <jamie@FreeBSD.org> A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.
6dc6856e334aa81abad9a95e6efe87e9d697c7aa 09-Oct-2010 imp <imp@FreeBSD.org> Allow the kernel to generate more spacy things and still have devd
cope. Skip multiple spaces in a few contexts.

PR: 96854
Submitted by: Shin'ya Kumabuchi
MFC after: 1 week
87c9a96183cedc8ff5345a48039bd1369aee8a6a 29-Jul-2010 lulf <lulf@FreeBSD.org> - Avoid calling the copy constructor when it is not necessary.
1b486040f01d7bae1a5d0a07ab7f05761ba28146 29-Jul-2010 lulf <lulf@FreeBSD.org> - Remove unused instance of string.
93e0327a90dc02fd0242bd342897292a8f275f4f 29-Jun-2010 imp <imp@FreeBSD.org> Expand system into my_system, and add the necessary tidyness that we
need. Close the pidfile. Then close all descriptors >= 3 to avoid
information leakage to children.

This solves the problem of not being able to restart devd when you
have, for example, a dhclient forked to configure your network...

MFC after: 3 days
f1216d1f0ade038907195fc114b7e630623b402c 19-Mar-2010 delphij <delphij@FreeBSD.org> Create a custom branch where I will be able to do the merge.
62577aca10f3226bd6da0d193186963e90092c73 14-Dec-2008 phk <phk@FreeBSD.org> Send all debug to stderr.
19b6af98ec71398e77874582eb84ec5310c7156f 22-Nov-2008 dfr <dfr@FreeBSD.org> Clone Kip's Xen on stable/6 tree so that I can work on improving FreeBSD/amd64
performance in Xen's HVM mode.
cf5320822f93810742e3d4a1ac8202db8482e633 19-Oct-2008 lulf <lulf@FreeBSD.org> - Import the HEAD csup code which is the basis for the cvsmode work.
46470485d3612bdbd08ede95758caaecc5521e39 17-Sep-2006 ru <ru@FreeBSD.org> Add -f option to program's usage(), fix manpage's SYNOPSIS.
98fcb88a2863826d78ca3f9c62c050181611b9c7 01-May-2006 maxim <maxim@FreeBSD.org> MFC rev. 1.32: reset lineno to 1 for each devd config file.

Approved by: re (kensmith)
4c7363828c554097c72b295689dbc88b763ac63d 14-Apr-2006 maxim <maxim@FreeBSD.org> o Yacc's lineno variable holds a total number of parsed lines.
Reset it to 1 for each devd config file so if the parser finds
a syntax error devd(8) will report a correct line number.

Submitted by: Niki Denev
MFC after: 2 weeks
f9836a378dd449473e8e5a10774d2be75247f682 30-Jan-2006 pjd <pjd@FreeBSD.org> Use pidfile(3).

OK'ed by: imp
4f9a9122c65d8ecf1b8eadef2ceaa8db0a6e0acb 08-Jan-2006 imp <imp@FreeBSD.org> It was always intended that regular expression matching be case
insensitive. Make it so.
50d87e1085295813125dd12f8214b5a0bf0aff68 19-Dec-2005 jkoshy <jkoshy@FreeBSD.org> MFC {devd.8 r1.15,1.16; devd.cc r1.29}

"Add a -f configfile option to devd(8), based on a patch submitted by
Wojciech A. Koszek."
ee7f1faad288d85d705ba10bfc0a7e63ca7b9ad5 24-Nov-2005 jkoshy <jkoshy@FreeBSD.org> Add a -f configfile option to devd(8), based on a patch submitted by
Wojciech A. Koszek.

Submitted by: Wojciech A. Koszek <dunstan@freebsd.czest.pl>
b093df020c029094eeedd740f4e7e6e8b27acdde 14-Nov-2005 bland <bland@FreeBSD.org> Reuse delete_and_clear() template helper.

Approved by: imp
3315386261d2e4bc0e7695ee6a4201473a9f3e07 25-Oct-2005 imp <imp@FreeBSD.org> MFC: 1.26 remove 'string' to avoid shadowing a variable we want to change.

Approved by: re@ (scottl)
046511ce880e689c3741ada06f9cfaaa33b7bda0 19-Oct-2005 brooks <brooks@FreeBSD.org> Make devd WARNS=4 clean and bump WARNS accordingly. This will insure
that future variable shadowing bugs don't compile.

Reviewed by: imp
Compiled on: alpha i386 sparc64
32a93330de5f1f44e51cb5b729b609573cbc7cbf 19-Oct-2005 imp <imp@FreeBSD.org> As pointed out on current@, we don't want to declare a variable in a scope
that just uses the variable and throws it away.

This should fix the subsystem keyword wrt media-type.

MFC After: 2 days
6e436f7decd1a8081c047a2b282ec380ebfb034b 06-Oct-2005 imp <imp@FreeBSD.org> MFC: if no device-name, look at subsystem

Approved by: re@ (scottl)
1edcefa858ba0a4d52c23ff6281112e869c9f24b 04-Oct-2005 imp <imp@FreeBSD.org> media-type predicate is used in contexts where device-name is undefined.
In those contexted, use subsystem instead.

# This causes dhclient to run again when I plug in my ethernet cable to
# my fxp card in my laptop.
534fb07b6c4a7b509c4dc60ff2bf5a362ca8c1f3 19-Sep-2005 marcus <marcus@FreeBSD.org> MFC:

Correct a mis-merge from HEAD, and make sure the socket permissions are set
to 0666.

Reported by: delphij via rwatson
Approved by: re (scottl)
2acfae159daadedc5c7e9ecd7a475599a88438eb 18-Jul-2005 marcus <marcus@FreeBSD.org> MFC: revs 1.23 and 1.24

* Replace fch{mod,own} with straight ch{mod,own} as the former cannot be used
on socket file descriptors
* Open permissions on /var/run/devd.pipe so that any user can read devd events
from this socket
* Enable non-blocking I/O on devd.pipe to keep clients from wedging devd.
If a write(2) on devd.pipe would block, the client in question will be
removed

Approved by: re (kensmith)
5b352640f8efaf44f5f7d243077931d85c964697 13-Jul-2005 marcus <marcus@FreeBSD.org> * Open permissions on /var/run/devd.pipe so that any user can read devd events
from this socket
* Enable non-blocking I/O on devd.pipe to keep clients from wedging devd.
If a write(2) on devd.pipe would block, the client in question will be
removed [1]

Requested by: rwatson [1]
Approved by: imp
087a48f8855ca2a0d166722151f081102d04ee4e 13-Jul-2005 marcus <marcus@FreeBSD.org> Replace fch{mod,own} with straight ch{mod,own} as the former cannot be used
on socket file descriptors.

Reviewed by: secteam (cperciva)
Approved by: imp
68644ee7c20ae551f423483008f4f216eb31d6a5 10-Jul-2005 imp <imp@FreeBSD.org> Add the ability to match the on a media type of the device in question.

Submitted by: sam
Approved by: re (scottl)
1cec98375ca06f61c922526dac7f8442bee8f2ff 16-May-2005 imp <imp@FreeBSD.org> Ignore sigpipe so we can properly detach clients to the pipe.

Submitted by: Fredrik Lindberg
6bc67c1366d316a97914f752fb0f2494d7d9f591 18-Apr-2005 imp <imp@FreeBSD.org> Fix parsing of nomatch events.
minor debug fix.
719be5d34133092608f2cb4b6a8acd6cf2c403c6 10-Feb-2005 ru <ru@FreeBSD.org> Sync program's usage() with manpage's SYNOPSIS.
3c5c35a72b44c745361adcdc5002abdd00233ca6 01-Jul-2004 imp <imp@FreeBSD.org> Create a unix domain socket and write to it all the events that come
in over the socket.
ff0432665a0dc30bec1aa09d92ecfe2ac4d25f4d 24-Oct-2003 imp <imp@FreeBSD.org> Parse the ! lines that will soon be coming from the kernel. These are
a generalized notification mechanism for subsystems wishing to report
events.

Revieded by: njl

# The kernel side seems like it might be causing panics for me, but should
# be forthcoming shortly.
b0747bd0098d542b22577c813b8a74ca7538cca6 23-Jul-2003 imp <imp@FreeBSD.org> Remove old workaround
b29651d73e8ca9350720a87c29f7d0c6c7cdf943 05-Jul-2003 imp <imp@FreeBSD.org> Drop the pid file after we call the final daemon call. w/o -n would
give the wrong pid.

Submitted by: ru and Lukas Ertl
PR: 54113
0016700b2e6b602be7a72e584a61021cdfb76152 02-May-2003 imp <imp@FreeBSD.org> sysctlbyname takes a size_t as its 5th argument, not a pointer.
However, since NULL was used, and this is C++, this error went
undetected until g++ 3.3 somehow managed to whine about it.

Reported by: obrien
9f864f962e6456a803eda5de9c2a5c451f36edc9 26-Apr-2003 imp <imp@FreeBSD.org> Create a new C++ header file called devd.hh which has all the class
definitions in it. Begin to document the classes that we use, and how
they interrelate (using comments that I can use with doxygen to
automatically generate docs with).
02bfd4df0a9a2d2c8862cfc1238029ef8f903c9b 26-Apr-2003 imp <imp@FreeBSD.org> Update to use is_id_char() in the last patch. I should have done this
before the last commit.
5e747a109fe42cfcee9cc558f84661a270807bb7 26-Apr-2003 imp <imp@FreeBSD.org> Make better use of the string type when parsing things. This switches
expand one from using a fixed buffer to using a string which
dynamically allocates these things.

Submitted by: green@ (against an earlier version of devd)
Ignored for too long by: imp
71f3be54cc12a1c9e53cbfdca4d66f54cbcf7930 25-Apr-2003 imp <imp@FreeBSD.org> Change default to be 'process all events before calling daemon.'

Also, put a small work around into devd to prevent a hang on boot this
would cause because select used to return 2 rather than 0 for no
evetnts due to a bug I fixed a few days ago in subr_bus.c. I'll
remove this workaround May 7th. You have until then to upgrade your
kernel if you want to run a new devd with an older kernel.
3a058512c4d07de369fd3c8d3dae6ae27fc8a552 21-Apr-2003 imp <imp@FreeBSD.org> Kill debug printf that crept in my last commit
037b7ed6756daa719b5a4bd2ed504620694c0342 21-Apr-2003 imp <imp@FreeBSD.org> Implement a two new flags, and change the meaning of another one.
'd': now means don't do daemon().
'D': Debug
'n': Don't wait to process all pending events before calling daemon.

In the past, devd would call daemon immediately. However, this causes
a race. If anything in the boot process depends on configuring the
devices configured by devd, maybe they would be configured in time,
maybe not. Now we don't call daemon until all pending events are
processed, unless -n is specified.

# -n is actually the default for a while due to the select(2) bug in devctl
# that I just fixed to give people a chance to upgrade.
6968b9e7d3cf2019a7ba3a73692c1c9d15989fe1 21-Apr-2003 imp <imp@FreeBSD.org> Put an anti-foot-shooting measure in place. Set hw.bus.devctl_disable
to 0 when we startup. Print a warning in this case. This allows
people that are playing with devd by hand to have something happen.
Otherwise, it appears that devd isn't working because /dev/devctl is
disabled and producing no events.

Suggested by: peter on irc a long time ago.
304876f035aec43b1760b405c77a7f294b73ca0d 21-Apr-2003 imp <imp@FreeBSD.org> o Skip white space between variables better. This makes
'a="b" c="d" at loc=1 on busN' properly set 'c' and process the rest of
the stirng. Before it would ignore everything after variable 'a'.
o Parse nomatch and other events differently. They are more different
than the code allowed for, so we weren't properly parsing nomatch
events. It appears this fixes some of the demand loading issues that
I was having with devd.

Noticed by: Gary Palmer
16d81429756a845c49df698a773dd3e84864aaff 21-Apr-2003 imp <imp@FreeBSD.org> devd.conf already has the examples in the todo list
624cac54faa2c349d902819fd9d9e8bc334ef3d4 06-Jan-2003 imp <imp@FreeBSD.org> Terminate the usage message with \n.

Submitted by: joe
150f6d2e0e167472f40a6de84730e910fa78228f 06-Jan-2003 imp <imp@FreeBSD.org> MFp4: make it work

o Expand variables correctly.
o Set variables for each event.
o rewrite event loop to execute the commands in the config file, rather
than the hard wired generic command
o better(?) debug when running -d
o sort vectors of actions so that we just have to search for the first
one to match rather than the best one that matches.
o better attempts to clear all resources used on 'restart'
o Remove now bogus comments

MFC After: 1 centiyear
4cd656bce57be3b2017fefeaf60dfb4f04833101 18-Dec-2002 imp <imp@FreeBSD.org> Latest snapshot of devd. This one adds re-matching and string
expansion.
a536ab821b9ea241e31d101e54da3e7d33e9211b 07-Dec-2002 imp <imp@FreeBSD.org> MFp4 (imp_freebsd branch): snapshot of devd work:
o improve parsing and lexing
o create data structures based on the parsed file now.
o Still need to rewrite main loop and add regex (still uses hard coded
devd-generic)
o minor man page updates.

# There should be one more commit before rc2

Approved by: re (blanket)