1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-05 23:51:28 +03:00
Commit Graph

93 Commits

Author SHA1 Message Date
Kay Sievers
6f1892dc7a udevd: inotify - do not parse rules at create but at close
We do not need to get notified about created files, only about moved
ones or files closed-after-writing.
2010-01-13 13:09:02 +01:00
Kay Sievers
f46d2e54a8 remove UDEV_RUN environment variable
It handles only RUN but not IMPORT and PROGRAM. There is no sane way
to suppress program execution. Most important programs run with IMPORT
these days. Also events can no longer suppressed with the libudev
netlink messages, so UDEV_RUN does nothing useful and is just
inconsistent.
2009-12-25 15:23:45 +01:00
Kay Sievers
3c1898863f remove remaining support for CONFIG_SYSFS_DEPRECATED 2009-12-15 16:14:14 +01:00
Kay Sievers
cdae488a3f remove "ignore_device"
There is no way to ignore an event these days. Libudev events can
not be suppressed. It only prevents RUN keys from being executed,
which results in an inconsistent behavior in current setups.
2009-11-16 15:22:17 +01:00
Kay Sievers
081be002ea udevd: create /dev/.udev/rules.d/ before watching it wit inotify
This should also address:

On Tue, Nov 3, 2009 at 16:21, Marco d'Itri <md@linux.it> wrote:
> udev_rules_new() in udev/udev-rules.c unconditionally creates the
> directory.
> This is a problem because the function is called also by e.g. udevadm
> test, and creating /dev/.udev/ when it does not exist is an unacceptable
> side effect which will break everything else that checks for its
> existence to know if udev is running.
2009-11-04 17:06:52 +01:00
Kay Sievers
26347a4c55 use CLOEXEC flags instead of fcntl() 2009-10-30 12:39:04 +01:00
Kay Sievers
19711e1933 udevd: serialize events for with the same major/minor
On Wed, Oct 7, 2009 at 21:46, Alan Jenkins <sourcejedi.lkml@googlemail.com> wrote:
> Udev would have avoided the race prior to
>
> 82c785e "udevd: remove check for dev_t, DEVPATH_OLD takes care of that"
>
> (the "check" removed here used to serialize events based on the device
> major:minor number).

On Wed, Oct 7, 2009 at 22:31, Michael Guntsche <mike@it-loops.com> wrote:
> add      /module/8250_pnp (module)
> remove /devices/platform/serial8250/tty/ttyS0 (tty)
> add      /devices/pnp0/00:05/tty/ttyS0 (tty)
2009-10-08 00:06:23 +02:00
Andrew Church
4daa146bf7 fix wrong parameter size on ioctl FIONREAD
On Wed, Sep 23, 2009 at 23:11, Matthias Schwarzott <zzam@gentoo.org> wrote:
> It is about ioctl failures on amd64:
>   http://bugs.gentoo.org/show_bug.cgi?id=286041
>
> A bad parameter type to an ioctl() call causes udev-146 to generate "error
> getting buffer for inotify" messages in syslog.  The offending code is
> roughly:
>
>    ssize_t nbytes, pos;
>    // ...
>    ioctl(fd, FIONREAD, &nbytes);
>
> where ssize_t is 64 bits on amd64, but the kernel code for FIONREAD (at least
> through gentoo-sources-2.6.31) uses type int:
>
>    p = (void __user *) arg;
>    switch (cmd) {
>    case FIONREAD:
>        // ...
>        ret = put_user(send_len, (int __user *) p);
>
> so the upper 32 bits of "nbytes" are left uninitialized, and the subsequent
> malloc(nbytes) fails unless those 32 bits happen to be zero (or the system has
> a LOT of memory).
2009-09-24 10:53:10 -07:00
Jeremy Kerr
d412a68573 util_run_program: restore signal mask before executing event RUN commands
External programs triggered by events (via RUN=) will inherit udev's
signal mask, which is set to block all but SIGALRM. For most utilities,
this is OK, but if we start daemons from RUN=, we run into trouble
(especially as SIGCHLD is blocked).

This change saves the original sigmask when udev starts, and restores it
just before we exec() the external command.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
2009-09-07 12:13:50 +02:00
Kay Sievers
cb6268f419 udevd: block for 15 seconds after error when too old kernel is detected
The compat code will go away some day and CONFIG_SYSFS_DEPRECATED
kernels fail in too many setups now to be worth to support them.
2009-08-08 22:59:41 +02:00
Kay Sievers
f7c5b04f69 re-enable failed event tracking
It did not work for the last couple of releases.

If RUN{record_failed}+="..." is given, a non-zero execution will mark
the event as failed. Recorded failed events can be re-triggered with:
  udevadm trigger --type=failed

The failed tracking _might_ be useful for things which might not be
ready to be executed at early bootup, but a bit later when the needed
dependencies are available. In many cases though, it indicates that
something is used in a way it should not.
2009-08-06 16:16:26 +02:00
Kay Sievers
820fc48f24 udevd: add timestamp to --debug output 2009-07-17 13:26:46 +02:00
Kay Sievers
c380472899 udevd: use bool 2009-07-13 03:33:15 +02:00
Kay Sievers
bc113de9a4 udevd: handle SIGCHLD before the worker event message
We may need to handle SIGCHLD before the queued worker message. The last
reference, from the SIGCHLD or the worker message will clean up the worker
context. In case we receive an unexpected SIGCHLD with an error, we let
the event fail and clean up the worker context.
2009-07-13 03:09:05 +02:00
Kay Sievers
adda4c682a udevd: make sure a worker finishes event handling before exiting
Persistent network rules write out new rules files. When rules change,
we need to kill all workers to update the in-memory copy of the rules.
We need to make sure, that a worker finshes its work for all device
messages it has accepted, before it exits after a SIGTERM from the main
process.
2009-07-11 18:21:26 +02:00
Kay Sievers
a073cfa844 udevd: detach event from worker if we kill a worker
Jul  8 09:36:41 udevd[663]: worker [5491] did not accept message, kill it
Jul  8 09:36:41 udevd[663]: worker [5491] unexpectedly returned with 0
Jul  8 09:36:41 udevd[663]: worker [5551] unexpectedly returned with 0
Jul  8 09:36:41 kernel: [  156.832086] <6>udevd[663]: segfault at 4 ip 00959fbc sp bfbe7b78 error 6 in udevd[94f000+1c000]

https://bugs.launchpad.net/ubuntu/+source/udev/+bug/396957
2009-07-08 14:13:20 +02:00
Kay Sievers
6133f3432f cleanup ./configure installation directory options 2009-06-17 02:25:07 +02:00
Kay Sievers
9060b066d9 move syslog wrapper to libudev 2009-06-09 22:47:48 +02:00
Kay Sievers
12bc9c54f2 udevd: log info for created/killed workers 2009-06-09 18:31:14 +02:00
Kay Sievers
45798927f8 udevd: print error if worker dies unexpectedly 2009-06-08 17:16:48 +02:00
Kay Sievers
9290143d2d udevd: close netlink socket in worker and set cloexec 2009-06-04 02:49:42 +02:00
Kay Sievers
1e03b754ae udevd: convert to event worker processes
Event processes now get re-used after they handled an event. This reduces
pressure on the CPU significantly because cloned event processes no longer
cause page faults in the main daemon. After the events have settled, the
no longer needed worker processes get killed.
2009-06-04 01:44:04 +02:00
Kay Sievers
82c785e5dc udevd: remove check for dev_t, DEVPATH_OLD takes care of that 2009-05-29 18:54:03 +02:00
Alan Jenkins
f503f6b22f udevd: implement a more efficient queue file format
Directory lookups show up in profiling. The queue files are responsible
for a large proportion of file-related system calls in udev coldplug.

Instead of creating a file for each event, append their details to a
log file.  The file is periodically rebuilt (garbage-collected) to
prevent it from growing indefinitely.

This single queue file replaces both the queue directory and the
uevent_seqnum file. On desktop systems the file tends not to grow
beyond one page. So it should also save a small amount of memory in
tmpfs.

Tests on a running EeePC indicate average savings of 5% *udevd* cpu time
as measured by oprofile. __link_path_walk is reduced from 1.5% to
1.3%. It is not completely clear where the rest of the gains come from.

In tests running ~400 events, the queue file is rebuilt about 5 times.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2009-05-21 22:22:37 +02:00
Alan Jenkins
f9b3f88f71 udevd: remove tiny bit of dead code 2009-05-21 18:31:43 +02:00
Kay Sievers
ce449f89d6 keep the ifdef'd udevd testing/profiling hack 2009-05-21 01:20:18 +02:00
Kay Sievers
e6c1a2bde7 use openat(), unlinkat(), fstatat() 2009-05-20 18:58:52 +02:00
Kay Sievers
065db05221 use more efficient string copying 2009-05-20 17:57:52 +02:00
Kay Sievers
619b97ff2b remove asmlinkage 2009-05-05 02:39:16 +02:00
Kay Sievers
e3196993f1 remove all PHYSDEVPATH handling and warning about 2009-05-04 22:08:05 +02:00
Kay Sievers
a00bdfa16b udevd: revert initial device node creation 2009-05-02 05:23:02 +02:00
Kay Sievers
540f46698d udevd: at startup create /dev/null, /dev/console, /dev/kmsg 2009-04-19 03:25:04 +02:00
Kay Sievers
b44b7f8841 udevd: log error for too old kernels or CONFIG_SYSFS_DEPRECATED 2009-04-16 22:34:26 +02:00
Kay Sievers
f2b937440c "UDEV_MONITOR_KERNEL/UDEV" -> "kernel/udev" 2009-03-29 20:08:52 +02:00
Kay Sievers
116254097a send monitor events back to netlink socket
Instead of of our own private monitor socket, we send the
processed event back to our netlink socket, to the multicast
group 2 -- so any number of users can listen to udev events,
just like they can listen to kernel emitted events on group 1.
2009-03-29 04:24:39 +02:00
Scott James Remnant
bb38678e3c udevadm: settle - synchronise with the udev daemon
There's still a slight race condition when using udevadm settle, if the
udev daemon has a pending inotify event but hasn't yet generated the
"change" uevent for it, the kernel and udev sequence numbers will match
and settle will exit.

Now udevadm settle will send a control message to udevd, which will
respond by sending SIGUSR1 back to the waiting udevadm settle once it
has completed the main loop iteration in which it received the control
message.

If there were no pending inotify events, this will simply wake up the
udev daemon and allow settle to continue.  If there are pending inotify
events, they are handled first in the main loop so when settle is
continued they will have been turned into uevents and the kernel
sequence number will have been incremented.

Since the inotify event is pending for udevd when the close() system
call returns (it's queued as part of the kernel handling for that system
call), and since the kernel sequence number is incremented by writing to
the uevent file (as udevd does), this solves the race.

When the settle continues, if there were pending inotify events that
udevd had not read, they are now pending uevents which settle can wait
for.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-03-12 10:02:37 +00:00
Kay Sievers
3d3a0a709a use the event udev_device to disable the watch on "remove" 2009-02-24 15:11:17 +01:00
Scott James Remnant
80be8c48c5 Look at more inotify events in the buffer than just the first. 2009-02-23 18:33:49 +00:00
Scott James Remnant
b8e96d67a2 lookup the old watch handle; reload only if has a path 2009-02-23 17:59:01 +00:00
Scott James Remnant
9ce462721a Put a log message in a more sensible place. 2009-02-23 17:46:00 +00:00
Scott James Remnant
047f88bca3 Use the udevdb to speed up watch clearing.
Also return a udev_device when looking up by handle as well, so
everything works the same way.
2009-02-23 17:43:53 +00:00
Scott James Remnant
03e0170db3 Cleanup a little.
Move some of the checks into udev_watch_begin() and udev_watch_clear()
so we don't have to repeat them all the time.
2009-02-23 17:21:24 +00:00
Scott James Remnant
521b3a9211 Clear existing inotify watch before processing.
Likewise when re-processing an event, we want to drop the existing
inotify watch first to avoid side-effects.
2009-02-23 17:19:05 +00:00
Scott James Remnant
5ae82640c5 Don't add inotify watch until RUN rules processed.
The programs we RUN can open device nodes, and thus we can end up
chasing our own tail.
2009-02-23 17:17:20 +00:00
Kay Sievers
4aca304e48 use global "reload_config" flag 2009-02-11 21:56:35 +01:00
Scott James Remnant
bd284db142 udevd: optionally watch device nodes with inotify
This allows you to re-process the rules if the content of the device
has been changed, most useful for block subsystem to cause vol_id to
be run again.
2009-02-11 17:38:56 +00:00
Kay Sievers
5db88229d1 udevd: add back SA_RESTART
<Keybuk> poll, select, ppoll, pselect, epoll, etc. are *explicitly* NOT restarted in case of signal
<kay> ok
2009-01-21 18:55:59 +01:00
Kay Sievers
6469c77216 split up long line 2009-01-21 15:11:38 +01:00
Kay Sievers
4b0faa2aa0 Merge commit '9032f119f07ad3b5116b3d4858816d851d4127de' 2009-01-21 14:43:22 +01:00
Kay Sievers
2c7b88c4a5 Merge commit '5f03ed8a56d308af72db8a48ab66ed68667af2c6'
Conflicts:
	udev/udevd.c
2009-01-21 14:42:30 +01:00