udevd.c revision 39c19cf13a5d32887977f06cb34e4c95e6da3f56
0N/A * along with this program. If not, see <http://www.gnu.org/licenses/>.
0N/A#include "sd-daemon.h"
0N/A#include "rtnl-util.h"
0N/A#include "cgroup-util.h"
868N/A#include "dev-setup.h"
0N/A#include "selinux-util.h"
868N/A#include "udev-util.h"
0N/A#include "formats-util.h"
0N/Astatic bool stop_exec_queue;
0N/Astatic int arg_daemonize = false;
0N/Astatic int arg_children_max;
0N/Astatic int arg_exec_delay;
0N/Astatic char *udev_cgroup;
0N/Aenum event_state {
0N/A unsigned long long int delaying_seqnum;
0N/A const char *devpath_old;
0N/Aenum worker_state {
0N/A bool event_warned;
0N/Astruct worker_message {
0N/Astatic int worker_new(struct worker **ret, struct udev *udev, struct udev_monitor *worker_monitor, pid_t pid) {
0N/A int fd_monitor;
0N/A if (arg_exec_delay > 0)
0N/A d = udev_device_get_parent(d);
0N/A log_debug_errno(errno, "Unable to flock(%s), skipping event handling: %m", udev_device_get_devnode(d));
0N/A &sigmask_orig);
0N/A &sigmask_orig);
0N/A if (major(event->devnum) != 0 && event->devnum == loop_event->devnum && event->is_block == loop_event->is_block)
0N/A if (major(event->devnum) != 0 && (event->devnum != loop_event->devnum || event->is_block != loop_event->is_block))
0N/A stop_exec_queue = true;
0N/A stop_exec_queue = false;
0N/A arg_children_max = i;
0N/A bool part_table_read = false;
0N/A bool has_partitions = false;
0N/A part_table_read = true;
0N/A r = udev_enumerate_scan_devices(e);
0N/A has_partitions = true;
0N/A struct inotify_event *e;
0N/Astatic void event_queue_update(void) {
0N/A n = sd_listen_fds(true);
0N/A arg_daemonize = true;
0N/A arg_resolve_names = 0;
goto exit;
log_open();
goto exit;
if (arg_debug)
if (getuid() != 0) {
goto exit;
goto exit;
goto exit;
goto exit;
if (arg_daemonize) {
int fd;
if (fd >= 0) {
goto exit;
goto exit;
goto exit;
goto exit;
goto exit;
goto exit;
goto exit;
if (rc < 0)
if (arg_daemonize) {
switch (pid) {
goto exit;
goto exit_daemonize;
setsid();
if (arg_children_max <= 0) {
if (fd_inotify < 0) {
goto exit;
if (fd_signal < 0) {
goto exit;
goto exit;
if (fd_ep < 0) {
goto exit;
goto exit;
int fdcount;
int timeout;
if (udev_exit) {
if (fd_ctrl >= 0) {
if (fd_inotify >= 0) {
if (udev_cgroup)
if (fdcount < 0)
if (fdcount == 0) {
if (udev_exit) {
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 (dev) {
if (is_signal) {
if (udev_exit)
if (is_inotify) {
if (is_ctrl)
exit:
if (fd_ep >= 0)
if (fd_signal >= 0)
log_close();
return rc;