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

444 Commits

Author SHA1 Message Date
Kay Sievers
ff5d99e0b0 udevadm: info -revert "accept --query without argument"
Getopt is too dumb, the optional argument breaks "udevadm -q symlink".
2009-06-10 15:55:24 +02:00
Kay Sievers
98631e1c21 libudev: rename private files to *-private.c 2009-06-09 23:12:12 +02:00
Kay Sievers
44b49d3736 move common stuff from udev/ to private parts of libudev/ 2009-06-09 23:05:25 +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
48a9b173e8 libudev: move to top-level directory 2009-06-08 21:36:06 +02:00
Kay Sievers
15a45c89e5 libudev: add comments to libudev.h 2009-06-08 19:31:07 +02:00
Kay Sievers
45798927f8 udevd: print error if worker dies unexpectedly 2009-06-08 17:16:48 +02:00
Kay Sievers
b0d5e0df3e udevadm: monitor --environment -> --property 2009-06-07 03:07:33 +02:00
Kay Sievers
5654503680 udevadm: control - --env -> --property 2009-06-07 02:53:35 +02:00
Kay Sievers
0254b2118f udevadm: info - accept --query without a value and print properties 2009-06-07 02:39:54 +02:00
Kay Sievers
80381823bc udevadm: trigger - add --property-match=<key>:<value> 2009-06-07 02:07:54 +02:00
Kay Sievers
701a57da31 libudev: enumerate - allow multiple keys with the same name 2009-06-07 01:51:38 +02:00
Kay Sievers
93ee84ce07 fix signed/unsigned warning 2009-06-06 21:19:56 +02:00
Kay Sievers
4950b6e6a8 cleanup $attr{} substitution 2009-06-06 04:54:41 +02:00
Kay Sievers
32028733ee allow format substitution in path of ATTR{<path>}=="<value>" 2009-06-06 04:52:52 +02:00
Kay Sievers
a25d547dd4 udevd: use enum instead of char in struct declaration 2009-06-05 23:27:11 +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
b61f48a0e8 str[sp]cpyl: add __attribute__ ((sentinel)) 2009-06-01 21:10:29 +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
Kay Sievers
97f48a8c67 udevadm: settle - add --exit-if-exists=<file> 2009-05-29 14:05:39 +02:00
Kay Sievers
dc383337b3 udevadm: control - add comment to man page about --reload-rules 2009-05-28 19:21:35 +02:00
Alan Jenkins
542aeeb48a udevd: queue-export - fix crash
The math in skip_to() was the wrong way round and allocated a
variable size array on the stack with a massively negative size.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2009-05-28 19:19:42 +02:00
Alan Jenkins
a29b30b411 udev-selinux.c: remove libudev header
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2009-05-28 12:50:10 +02:00
Kay Sievers
9f894a3391 udevadm: settle - make --timeout=0 working 2009-05-21 23:49:53 +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
81469dae34 fix location of database files 2009-05-21 01:44:45 +02:00
Kay Sievers
ce449f89d6 keep the ifdef'd udevd testing/profiling hack 2009-05-21 01:20:18 +02:00
Kay Sievers
bd75fddbcb require key names in uppercase
Drop pretty expensive case-insensitive matching, and key names in
mixed or lowercase are not supported anyway.
2009-05-20 23:45:32 +02:00
Kay Sievers
fb04513470 remove unused GL_FORMAT from rules parser 2009-05-20 23:12:22 +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
Alan Jenkins
f58a9099bb udevadm: settle - fix timeout
The timeout wasn't working when settle was run as root:
  # udevadm control --stop-exec-queue
  # udevadm trigger
  # udevadm settle --timeout=1
  ... (hangs)

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2009-05-20 16:12:22 +02:00
Kay Sievers
a0ee5a05bb remove format char string truncation syntax 2009-05-19 12:56:17 +02:00
Scott James Remnant
055e40edc6 OWNER/GROUP: fix if logic
The introduction of the --resolve-names=early/never code introduced a
bug to the OWNER/GROUP lookup.  Previously if the name had contained $,
lookup would have been performed later; after the patch, the key ended
up being ignored!
2009-05-14 12:42:44 +01:00
Kay Sievers
0c37798916 fix possible endless loop for GOTO to non-existent LABEL
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=526365
2009-05-13 18:01:32 +02:00
Kay Sievers
4a74214a58 add "static" back to the inline functions
<Keybuk> kay: udev git head ftbfs
<Keybuk> udev-watch.o: In function `udev_selinux_init':
<Keybuk> /../udev/udev.h:130: multiple definition of `udev_selinux_init'
2009-05-07 13:24:40 +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
cb14f4543a handle devtmpfs nodes
UDev follows the kernel given name, and re-uses the kernel created
device node. If the kernel and spcecified udev rules disagree, the
udev specified node node is created and the kernel-created on is
deleted.
2009-05-04 04:52:31 +02:00
Kay Sievers
a00bdfa16b udevd: revert initial device node creation 2009-05-02 05:23:02 +02:00
Kay Sievers
8e4bd22558 accept DEVNAME from the kernel as a hint for the node name 2009-04-28 15:59:45 +02:00
Kay Sievers
37ed4f5619 drop "extern" keyword from non-static function 2009-04-26 13:59:39 +02:00
Kay Sievers
aa1aa46f95 update NEWS 2009-04-24 02:27:44 +02:00
Kay Sievers
19d7e87cc0 libudev: monitor - export filter_update() 2009-04-23 18:05:10 +02:00
Kay Sievers
34f55e1dc7 libudev: queue - clarify comments 2009-04-23 15:16:26 +02:00
Kay Sievers
8c3ae78546 libudev: queue - fix get_seqnum_is_finished()
On Thu, Apr 23, 2009 at 11:39, Alan Jenkins <alan-jenkins@tuffmail.co.uk> wrote:
> I'm puzzled by this function:
>
>        /* if we have not seen this seqnum, check if it is/was already queued */
>        if (seqnum < udev_queue->last_seen_udev_seqnum) {
>                udev_queue_get_udev_seqnum(udev_queue);
>                if (seqnum < udev_queue->last_seen_udev_seqnum)
>
> Shouldn't the test be (seqnum > udev_queue->last_seen_udev_seqnum) ?
2009-04-23 13:23:45 +02:00
Kay Sievers
08a7a795f6 libudev: monitor - add udev_monitor_filter_remove 2009-04-23 04:07:51 +02:00
Kay Sievers
bb7045a0a3 udevadm: monitor - add <subsytem>:<devtype> support 2009-04-23 04:07:15 +02:00
Kay Sievers
e93c38c3a2 libudev: monitor - do not filter messages with wrong magic 2009-04-23 03:33:58 +02:00
Kay Sievers
dacea9ff6b libudev: monitor - switch to filter_add_match_subsystem_devtype() 2009-04-23 03:24:38 +02:00
Kay Sievers
c7dff03e05 libudev: monitor - use simpler hash 2009-04-22 18:38:16 +02:00
Kay Sievers
a9550eb11f udevadm monitor - add --subsystem-match= 2009-04-22 05:00:15 +02:00
Kay Sievers
4277453fd2 update TODO 2009-04-22 04:32:25 +02:00
Kay Sievers
3111a33e95 udevadm: monitor - print error if we can not bind to socket 2009-04-22 04:11:18 +02:00
Kay Sievers
e14bdd88e9 libudev: monitor - add client socket filter for subsystem value
Messages send back by the udev daemon to the netlink socket are
multiplexed by the kernel and delivered to multiple clients. The
clients can upload a socket filter to let the kernel drop messages
not belonging to a certain subsystem. This prevent needless wakeups
and message processing for users who are only interested in a
subset of available events.

Recent kernels allow untrusted users to listen to the netlink
messages.

The messages send by the udev daemon are versioned, to prevent any
custom software reading them without libudev. The message wire format
may change with any udev version update.
2009-04-22 03:50:11 +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
f1986e09fc test-libudev: update monitor source 2009-04-18 13:23:10 +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
ff109b8ded libudev: monitor - clarify socket handling documentation 2009-04-16 01:49:16 +02:00
Kay Sievers
3e5bafc98a libudev: path_encode - always return 0 if encoded string does not fit into size 2009-04-15 21:47:04 +02:00
Scott James Remnant
e86a923d50 libudev: monitor - ignore messages from unusual sources
For added protection, ignore any unicast message received on the
netlink socket or any multicast message on the kernel group not
received from the kernel.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-04-08 16:16:14 -07:00
Kay Sievers
e2b362d9f2 libudev: monitor - unify socket message handling 2009-04-08 07:46:54 -07:00
Kay Sievers
662c311080 path_encode: fix max length calculation
Sebastian Krahmer wrote:
> it should reserve 4 times not 3 times len :)
2009-04-08 06:06:01 -07:00
Alan Jenkins
4b09a2fc43 avoid leaking netlink socket fd to external programs
The netlink socket is now used by udev event processes. We should take
care not to pass it to the programs they execute. This is the same way
the inotify fd was handled.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2009-04-06 07:23:35 -07:00
Kay Sievers
52761bb0a9 IMPORT: 2048 -> 4096 bytes buffer 2009-03-30 20:09:08 +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
Kay Sievers
4061ab9f4b libudev: GPL -> LGPL 2009-03-26 19:29:36 +01:00
Kay Sievers
498c2750bf udevadm: monitor - clarify printed header 2009-03-18 18:47:23 +01:00
Kay Sievers
f454f6708a udevadm: test - handling trailing '/' in devpath
On Wed, Mar 18, 2009 at 16:00, Matthias Schwarzott <zzam@gentoo.org> wrote:
found out how the error occurs:
It is a difference between
A. udevadm test /sys/class/mem/null/
and
B. udevadm test /sys/class/mem/null

Case A was the case that showed the error behaviour. It seems udevadm is
confused by the trailing slash. This behaviour seems to be there since ages.
2009-03-18 18:42:16 +01:00
Robby Workman
1d59ba4077 udevadm: trigger - add "--action" to --help 2009-03-17 10:31:32 +01: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
c2c24d4d3c udevadm: settle - use timeout signal, instead of loop counter 2009-03-11 15:06:14 +01:00
Kay Sievers
89d080c3ae libudev: ctrl - return error after sending ctrl message 2009-03-11 13:32:39 +01:00
Kay Sievers
f1e7e36046 udevadm: add text for new options to command and man page 2009-03-07 02:32:40 +01:00
Kay Sievers
45bcd16ca5 udevd: switch watch symlinks to devpath
Some broken tools get confused following links to /sys, switch
to link targets carrying the devpath instead of the syspath, like
the queue links.
2009-03-05 00:35:58 +01:00
Kay Sievers
98d3d51715 udevadm: settle - add --seq-start= --seq-end=
It might be useful in some cases not to wait for "all" events.

  $ read START < /sys/kernel/uevent_seqnum
  $ (do something which may create uevents)
  $ udevadm settle --seq-start=$START
2009-03-04 23:48:53 +01:00
Kay Sievers
a5d8cffad9 libudev: queue - use lstat() to check existence of symlink 2009-03-04 23:32:16 +01:00
Michael Prokop
2236ddae2d fix compile error in debug mode
When building with './configure --enable-debug && make' it fails with:
  udev-rules.c: In function ‘dump_token’:
  udev-rules.c:366: error: ‘struct <anonymous>’ has no member named ‘i’

Signed-off-by: Michael Prokop <mika@grml.org>
2009-03-03 17:27:00 +01:00
Kay Sievers
b38a5801f9 udevadm: info - export all devices with --export-db 2009-02-26 22:59:40 +01:00
Kay Sievers
46f194cbde add "nowatch" to disable a default installed watch with a later rule 2009-02-25 11:18:15 +01:00
Kay Sievers
3d3a0a709a use the event udev_device to disable the watch on "remove" 2009-02-24 15:11:17 +01:00
Kay Sievers
d5d04d4f9f remove static local variable 2009-02-24 12:58:48 +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
c08337da5c Output watch handle in udevadm info. 2009-02-23 17:48:18 +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
25bdd197ec Store watch handle in db. 2009-02-23 17:34:07 +00:00
Scott James Remnant
d7ce7539d3 Allow watch handle to be stored in the udevdb. 2009-02-23 17:31:26 +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
64746532e8 rules: add "watch" option to dm and md rules 2009-02-13 16:02:36 +01: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
10b2d011e7 fix NAME= and OPTION+="string_escape=..." logic
Scott discovered this silly bug.
2009-02-08 16:02:15 +01:00