Commit Graph

201 Commits

Author SHA1 Message Date
pluknet
d9f661c57a Separate items in the list of System values with .Pp to ease readability. 2013-02-21 20:45:19 +00:00
sjg
0ee5295509 Updated dependencies 2013-02-16 01:23:54 +00:00
obrien
3028e3f8ab Sync with HEAD. 2013-02-08 16:10:16 +00:00
zeising
e05b8f83c1 Bump .Dd for the change in r246121.
Approved by:	joel (mentor)
2013-02-05 14:29:37 +00:00
ian
85fcf6286d 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)
2013-01-30 23:37:35 +00:00
ian
3e5ced1b98 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)
2013-01-30 15:21:18 +00:00
eadler
d63ec4c24b Prefer the use of initalizer lists to ctor assignment.
Approved by:	cperciva
MFC after:	2 weeks
2012-12-06 01:25:21 +00:00
eadler
76f827328b Avoid the creation of a temporary object by using the prefix operator
for non-primitive types.

Approved by:	cperciva
MFC after:	2 weeks
2012-12-06 01:25:17 +00:00
eadler
be40a13e59 Constify where possible
Approved by:	cperciva
MFC after:	2 weeks
2012-12-06 01:25:14 +00:00
dim
ab2b1f57e9 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
2012-12-05 20:50:40 +00:00
sjg
9f7bd28e77 Updated/new Makefile.depend 2012-11-08 21:24:17 +00:00
sjg
778e93c51a Sync from head 2012-11-04 02:52:03 +00:00
avg
04a3ee8c86 document acpi_cpu devd notification about _CST change
Based on prodding and a submission by Lars Engels <lars.engels@0x20.net>.

MFC after:	5 days
2012-10-20 09:40:34 +00:00
pjd
66da4b41b3 Use O_CLOEXEC for open instead of separate fcntl(2) call. 2012-09-22 12:42:51 +00:00
marcel
9dd41e3647 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
dim
2c17ed141e Make devd build with libc++.
MFC after:	3 days
2012-06-01 06:56:35 +00:00
bapt
310ab6d7ff Fix world after byacc import:
- old yacc(1) use to magicially append stdlib.h, while new one don't
- new yacc(1) do declare yyparse by itself, fix redundant declaration of
  'yyparse'

Approved by:	des (mentor)
2012-05-22 16:33:10 +00:00
glebius
6700bd7ced Fix build. 2012-01-06 15:01:05 +00:00
maxim
473a67378d o Sort .Xrs. 2011-12-19 05:09:08 +00:00
dim
32859c5990 In sbin/devd/devd.h, 'event_proc' and 'eps' are declared as structs. In
devd.hh, there are redeclared as classes.  Fix the inconsistency.

MFC after:	1 week
2011-12-17 01:54:51 +00:00
glebius
8e22f12db2 Xref re_format(7) in devd.conf(5), not in devd(8).
Pointy hat to:	glebius
2011-12-16 10:21:01 +00:00
glebius
014ced0760 Xref re_format(7). 2011-12-16 10:14:41 +00:00
hrs
fb5f47d254 - 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
2011-10-26 02:11:28 +00:00
bms
f92bf45e3f Typo. For USB devices, 'serial' should be 'sernum'.
See sys/dev/usb/usb_device.c for what devctl_notify() gets.
2011-05-10 02:34:11 +00:00
brucec
316b5514e8 Don't generate input() since it's not used. 2010-11-22 12:33:48 +00:00
kevlo
dac2186be3 Fix missing closedir()
Reviewed by:	imp
2010-11-21 04:02:37 +00:00
imp
6dc6856e33 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
2010-10-09 07:29:13 +00:00
uqs
8ae3afcfad mdoc: drop redundant .Pp and .LP calls
They have no effect when coming in pairs, or before .Bl/.Bd
2010-10-08 12:40:16 +00:00
joel
dd1fff9bcb Fix typos, spelling, formatting and mdoc mistakes found by Nobuyuki while
translating these manual pages.  Minor corrections by me.

Submitted by:	Nobuyuki Koganemaru <n-kogane@syd.odn.ne.jp>
2010-08-16 15:18:30 +00:00
lulf
87c9a96183 - Avoid calling the copy constructor when it is not necessary. 2010-07-29 16:06:40 +00:00
lulf
1b486040f0 - Remove unused instance of string. 2010-07-29 16:01:10 +00:00
imp
93e0327a90 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
2010-06-29 03:52:12 +00:00
thompsa
6fc09494d1 Document the new USB notification types. 2010-04-22 20:46:39 +00:00
uqs
764da0e641 Bump WARNS where possible.
Checked by:	make universe
Approved by:	ed (co-mentor)
2010-02-15 14:07:40 +00:00
maxim
5dd0791944 o Spell. Sort .Xrs. 2009-03-08 18:02:30 +00:00
kib
ecebbcfa4c Document several notifications, among them are DEVFS, update to ifneti,
coretemp and kern.

The asmc(4) and zfs(5) are still not documented.

Based on the patch by Roland Smith <rsmith xs4all nl>.
MFC after:	1 week
2009-03-08 14:28:40 +00:00
phk
62577aca10 Send all debug to stderr. 2008-12-14 11:48:51 +00:00
phk
329b1107fb Clarify that configuration files must be named '*.conf' 2008-12-14 11:47:39 +00:00
imp
5541a160b6 No need to be gratuitously style(9) non-compliant here, even though
C++ lets me get away with it.
2008-03-21 20:38:28 +00:00
imp
71f57a2fb1 Minor initialization change to not trigger bogus gcc warning about
passing literal strings to the constructors of string.
2007-12-21 01:00:04 +00:00
jb
bdea99cbc2 Reduce the WARNS level across the board due to a warning that occurs
on at least arm and sparc64. i386/pc98, ia64 and amd64 are all OK.
2007-11-19 00:19:01 +00:00
ru
18498b3d43 Fix the description of "media-type". 2006-10-24 20:20:41 +00:00
ru
c33f5fb2d6 Revise the markup, sort sections, fix some grammar bugs.
Not fixed: the description of media-type is completely bogus.
2006-10-21 17:15:11 +00:00
jmg
3043d9a100 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....

PR:		85097
Submitted by:	Fredrik Lindberg
MFC after:	1 week
2006-10-07 21:15:40 +00:00
ru
46470485d3 Add -f option to program's usage(), fix manpage's SYNOPSIS. 2006-09-17 22:49:26 +00:00
maxim
4c7363828c 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
2006-04-14 07:20:42 +00:00
pjd
f9836a378d Use pidfile(3).
OK'ed by:	imp
2006-01-30 22:50:13 +00:00
imp
4f9a9122c6 It was always intended that regular expression matching be case
insensitive.  Make it so.
2006-01-08 05:18:36 +00:00
jkoshy
4f006a501c Rev 1.15 should have incremented the date on this manual page. 2005-12-19 02:55:44 +00:00
jkoshy
ee7f1faad2 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>
2005-11-24 14:39:41 +00:00
bland
b093df020c Reuse delete_and_clear() template helper.
Approved by:	imp
2005-11-14 02:01:10 +00:00
brooks
046511ce88 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
2005-10-19 21:21:22 +00:00
imp
32a93330de 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
2005-10-19 18:10:34 +00:00
imp
1edcefa858 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.
2005-10-04 22:22:51 +00:00
marcus
5b352640f8 * 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
2005-07-13 17:28:11 +00:00
marcus
087a48f885 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
2005-07-13 17:10:47 +00:00
imp
68644ee7c2 Add the ability to match the on a media type of the device in question.
Submitted by: sam
Approved by: re (scottl)
2005-07-10 03:37:15 +00:00
imp
1cec98375c Ignore sigpipe so we can properly detach clients to the pipe.
Submitted by: Fredrik Lindberg
2005-05-16 20:51:46 +00:00
imp
6bc67c1366 Fix parsing of nomatch events.
minor debug fix.
2005-04-18 02:54:07 +00:00
ru
719be5d341 Sync program's usage() with manpage's SYNOPSIS. 2005-02-10 09:19:34 +00:00
ru
c56f1c1871 Scheduled mdoc(7) sweep. 2005-01-10 16:17:34 +00:00
ru
c1a820195c NOSHARED -> NO_SHARED 2004-12-21 09:59:45 +00:00
ceri
57bed962f3 Clarify that devd will only parse files whose names end in .conf.
Prompted by

PR:		docs/73668
Submitted by:	Dan Pelleg
MFC After:	3 days
2004-11-28 17:44:22 +00:00
ru
9f45c1d92e mdoc(7) fixes. 2004-07-07 19:57:16 +00:00
imp
3c5c35a72b Create a unix domain socket and write to it all the events that come
in over the socket.
2004-07-01 07:24:18 +00:00
imp
ff0432665a 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.
2003-10-24 22:02:29 +00:00
rse
f948c62a16 fix typo: s/Instaed/Instead/ 2003-09-26 12:24:16 +00:00
gordon
d2464b0086 At imp's request, force devd to be statically compiled. This avoids the
need for libstdc++ in /lib, and the generated binary is actually smaller
statically linked than dynamically + sizeof(libstdc++). Additionally,
devd doesn't use get*by*() which is one of the main motivations for
dynamically linking your root partition anyway.
2003-08-17 08:40:49 +00:00
imp
3c9c390054 Simplistic C comment re is wrong, use more correct one 2003-07-23 23:50:25 +00:00
imp
b0747bd009 Remove old workaround 2003-07-23 23:50:00 +00:00
imp
b29651d73e 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
2003-07-05 00:43:50 +00:00
ru
f05c138670 mdoc(7) fixes: Expand contraction. 2003-05-17 22:21:27 +00:00
imp
e01c3427e3 Allow zero or more actions in an action list, rather than requiring
one or more actions in the list.  This makes constructs like:

attach 10 {
//	echo "Driver $device_name attached"
};

to be accepted by the parser.  It will be treated as if the user had
entered:

// attach 10 {
//	echo "Driver $device_name attached"
// };

(eg totally ignored).

Approved by: re@ (rwatson)
2003-05-15 02:23:32 +00:00
imp
0016700b2e 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
2003-05-02 17:38:08 +00:00
imp
9f864f962e 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).
2003-04-26 20:59:04 +00:00
imp
02bfd4df0a Update to use is_id_char() in the last patch. I should have done this
before the last commit.
2003-04-26 20:25:40 +00:00
imp
5e747a109f 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
2003-04-26 19:44:45 +00:00
imp
71f3be54cc 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.
2003-04-25 02:13:42 +00:00
imp
3a058512c4 Kill debug printf that crept in my last commit 2003-04-21 17:25:39 +00:00
imp
037b7ed675 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.
2003-04-21 06:26:08 +00:00
imp
6968b9e7d3 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.
2003-04-21 04:30:12 +00:00
imp
304876f035 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
2003-04-21 04:00:01 +00:00
imp
16d8142975 devd.conf already has the examples in the todo list 2003-04-21 03:29:53 +00:00
ru
59ea65502d This can't obviously be cleaner than system headers. 2003-04-01 11:11:38 +00:00
ru
74cf5d6de7 mdoc(7) police: Revision. 2003-03-03 11:51:30 +00:00
imp
24dd801cb7 The bugs section hasn't been true since before 5.0-R 2003-02-14 19:49:19 +00:00
imp
ad3fe0309b devd bugs section is now OBE 2003-02-14 16:21:50 +00:00
imp
648c140205 These are OBE. devd.conf now lives in /etc. 2003-01-09 04:11:19 +00:00
imp
624cac54fa Terminate the usage message with \n.
Submitted by: joe
2003-01-06 16:46:25 +00:00
imp
150f6d2e0e 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
2003-01-06 08:09:41 +00:00
imp
292b14851c devd not devdd
submitted by: joe
2003-01-06 08:03:00 +00:00
schweikh
fec6546e12 english(4) police. 2002-12-27 12:15:40 +00:00
imp
4cd656bce5 Latest snapshot of devd. This one adds re-matching and string
expansion.
2002-12-18 07:08:01 +00:00
imp
a536ab821b 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)
2002-12-07 08:04:36 +00:00
jhb
51e467ab6a Fixup FILES section to use proper width and to use a cross-reference to
devd(8).
2002-11-18 21:07:48 +00:00
jhb
4b330a9d15 Remove leading ^ from example of match line in vendor-supplied rules since
the ^ is implicit at the beginning of the expressions.
2002-11-18 21:02:29 +00:00
imp
71d25044f6 Add BUGS section and note departure of actual implementation from what
is documented so the pioneers will know why it works the way it does.
2002-11-18 07:16:47 +00:00
tjr
53f32a094d Install devd.conf(5). 2002-11-14 10:00:01 +00:00
jhb
cea56bb805 Try to reword things a bit more to make it clearer.
Reviewed by:	imp
2002-11-13 20:27:46 +00:00
jhb
46c1974156 - Fix some minor grammar and spelling nits.
- Massage the wording in a few places.
- Put .Nm on lines by itself so it renders correctly.

Reviewed by:	imp
2002-11-13 19:31:04 +00:00
imp
825b39f9a0 devd. A daemon that hooks into the kernel's /dev/devctl to produce
arbitrary commands when devices come and go in the device tree (which is
different than the /dev directory).

This is an initial version.  Much of the planned power isn't here.
Instead of doing the full matching, we always run /etc/devd-generic.
/etc/devd.generic will go away at some point, I think.

I'm committing it in this early state so I can start getting feedback
from early adapters.

Approved by: re
2002-10-20 22:15:17 +00:00