summaryrefslogtreecommitdiff
path: root/src/udev/udevd.c
AgeCommit message (Collapse)Author
2016-05-31udevd: remove unnecessary cgroups handlingMurray Calavera
Signed-off-by: Murray Calavera <murray.calavera@gmail.com> Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-11-22src/udev/udevd.c: add eudev startup message for kmsgRichard Narron
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-09-11Revert "udevd: warn if we receive SIGCHLD from untracked worker"eudev/v3.1.3Anthony G. Basile
This reverts commit 75e930ed64b62ac7e684cbe3493963371904d55b. This fixes issue #121. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-07-20udevd: don't unref worker objects on SIGSTOP/SIGCONTTom Gundersen
We should not be receiving these anyway, but let's be correct. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-07-20udevd: warn if we receive SIGCHLD from untracked workerTom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-06-18Rename mkdir_p -> udev_mkdir_p to avoid symbol collisions.Anthony G. Basile
While usptream doesn't support a static libudev.a, we will try to do so. However, mkdir_p() is used in lvm2 and util-linux, so to avoid the collision, we rename it to udev_mkdir_p(). See: https://bugs.gentoo.org/show_bug.cgi?id=520450 Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-06-18Revert "udev: don't close std{in,out,err}"Anthony G. Basile
This reverts commit b2399d9b7222abe7db8ab4bc16e0efe3ccae4c42. This solves issue #108. While upstream also reverted this commit, they did so using functions in terminal-util.c. We could import that file and those functions but for such a small commit, its not worth it. We may do so at some future time if there are further gains. See: https://github.com/systemd/systemd/commit/40e749b59ba49fb97c1f45859debe2a82bc9c9ef Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-27nspawn: finish user namespace supportLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-27udevd: main - use _exit() when daemonizingTom Gundersen
Makes it a bit clearer what is going on, rather than jumping to the end of main(). No functional change. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-27udevd: on_worker - distinguish between EINTR and EAGAINTom Gundersen
EAGAIN means there are no more messages to read, so give up. EINTR means we got interrupted reading a message, so try again. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-27udevd: worker - use loop_write() rather than send()Tom Gundersen
When notifying the main daemon about event completion, make sure the message is sent successfully, and not interrupted. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: remove stale commentTom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: explicitly update queue file before answering to pingTom Gundersen
This avoids updating the flag files twice for every loop, and also removes another dependency in the main-loop, so we are freer to reshufle it as we want. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: make udev_ctrl_connection globalTom Gundersen
This allows us to simplify the ctrl_msg handler. Eventually all this global state should move to a Manager object or so. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: remove unused functionThomas Hindoe Paaboel Andersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: don't explicitly count the number of workersTom Gundersen
Simply query the size of the hashmap keeping all the worker contexts instead. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: keep workers in a hashmap rather than a listTom Gundersen
This makes the code somewhat more readable. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: worker - drop reference countingTom Gundersen
Make the worker context have the same life-span as the worker process. It is created on fork() and free'd on SIGCHLD. The change means that we can get worker_returned() for a worker context that is no longer around, this is not a problem and we can just drop the message. The only use for worker_returned() is to know to reschedule events to workers that are still around, so if the worker has already exited it is not important to keep track of. We still print a debug statement in this case to be on the safe side. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udev: fix weird coding-styleDavid Herrmann
Eeeew! Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: worker - allow passing NULL to worker_unref()Tom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: worker - use _exit() rather than exit()Tom Gundersen
Follow the coding style and avoid the exit handlers. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: modernize error handlingTom Gundersen
We never return magic exit codes, but just EXIT_FAILUER or EXIT_SUCCESS. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: use kernel cmdline parserTom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: worker - move some fields from the worker to the eventTom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: worker - introduce worker_attach_event()Tom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: worker - make refcounting clearerTom Gundersen
Take and drop explicit references where it makes sense. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: worker - only allocate the worker struct in the main processTom Gundersen
This is not used in the worker, so avoid having to free it there. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: rename worker_new() to worker_spawn()Tom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-26udevd: don't track worker exitcodeTom Gundersen
We used to use this to track failed events so they could be retriggered, but that is no longer done, so the code can be dropped. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-03udevd: worker - log if worker result cannot be sentTom Gundersen
If the main daemon is not notified about a worker finishing an event the refcounting of the worker struct will be wrong, and we will lose track of the number of children we have to wait for. This should not happen, but if it does we better complain loudly about it. Worst case udev will wait for 30 seconsd at shutdown waiting for nonexistent workers. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-03udevd: worker - warn if unknown worker returnsTom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-03src/udev/udevd.c: remove initializer for struct for gcc-4.5.Anthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-03udevd: worker - let the kernel attach the sender pidTom Gundersen
No need to include this explicitly, just use SCM_CREDENTIALS. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-03udevd: don't unref worker objects on SIGSTOP/SIGCONTTom Gundersen
We should not be receiving these anyway, but let's be correct. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-03udevd: warn if we receive SIGCHLD from untracked workerTom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-05-03udevd: improve logging in SIGCHLD handlingTom Gundersen
Remove some redundant logging, and reduce the log-level in most cases. The only case that is really critical is if a worker failed while hanlding an event, so keep that at error level.
2015-04-12udevd: fix synchronization with settle when handling inotify eventsDaniel Drake
udev uses inotify to implement a scheme where when the user closes a writable device node, a change uevent is forcefully generated. In the case of block devices, it actually requests a partition rescan. This currently can't be synchronized with "udevadm settle", i.e. this is not reliable in a script: sfdisk --change-id /dev/sda 1 81 udevadm settle mount /dev/sda1 /foo The settle call doesn't synchronize there, so at the same time we try to mount the device, udevd is busy removing the partition device nodes and readding them again. The mount call often happens in that moment where the partition node has been removed but not readded yet. This exact issue was fixed long ago: http://git.kernel.org/cgit/linux/hotplug/udev.git/commit/?id=bb38678e3ccc02bcd970ccde3d8166a40edf92d3 but that fix is no longer valid now that sequence numbers are no longer used. Fix this by forcing another mainloop iteration after handling inotify events before unblocking settle. If the inotify event caused us to generate a "change" event, we'll pick that up in the following loop iteration, before we reach the end of the loop where we respond to settle's control message, unblocking it. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-04-12sd-device,udevd: fix spelling /ammend/amend/Tom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-27Remove hardcoded path /run and configure using --with-rootrundir=David Cortarello
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18udev: make set_usec_initialized() internal to libudevTom Gundersen
Instead introduce ensure_usec_initialized(), which copies the timestamp if possible otherwise sets it to now(CLOCK_MONOTONIC). Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18udevd: improve handling of failed workerTom Gundersen
The information in the db is stale, so it does not make sense to expose it any longer. Also, don't drop the kernel event, but simply pass it on to userspace without ammending it. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18udevd: don't free event when killing the worker, wait until it has been reapedTom Gundersen
This will allow us to clean up the device when we are notified about the worker being killed. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18udev: simplify event_queue_update() and add debug loggingTom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-03-18udevd: close race in udev settleTom Gundersen
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-02-11src/udev/udevd.c: remove create static nodes from modulesAnthony G. Basile
2015-01-25Assorted format fixesZbigniew Jędrzejewski-Szmek
Types used for pids and uids in various interfaces are unpredictable. Too bad. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2015-01-07udevadm,..: make --help output of udev tools more like the output of the ↵Lennart Poettering
various other tools Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-29util: fix strict aliasing violations in use of struct inotify_event v5Shawn Paul Landden
There is alot of cleanup that will have to happen to turn on -fstrict-aliasing, but I think our code should be "correct" to the rule. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-11core: unify how we iterate over inotify eventsLennart Poettering
Let's add some syntactic sugar for iterating through inotify events, and use it everywhere. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-12-01treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt
If the format string contains %m, clearly errno must have a meaningful value, so we might as well use log_*_errno to have ERRNO= logged. Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/' Plus some whitespace, linewrap, and indent adjustments. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>