udevd.c revision e9fc29f4ecc9509ccc02eb8a014341e26c0d7831
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * Copyright (C) 2004-2012 Kay Sievers <kay@vrfy.org>
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * Copyright (C) 2004 Chris Friesen <chris_friesen@sympatico.ca>
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * Copyright (C) 2009 Canonical Ltd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * Copyright (C) 2009 Scott James Remnant <scott@netsplit.com>
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * This program is free software: you can redistribute it and/or modify
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * it under the terms of the GNU General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * the Free Software Foundation, either version 2 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * This program is distributed in the hope that it will be useful,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * but WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * GNU General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * You should have received a copy of the GNU General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * along with this program. If not, see <http://www.gnu.org/licenses/>.
91adc4db33f69606aabd332813a5d7d5751c859fLennart Poetteringvoid udev_main_log(struct udev *udev, int priority,
91adc4db33f69606aabd332813a5d7d5751c859fLennart Poettering const char *file, int line, const char *fn,
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering log_metav(priority, file, line, fn, format, args);
8ba9fd9cee0eef572f7b3ed7a8c3ed31160e93d3Lennart Poettering unsigned long long int delaying_seqnum;
8ba9fd9cee0eef572f7b3ed7a8c3ed31160e93d3Lennart Poettering unsigned long long int seqnum;
8ba9fd9cee0eef572f7b3ed7a8c3ed31160e93d3Lennart Poetteringstatic inline struct event *node_to_event(struct udev_list_node *node)
8ba9fd9cee0eef572f7b3ed7a8c3ed31160e93d3Lennart Poettering return container_of(node, struct event, node);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringstatic void event_queue_cleanup(struct udev *udev, enum event_state type);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering/* passed from worker to main process */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic inline struct worker *node_to_worker(struct udev_list_node *node)
ad867662936a4c7ab2c7116d804c272338801231Lennart Poettering return container_of(node, struct worker, node);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic void event_queue_delete(struct event *event)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poetteringstatic struct worker *worker_ref(struct worker *worker)
ad867662936a4c7ab2c7116d804c272338801231Lennart Poetteringstatic void worker_cleanup(struct worker *worker)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poetteringstatic void worker_unref(struct worker *worker)
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering log_debug("worker [%u] cleaned up", worker->pid);
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poetteringstatic void worker_list_cleanup(struct udev *udev)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering udev_list_node_foreach_safe(loop, tmp, &worker_list) {
3339cb71d44c5198f9546f113674f06dc7b01a6fLennart Poettering struct worker *worker = node_to_worker(loop);
3339cb71d44c5198f9546f113674f06dc7b01a6fLennart Poetteringstatic void worker_new(struct event *event)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* listen for new events */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering worker_monitor = udev_monitor_new_from_netlink(udev, NULL);
ad867662936a4c7ab2c7116d804c272338801231Lennart Poettering /* allow the main daemon netlink address to send devices to the worker */
ad867662936a4c7ab2c7116d804c272338801231Lennart Poettering udev_monitor_allow_unicast_sender(worker_monitor, monitor);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering udev_monitor_enable_receiving(worker_monitor);
309e9d86f0e7f9c5f0a2a09227bdfdb3174d4436Lennart Poettering /* worker + event reference */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct epoll_event ep_signal, ep_monitor;
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering /* take initial device from queue */
51323288fc628a5cac50914df915545d685b793eLennart Poettering fd_signal = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("error creating epoll fd: %m");
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering memzero(&ep_signal, sizeof(struct epoll_event));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering fd_monitor = udev_monitor_get_fd(worker_monitor);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering memzero(&ep_monitor, sizeof(struct epoll_event));
7b9f7afcc04e80b77a2567b0750aa2cd03c1a1cdLennart Poettering if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_signal, &ep_signal) < 0 ||
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_monitor, &ep_monitor) < 0) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_error("fail to add fds to epoll: %m");
51323288fc628a5cac50914df915545d685b793eLennart Poettering /* request TERM signal if parent exits */
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering /* reset OOM score, we only protect the main daemon */
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering write_string_file("/proc/self/oom_score_adj", "0");
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_debug("seq %llu running", udev_device_get_seqnum(dev));
82bd6dddc4a363a9c3c6f41eb46eb171a80dca27Lennart Poettering /* needed for SIGCHLD/SIGTERM in spawn() */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * Take a "read lock" on the device node; this establishes
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * a concept of device "ownership" to serialize device
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * access. External processes holding a "write lock" will
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * cause udev to skip the event handling; in the case udev
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * acquired the lock, the external process will block until
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * udev has finished its event handling.
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering * <kabi_> since we make check - device seems unused - we try
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * ioctl to deactivate - and device is found to be opened
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * <kay> sure, you try to take a write lock
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * <kay> if you get it udev is out
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * <kay> if you can't get it, udev is busy
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * <kabi_> we cannot deactivate openned device (as it is in-use)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * <kay> maybe we should just exclude dm from that thing entirely
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering * <kabi_> IMHO this sounds like a good plan for this moment
ad867662936a4c7ab2c7116d804c272338801231Lennart Poettering if (streq_ptr("block", udev_device_get_subsystem(dev)) &&
ad867662936a4c7ab2c7116d804c272338801231Lennart Poettering !startswith("dm-", udev_device_get_sysname(dev))) {
95d46fcaa4f27bc5e675e8de39ab3acc4732e39bTom Gundersen if (streq_ptr("partition", udev_device_get_devtype(d)))
95d46fcaa4f27bc5e675e8de39ab3acc4732e39bTom Gundersen fd_lock = open(udev_device_get_devnode(d), O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK);
95d46fcaa4f27bc5e675e8de39ab3acc4732e39bTom Gundersen if (fd_lock >= 0 && flock(fd_lock, LOCK_SH|LOCK_NB) < 0) {
7588460aaf6bd33f6c9bd5645916cfd8a862e9c4Tom Gundersen log_debug("Unable to flock(%s), skipping event handling: %m", udev_device_get_devnode(d));
ad867662936a4c7ab2c7116d804c272338801231Lennart Poettering /* apply rules, create node, symlinks */
ad867662936a4c7ab2c7116d804c272338801231Lennart Poettering udev_event_execute_rules(udev_event, rules, &sigmask_orig);
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering udev_event_execute_run(udev_event, &sigmask_orig);
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering /* apply/restore inotify watch */
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering /* send processed event back to libudev listeners */
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering udev_monitor_send_device(worker_monitor, NULL, dev);
ad867662936a4c7ab2c7116d804c272338801231Lennart Poettering /* send udevd the result of the event execution */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering memzero(&msg, sizeof(struct worker_message));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering send(worker_watch[WRITE_END], &msg, sizeof(struct worker_message), 0);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("seq %llu processed with %i", udev_device_get_seqnum(dev), err);
ad867662936a4c7ab2c7116d804c272338801231Lennart Poettering /* wait for more device messages from main udevd, or term signal */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering fdcount = epoll_wait(fd_ep, ev, ELEMENTSOF(ev), -1);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering for (i = 0; i < fdcount; i++) {
51323288fc628a5cac50914df915545d685b793eLennart Poettering if (ev[i].data.fd == fd_monitor && ev[i].events & EPOLLIN) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering dev = udev_monitor_receive_device(worker_monitor);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } else if (ev[i].data.fd == fd_signal && ev[i].events & EPOLLIN) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering size = read(fd_signal, &fdsi, sizeof(struct signalfd_siginfo));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (size != sizeof(struct signalfd_siginfo))
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* close monitor, but keep address around */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering worker->event_start_usec = now(CLOCK_MONOTONIC);
966c66e34940001a40806142ecebaae61b478444Lennart Poettering udev_list_node_append(&worker->node, &worker_list);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("seq %llu forked new worker [%u]", udev_device_get_seqnum(event->dev), pid);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic void event_run(struct event *event)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering udev_list_node_foreach(loop, &worker_list) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering struct worker *worker = node_to_worker(loop);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering count = udev_monitor_send_device(monitor, worker->monitor, event->dev);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_error("worker [%u] did not accept message %zi (%m), kill it", worker->pid, count);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering worker->event_start_usec = now(CLOCK_MONOTONIC);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("maximum number (%i) of children reached", children);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering /* start new worker and pass initial device */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poetteringstatic int event_queue_insert(struct udev_device *dev)
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering event->seqnum = udev_device_get_seqnum(dev);
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering event->devpath = udev_device_get_devpath(dev);
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering event->devpath_len = strlen(event->devpath);
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering event->devpath_old = udev_device_get_devpath_old(dev);
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering event->devnum = udev_device_get_devnum(dev);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering event->is_block = streq("block", udev_device_get_subsystem(dev));
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering event->ifindex = udev_device_get_ifindex(dev);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering if (streq(udev_device_get_subsystem(dev), "firmware"))
7588460aaf6bd33f6c9bd5645916cfd8a862e9c4Tom Gundersen log_debug("seq %llu queued, '%s' '%s'", udev_device_get_seqnum(dev),
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering udev_device_get_action(dev), udev_device_get_subsystem(dev));
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering udev_list_node_append(&event->node, &event_list);
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poetteringstatic void worker_kill(struct udev *udev)
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering udev_list_node_foreach(loop, &worker_list) {
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering struct worker *worker = node_to_worker(loop);
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering/* lookup event for identical, parent, child device */
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poetteringstatic bool is_devpath_busy(struct event *event)
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering /* check if queue contains events we depend on */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering udev_list_node_foreach(loop, &event_list) {
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering struct event *loop_event = node_to_event(loop);
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering /* we already found a later event, earlier can not block us, no need to check again */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering if (loop_event->seqnum < event->delaying_seqnum)
51323288fc628a5cac50914df915545d685b793eLennart Poettering /* event we checked earlier still exists, no need to check again */
51323288fc628a5cac50914df915545d685b793eLennart Poettering if (loop_event->seqnum == event->delaying_seqnum)
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering /* found ourself, no later event can block us */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering if (major(event->devnum) != 0 && event->devnum == loop_event->devnum && event->is_block == loop_event->is_block)
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering /* check network device ifindex */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering if (event->ifindex != 0 && event->ifindex == loop_event->ifindex)
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering /* check our old name */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering if (event->devpath_old != NULL && streq(loop_event->devpath, event->devpath_old)) {
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering event->delaying_seqnum = loop_event->seqnum;
51323288fc628a5cac50914df915545d685b793eLennart Poettering /* compare devpath */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering common = MIN(loop_event->devpath_len, event->devpath_len);
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering /* one devpath is contained in the other? */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering if (memcmp(loop_event->devpath, event->devpath, common) != 0)
51323288fc628a5cac50914df915545d685b793eLennart Poettering /* identical device event found */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering if (loop_event->devpath_len == event->devpath_len) {
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering /* devices names might have changed/swapped in the meantime */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering if (major(event->devnum) != 0 && (event->devnum != loop_event->devnum || event->is_block != loop_event->is_block))
7b9f7afcc04e80b77a2567b0750aa2cd03c1a1cdLennart Poettering if (event->ifindex != 0 && event->ifindex != loop_event->ifindex)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering event->delaying_seqnum = loop_event->seqnum;
d0129ddb9fbb07bed7c8ea51b8031f824bf506fbLennart Poettering /* allow to bypass the dependency tracking */
51323288fc628a5cac50914df915545d685b793eLennart Poettering /* parent device event found */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering event->delaying_seqnum = loop_event->seqnum;
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering /* child device event found */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering if (loop_event->devpath[common] == '/') {
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering event->delaying_seqnum = loop_event->seqnum;
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poettering /* no matching device */
2d4c5cbc0ed3ccb09dc086a040088b454c22c644Lennart Poetteringstatic void event_queue_start(struct udev *udev)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering udev_list_node_foreach(loop, &event_list) {
82bd6dddc4a363a9c3c6f41eb46eb171a80dca27Lennart Poettering struct event *event = node_to_event(loop);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering /* do not start event if parent or child event is still running */
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poetteringstatic void event_queue_cleanup(struct udev *udev, enum event_state match_type)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering udev_list_node_foreach_safe(loop, tmp, &event_list) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering struct event *event = node_to_event(loop);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering if (match_type != EVENT_UNDEF && match_type != event->state)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poetteringstatic void worker_returned(int fd_worker)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering size = recv(fd_worker, &msg, sizeof(struct worker_message), MSG_DONTWAIT);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering if (size != sizeof(struct worker_message))
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering /* lookup worker who sent the signal */
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering udev_list_node_foreach(loop, &worker_list) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering struct worker *worker = node_to_worker(loop);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering /* worker returned */
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering/* receive the udevd message from userspace */
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poetteringstatic struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering struct udev *udev = udev_ctrl_get_udev(uctrl);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering ctrl_conn = udev_ctrl_get_connection(uctrl);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering ctrl_msg = udev_ctrl_receive_msg(ctrl_conn);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering i = udev_ctrl_get_set_log_level(ctrl_msg);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("udevd message (SET_LOG_LEVEL) received, log_priority=%i", i);
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering if (udev_ctrl_get_stop_exec_queue(ctrl_msg) > 0) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("udevd message (STOP_EXEC_QUEUE) received");
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering if (udev_ctrl_get_start_exec_queue(ctrl_msg) > 0) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("udevd message (START_EXEC_QUEUE) received");
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering if (udev_ctrl_get_reload(ctrl_msg) > 0) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("udevd message (RELOAD) received");
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("udevd message (ENV) received, unset '%s'", key);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("udevd message (ENV) received, set '%s=%s'", key, val);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering i = udev_ctrl_get_set_children_max(ctrl_msg);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("udevd message (SET_MAX_CHILDREN) received, children_max=%i", i);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("udevd message (SYNC) received");
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("udevd message (EXIT) received");
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering /* keep reference to block the client until we exit */
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering return udev_ctrl_connection_unref(ctrl_conn);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poetteringstatic int synthesize_change(struct udev_device *dev) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering if (streq_ptr("block", udev_device_get_subsystem(dev)) &&
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering streq_ptr("disk", udev_device_get_devtype(dev)) &&
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering !startswith("dm-", udev_device_get_sysname(dev))) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering struct udev *udev = udev_device_get_udev(dev);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering _cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering * Try to re-read the partition table. This only succeeds if
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering * none of the devices is busy. The kernel returns 0 if no
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * partition table is found, and we will not get an event for
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering fd = open(udev_device_get_devnode(dev), O_RDONLY|O_EXCL|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering /* search for partitions */
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering r = udev_enumerate_add_match_parent(e, dev);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering r = udev_enumerate_add_match_subsystem(e, "block");
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering udev_list_entry_foreach(item, udev_enumerate_get_list_entry(e)) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering _cleanup_udev_device_unref_ struct udev_device *d = NULL;
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering d = udev_device_new_from_syspath(udev, udev_list_entry_get_name(item));
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering if (!streq_ptr("partition", udev_device_get_devtype(d)))
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * We have partitions and re-read the table, the kernel already sent
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering * out a "change" event for the disk, and "remove/add" for all
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * We have partitions but re-reading the partition table did not
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * work, synthesize "change" for the disk and all partitions.
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("device %s closed, synthesising 'change'", udev_device_get_devnode(dev));
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering strscpyl(filename, sizeof(filename), udev_device_get_syspath(dev), "/uevent", NULL);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering udev_list_entry_foreach(item, udev_enumerate_get_list_entry(e)) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering _cleanup_udev_device_unref_ struct udev_device *d = NULL;
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering d = udev_device_new_from_syspath(udev, udev_list_entry_get_name(item));
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering if (!streq_ptr("partition", udev_device_get_devtype(d)))
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering log_debug("device %s closed, synthesising partition '%s' 'change'",
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering udev_device_get_devnode(dev), udev_device_get_devnode(d));
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering strscpyl(filename, sizeof(filename), udev_device_get_syspath(d), "/uevent", NULL);
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering log_debug("device %s closed, synthesising 'change'", udev_device_get_devnode(dev));
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering strscpyl(filename, sizeof(filename), udev_device_get_syspath(dev), "/uevent", NULL);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poetteringstatic int handle_inotify(struct udev *udev)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering r = ioctl(fd_inotify, FIONREAD, &nbytes);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering if (r < 0 || nbytes <= 0)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_error("error getting buffer for inotify");
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering for (pos = 0; pos < nbytes; pos += sizeof(struct inotify_event) + ev->len) {
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering ev = (struct inotify_event *)(buf + pos);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("inotify event: %x for %s", ev->mask, udev_device_get_devnode(dev));
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poetteringstatic void handle_signal(struct udev *udev, int signo)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering udev_list_node_foreach_safe(loop, tmp, &worker_list) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering struct worker *worker = node_to_worker(loop);
7588460aaf6bd33f6c9bd5645916cfd8a862e9c4Tom Gundersen log_error("worker [%u] exit with return code %i",
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_error("worker [%u] terminated by signal %i (%s)",
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering pid, WTERMSIG(status), strsignal(WTERMSIG(status)));
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_error("worker [%u] exit with status 0x%04x", pid, status);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_error("worker [%u] failed while handling '%s'",
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering /* drop reference taken for state 'running' */
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poetteringstatic int systemd_fds(struct udev *udev, int *rctrl, int *rnetlink)
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering for (fd = SD_LISTEN_FDS_START; fd < n + SD_LISTEN_FDS_START; fd++) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering if (sd_is_socket(fd, AF_LOCAL, SOCK_SEQPACKET, -1)) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering if (sd_is_socket(fd, AF_NETLINK, SOCK_RAW, -1)) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_debug("ctrl=%i netlink=%i", ctrl, netlink);
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * read the kernel commandline, in case we need to get into debug mode
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * udev.log-priority=<level> syslog priority
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering * udev.children-max=<number of workers> events are fully serialized if set to 1
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering * udev.exec-delay=<number of seconds> delay execution of every executed program
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poetteringstatic void kernel_cmdline_options(struct udev *udev)
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering /* accept the same options for the initrd, prefixed with "rd." */
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering if (startswith(opt, "udev.log-priority=")) {
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering } else if (startswith(opt, "udev.children-max=")) {
9a1f0c283bac56eb26a2fa02d62e0e9ece82f25aLennart Poettering children_max = strtoul(opt + 18, NULL, 0);
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering } else if (startswith(opt, "udev.exec-delay=")) {
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering { "children-max", required_argument, NULL, 'c' },
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering { "exec-delay", required_argument, NULL, 'e' },
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering { "resolve-names", required_argument, NULL, 'N' },
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering struct epoll_event ep_ctrl, ep_inotify, ep_signal, ep_netlink, ep_worker;
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering struct udev_ctrl_connection *ctrl_conn = NULL;
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering log_set_max_level(udev_get_log_priority(udev));
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering option = getopt_long(argc, argv, "c:de:DtN:hV", options, NULL);
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering fprintf(stderr, "resolve-names must be early, late or never\n");
23b298bce75a0d1f4f15f34458af9678b4a30c3aLennart Poettering log_error("resolve-names must be early, late or never");
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering " --children-max=<maximum number of workers>\n"
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering " --exec-delay=<seconds to wait before executing RUN=>\n"
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering " --resolve-names=early|late|never\n"
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering " --version\n"
45ec7efb6c2560c80dfa752bc9d3733749dc52cbLennart Poettering fprintf(stderr, "root privileges required\n");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering /* set umask before creating any file/directory */
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering /* before opening new files, make sure std{in,out,err} fds are in a sane state */
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering fprintf(stderr, "cannot open /dev/null\n");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering if (systemd_fds(udev, &fd_ctrl, &fd_netlink) >= 0) {
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering /* get control and netlink socket from systemd */
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering udev_ctrl = udev_ctrl_new_from_fd(udev, fd_ctrl);
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering log_error("error taking over udev control socket");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering monitor = udev_monitor_new_from_netlink_fd(udev, "kernel", fd_netlink);
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering log_error("error taking over netlink socket");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering /* get our own cgroup, we regularly kill everything udev has left behind */
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering if (cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, 0, &udev_cgroup) < 0)
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering /* open control and netlink socket */
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering fprintf(stderr, "error initializing udev control socket");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering log_error("error initializing udev control socket");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering monitor = udev_monitor_new_from_netlink(udev, "kernel");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering fprintf(stderr, "error initializing netlink socket\n");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering log_error("error initializing netlink socket");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering fd_netlink = udev_monitor_get_fd(monitor);
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering if (udev_monitor_enable_receiving(monitor) < 0) {
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering fprintf(stderr, "error binding netlink socket\n");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering log_error("error binding netlink socket");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering if (udev_ctrl_enable_receiving(udev_ctrl) < 0) {
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering fprintf(stderr, "error binding udev control socket\n");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering log_error("error binding udev control socket");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering udev_monitor_set_receive_buffer_size(monitor, 128 * 1024 * 1024);
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering write_string_file("/proc/self/oom_score_adj", "-1000");
7f220d94a938a99c77400fa0ca30485e269bae7cLennart Poettering print_kmsg("starting version " VERSION "\n");
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering fprintf(stderr, "error initializing inotify\n");
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering /* block and listen to all signals on signalfd */
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering sigprocmask(SIG_SETMASK, &mask, &sigmask_orig);
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering fd_signal = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering fprintf(stderr, "error creating signalfd\n");
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering /* unnamed socket from workers to the main daemon */
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering if (socketpair(AF_LOCAL, SOCK_DGRAM|SOCK_CLOEXEC, 0, worker_watch) < 0) {
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering fprintf(stderr, "error creating socketpair\n");
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering rules = udev_rules_new(udev, resolve_names);
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering memzero(&ep_ctrl, sizeof(struct epoll_event));
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering memzero(&ep_inotify, sizeof(struct epoll_event));
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering memzero(&ep_signal, sizeof(struct epoll_event));
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering memzero(&ep_netlink, sizeof(struct epoll_event));
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering memzero(&ep_worker, sizeof(struct epoll_event));
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering log_error("error creating epoll fd: %m");
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_ctrl, &ep_ctrl) < 0 ||
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_inotify, &ep_inotify) < 0 ||
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_signal, &ep_signal) < 0 ||
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_netlink, &ep_netlink) < 0 ||
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_worker, &ep_worker) < 0) {
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering log_error("fail to add fds to epoll: %m");
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering if (sched_getaffinity(0, sizeof (cpu_set), &cpu_set) == 0) {
78c6a153c47f8d597c827bdcaf8c4e42ac87f738Lennart Poettering log_debug("set children_max to %u", children_max);
78c6a153c47f8d597c827bdcaf8c4e42ac87f738Lennart Poettering rc = udev_rules_apply_static_dev_perms(rules);
a150ff5e4e2481eb28d6ed6e0d3e176623e25f5aLennart Poettering log_error("failed to apply permissions on static device nodes - %s", strerror(-rc));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering bool is_worker, is_signal, is_inotify, is_netlink, is_ctrl;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* close sources of new events and discard buffered events */
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering epoll_ctl(fd_ep, EPOLL_CTL_DEL, fd_ctrl, NULL);
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering epoll_ctl(fd_ep, EPOLL_CTL_DEL, fd_netlink, NULL);
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt epoll_ctl(fd_ep, EPOLL_CTL_DEL, fd_inotify, NULL);
902bb5d8abb2a7d258741828d212ca549ab16950Lennart Poettering /* discard queued events and kill workers */
902bb5d8abb2a7d258741828d212ca549ab16950Lennart Poettering /* exit after all has cleaned up */
902bb5d8abb2a7d258741828d212ca549ab16950Lennart Poettering if (udev_list_node_is_empty(&event_list) && children == 0)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* timeout at exit for workers to finish */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } else if (udev_list_node_is_empty(&event_list) && children == 0) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* we are idle */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* cleanup possible left-over processes in our cgroup */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering cg_kill(SYSTEMD_CGROUP_CONTROLLER, udev_cgroup, SIGKILL, false, true, NULL);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* kill idle or hanging workers */
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt /* tell settle that we are busy or idle */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (!udev_list_node_is_empty(&event_list)) {
f647962d64e844689f3e2acfce6102fc47e76df2Michal Schmidt fd = open("/run/udev/queue", O_WRONLY|O_CREAT|O_CLOEXEC|O_TRUNC|O_NOFOLLOW, 0444);
f647962d64e844689f3e2acfce6102fc47e76df2Michal Schmidt fdcount = epoll_wait(fd_ep, ev, ELEMENTSOF(ev), timeout);
f647962d64e844689f3e2acfce6102fc47e76df2Michal Schmidt log_error("timeout, giving up waiting for workers to finish");
902bb5d8abb2a7d258741828d212ca549ab16950Lennart Poettering /* kill idle workers */
902bb5d8abb2a7d258741828d212ca549ab16950Lennart Poettering if (udev_list_node_is_empty(&event_list)) {
902bb5d8abb2a7d258741828d212ca549ab16950Lennart Poettering /* check for hanging events */
902bb5d8abb2a7d258741828d212ca549ab16950Lennart Poettering struct worker *worker = node_to_worker(loop);
log_error("seq %llu '%s' killed", udev_device_get_seqnum(worker->event->dev), worker->event->devpath);
for (i = 0; i < fdcount; i++) {
is_worker = true;
is_netlink = true;
is_signal = true;
is_inotify = true;
is_ctrl = true;
reload = true;
reload = true;
if (reload) {
reload = false;
if (is_worker)
if (is_netlink) {
if (is_signal) {
if (udev_exit)
if (is_inotify)
if (is_ctrl)
exit:
if (fd_ep >= 0)
if (fd_signal >= 0)
label_finish();
log_close();
return rc;