diff options
Diffstat (limited to 'src/udev/udevd.c')
-rw-r--r-- | src/udev/udevd.c | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 572bca881d..d7c172cc75 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -145,7 +145,7 @@ static void event_queue_delete(struct event *event, bool export) if (export) { udev_queue_export_device_finished(udev_queue_export, event->dev); - log_debug("seq %llu done with %i\n", udev_device_get_seqnum(event->dev), event->exitcode); + log_debug("seq %llu done with %i", udev_device_get_seqnum(event->dev), event->exitcode); } udev_device_unref(event->dev); free(event); @@ -170,7 +170,7 @@ static void worker_unref(struct worker *worker) worker->refcount--; if (worker->refcount > 0) return; - log_debug("worker [%u] cleaned up\n", worker->pid); + log_debug("worker [%u] cleaned up", worker->pid); worker_cleanup(worker); } @@ -235,14 +235,14 @@ static void worker_new(struct event *event) sigfillset(&mask); fd_signal = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC); if (fd_signal < 0) { - log_error("error creating signalfd %m\n"); + log_error("error creating signalfd %m"); rc = 2; goto out; } fd_ep = epoll_create1(EPOLL_CLOEXEC); if (fd_ep < 0) { - log_error("error creating epoll fd: %m\n"); + log_error("error creating epoll fd: %m"); rc = 3; goto out; } @@ -258,7 +258,7 @@ static void worker_new(struct event *event) if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_signal, &ep_signal) < 0 || epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_monitor, &ep_monitor) < 0) { - log_error("fail to add fds to epoll: %m\n"); + log_error("fail to add fds to epoll: %m"); rc = 4; goto out; } @@ -274,7 +274,7 @@ static void worker_new(struct event *event) struct worker_message msg; int err; - log_debug("seq %llu running\n", udev_device_get_seqnum(dev)); + log_debug("seq %llu running", udev_device_get_seqnum(dev)); udev_event = udev_event_new(dev); if (udev_event == NULL) { rc = 5; @@ -309,7 +309,7 @@ static void worker_new(struct event *event) msg.pid = getpid(); send(worker_watch[WRITE_END], &msg, sizeof(struct worker_message), 0); - log_debug("seq %llu processed with %i\n", udev_device_get_seqnum(dev), err); + log_debug("seq %llu processed with %i", udev_device_get_seqnum(dev), err); udev_device_unref(dev); dev = NULL; @@ -331,7 +331,7 @@ static void worker_new(struct event *event) if (fdcount < 0) { if (errno == EINTR) continue; - log_error("failed to poll: %m\n"); + log_error("failed to poll: %m"); goto out; } @@ -373,7 +373,7 @@ out: udev_monitor_unref(worker_monitor); event->state = EVENT_QUEUED; free(worker); - log_error("fork of child failed: %m\n"); + log_error("fork of child failed: %m"); break; default: /* close monitor, but keep address around */ @@ -386,7 +386,7 @@ out: event->state = EVENT_RUNNING; udev_list_node_append(&worker->node, &worker_list); children++; - log_debug("seq %llu forked new worker [%u]\n", udev_device_get_seqnum(event->dev), pid); + log_debug("seq %llu forked new worker [%u]", udev_device_get_seqnum(event->dev), pid); break; } } @@ -404,7 +404,7 @@ static void event_run(struct event *event) count = udev_monitor_send_device(monitor, worker->monitor, event->dev); if (count < 0) { - log_error("worker [%u] did not accept message %zi (%m), kill it\n", worker->pid, count); + log_error("worker [%u] did not accept message %zi (%m), kill it", worker->pid, count); kill(worker->pid, SIGKILL); worker->state = WORKER_KILLED; continue; @@ -419,7 +419,7 @@ static void event_run(struct event *event) if (children >= children_max) { if (children_max > 1) - log_debug("maximum number (%i) of children reached\n", children); + log_debug("maximum number (%i) of children reached", children); return; } @@ -450,7 +450,7 @@ static int event_queue_insert(struct udev_device *dev) #endif udev_queue_export_device_queued(udev_queue_export, dev); - log_debug("seq %llu queued, '%s' '%s'\n", udev_device_get_seqnum(dev), + log_debug("seq %llu queued, '%s' '%s'", udev_device_get_seqnum(dev), udev_device_get_action(dev), udev_device_get_subsystem(dev)); event->state = EVENT_QUEUED; @@ -635,24 +635,24 @@ static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl) i = udev_ctrl_get_set_log_level(ctrl_msg); if (i >= 0) { - log_debug("udevd message (SET_LOG_PRIORITY) received, log_priority=%i\n", i); + log_debug("udevd message (SET_LOG_PRIORITY) received, log_priority=%i", i); log_set_max_level(i); udev_set_log_priority(udev, i); worker_kill(udev); } if (udev_ctrl_get_stop_exec_queue(ctrl_msg) > 0) { - log_debug("udevd message (STOP_EXEC_QUEUE) received\n"); + log_debug("udevd message (STOP_EXEC_QUEUE) received"); stop_exec_queue = true; } if (udev_ctrl_get_start_exec_queue(ctrl_msg) > 0) { - log_debug("udevd message (START_EXEC_QUEUE) received\n"); + log_debug("udevd message (START_EXEC_QUEUE) received"); stop_exec_queue = false; } if (udev_ctrl_get_reload(ctrl_msg) > 0) { - log_debug("udevd message (RELOAD) received\n"); + log_debug("udevd message (RELOAD) received"); reload = true; } @@ -669,14 +669,14 @@ static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl) val[0] = '\0'; val = &val[1]; if (val[0] == '\0') { - log_debug("udevd message (ENV) received, unset '%s'\n", key); + log_debug("udevd message (ENV) received, unset '%s'", key); udev_add_property(udev, key, NULL); } else { - log_debug("udevd message (ENV) received, set '%s=%s'\n", key, val); + log_debug("udevd message (ENV) received, set '%s=%s'", key, val); udev_add_property(udev, key, val); } } else { - log_error("wrong key format '%s'\n", key); + log_error("wrong key format '%s'", key); } free(key); } @@ -685,15 +685,15 @@ static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl) i = udev_ctrl_get_set_children_max(ctrl_msg); if (i >= 0) { - log_debug("udevd message (SET_MAX_CHILDREN) received, children_max=%i\n", i); + log_debug("udevd message (SET_MAX_CHILDREN) received, children_max=%i", i); children_max = i; } if (udev_ctrl_get_ping(ctrl_msg) > 0) - log_debug("udevd message (SYNC) received\n"); + log_debug("udevd message (SYNC) received"); if (udev_ctrl_get_exit(ctrl_msg) > 0) { - log_debug("udevd message (EXIT) received\n"); + log_debug("udevd message (EXIT) received"); udev_exit = true; /* keep reference to block the client until we exit */ udev_ctrl_connection_ref(ctrl_conn); @@ -715,7 +715,7 @@ static int handle_inotify(struct udev *udev) buf = malloc(nbytes); if (buf == NULL) { - log_error("error getting buffer for inotify\n"); + log_error("error getting buffer for inotify"); return -1; } @@ -727,17 +727,17 @@ static int handle_inotify(struct udev *udev) ev = (struct inotify_event *)(buf + pos); dev = udev_watch_lookup(udev, ev->wd); if (dev != NULL) { - log_debug("inotify event: %x for %s\n", ev->mask, udev_device_get_devnode(dev)); + log_debug("inotify event: %x for %s", ev->mask, udev_device_get_devnode(dev)); if (ev->mask & IN_CLOSE_WRITE) { char filename[UTIL_PATH_SIZE]; int fd; - log_debug("device %s closed, synthesising 'change'\n", udev_device_get_devnode(dev)); + log_debug("device %s closed, synthesising 'change'", udev_device_get_devnode(dev)); strscpyl(filename, sizeof(filename), udev_device_get_syspath(dev), "/uevent", NULL); fd = open(filename, O_WRONLY); if (fd >= 0) { if (write(fd, "change", 6) < 0) - log_debug("error writing uevent: %m\n"); + log_debug("error writing uevent: %m"); close(fd); } } @@ -775,26 +775,26 @@ static void handle_signal(struct udev *udev, int signo) if (worker->pid != pid) continue; - log_debug("worker [%u] exit\n", pid); + log_debug("worker [%u] exit", pid); if (WIFEXITED(status)) { if (WEXITSTATUS(status) != 0) - log_error("worker [%u] exit with return code %i\n", + log_error("worker [%u] exit with return code %i", pid, WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { - log_error("worker [%u] terminated by signal %i (%s)\n", + log_error("worker [%u] terminated by signal %i (%s)", pid, WTERMSIG(status), strsignal(WTERMSIG(status))); } else if (WIFSTOPPED(status)) { - log_error("worker [%u] stopped\n", pid); + log_error("worker [%u] stopped", pid); } else if (WIFCONTINUED(status)) { - log_error("worker [%u] continued\n", pid); + log_error("worker [%u] continued", pid); } else { - log_error("worker [%u] exit with status 0x%04x\n", pid, status); + log_error("worker [%u] exit with status 0x%04x", pid, status); } if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { if (worker->event) { - log_error("worker [%u] failed while handling '%s'\n", + log_error("worker [%u] failed while handling '%s'", pid, worker->event->devpath); worker->event->exitcode = -32; event_queue_delete(worker->event, true); @@ -843,7 +843,7 @@ static int systemd_fds(struct udev *udev, int *rctrl, int *rnetlink) if (ctrl < 0 || netlink < 0) return -1; - log_debug("ctrl=%i netlink=%i\n", ctrl, netlink); + log_debug("ctrl=%i netlink=%i", ctrl, netlink); *rctrl = ctrl; *rnetlink = netlink; return 0; @@ -931,7 +931,7 @@ int main(int argc, char *argv[]) udev_set_log_fn(udev, udev_main_log); log_set_max_level(udev_get_log_priority(udev)); - log_debug("version %s\n", VERSION); + log_debug("version %s", VERSION); label_init("/dev"); for (;;) { @@ -965,7 +965,7 @@ int main(int argc, char *argv[]) resolve_names = -1; } else { fprintf(stderr, "resolve-names must be early, late or never\n"); - log_error("resolve-names must be early, late or never\n"); + log_error("resolve-names must be early, late or never"); goto exit; } break; @@ -992,7 +992,7 @@ int main(int argc, char *argv[]) if (getuid() != 0) { fprintf(stderr, "root privileges required\n"); - log_error("root privileges required\n"); + log_error("root privileges required"); goto exit; } @@ -1018,7 +1018,7 @@ int main(int argc, char *argv[]) close(fd); } else { fprintf(stderr, "cannot open /dev/null\n"); - log_error("cannot open /dev/null\n"); + log_error("cannot open /dev/null"); } } @@ -1033,7 +1033,7 @@ int main(int argc, char *argv[]) monitor = udev_monitor_new_from_netlink_fd(udev, "kernel", fd_netlink); if (monitor == NULL) { - log_error("error taking over netlink socket\n"); + log_error("error taking over netlink socket"); rc = 3; goto exit; } @@ -1055,7 +1055,7 @@ int main(int argc, char *argv[]) monitor = udev_monitor_new_from_netlink(udev, "kernel"); if (monitor == NULL) { fprintf(stderr, "error initializing netlink socket\n"); - log_error("error initializing netlink socket\n"); + log_error("error initializing netlink socket"); rc = 3; goto exit; } @@ -1064,14 +1064,14 @@ int main(int argc, char *argv[]) if (udev_monitor_enable_receiving(monitor) < 0) { fprintf(stderr, "error binding netlink socket\n"); - log_error("error binding netlink socket\n"); + log_error("error binding netlink socket"); rc = 3; goto exit; } if (udev_ctrl_enable_receiving(udev_ctrl) < 0) { fprintf(stderr, "error binding udev control socket\n"); - log_error("error binding udev control socket\n"); + log_error("error binding udev control socket"); rc = 1; goto exit; } @@ -1081,7 +1081,7 @@ int main(int argc, char *argv[]) /* create queue file before signalling 'ready', to make sure we block 'settle' */ udev_queue_export = udev_queue_export_new(udev); if (udev_queue_export == NULL) { - log_error("error creating queue file\n"); + log_error("error creating queue file"); goto exit; } @@ -1093,7 +1093,7 @@ int main(int argc, char *argv[]) case 0: break; case -1: - log_error("fork of daemon failed: %m\n"); + log_error("fork of daemon failed: %m"); rc = 4; goto exit; default: @@ -1125,7 +1125,7 @@ int main(int argc, char *argv[]) fd_inotify = udev_watch_init(udev); if (fd_inotify < 0) { fprintf(stderr, "error initializing inotify\n"); - log_error("error initializing inotify\n"); + log_error("error initializing inotify"); rc = 4; goto exit; } @@ -1137,7 +1137,7 @@ int main(int argc, char *argv[]) fd_signal = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC); if (fd_signal < 0) { fprintf(stderr, "error creating signalfd\n"); - log_error("error creating signalfd\n"); + log_error("error creating signalfd"); rc = 5; goto exit; } @@ -1145,7 +1145,7 @@ int main(int argc, char *argv[]) /* unnamed socket from workers to the main daemon */ if (socketpair(AF_LOCAL, SOCK_DGRAM|SOCK_CLOEXEC, 0, worker_watch) < 0) { fprintf(stderr, "error creating socketpair\n"); - log_error("error creating socketpair\n"); + log_error("error creating socketpair"); rc = 6; goto exit; } @@ -1155,7 +1155,7 @@ int main(int argc, char *argv[]) rules = udev_rules_new(udev, resolve_names); if (rules == NULL) { - log_error("error reading rules\n"); + log_error("error reading rules"); goto exit; } @@ -1181,7 +1181,7 @@ int main(int argc, char *argv[]) fd_ep = epoll_create1(EPOLL_CLOEXEC); if (fd_ep < 0) { - log_error("error creating epoll fd: %m\n"); + log_error("error creating epoll fd: %m"); goto exit; } if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_ctrl, &ep_ctrl) < 0 || @@ -1189,7 +1189,7 @@ int main(int argc, char *argv[]) epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_signal, &ep_signal) < 0 || epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_netlink, &ep_netlink) < 0 || epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_worker, &ep_worker) < 0) { - log_error("fail to add fds to epoll: %m\n"); + log_error("fail to add fds to epoll: %m"); goto exit; } @@ -1202,11 +1202,11 @@ int main(int argc, char *argv[]) children_max += CPU_COUNT(&cpu_set) * 2; } } - log_debug("set children_max to %u\n", children_max); + log_debug("set children_max to %u", children_max); rc = udev_rules_apply_static_dev_perms(rules); if (rc < 0) - log_error("failed to apply permissions on static device nodes - %s\n", strerror(-rc)); + log_error("failed to apply permissions on static device nodes - %s", strerror(-rc)); udev_list_node_init(&event_list); udev_list_node_init(&worker_list); @@ -1266,13 +1266,13 @@ int main(int argc, char *argv[]) /* timeout */ if (udev_exit) { - log_error("timeout, giving up waiting for workers to finish\n"); + log_error("timeout, giving up waiting for workers to finish"); break; } /* kill idle workers */ if (udev_list_node_is_empty(&event_list)) { - log_debug("cleanup idle workers\n"); + log_debug("cleanup idle workers"); worker_kill(udev); } @@ -1284,14 +1284,14 @@ int main(int argc, char *argv[]) continue; if ((now(CLOCK_MONOTONIC) - worker->event_start_usec) > 30 * 1000 * 1000) { - log_error("worker [%u] %s timeout; kill it\n", worker->pid, + log_error("worker [%u] %s timeout; kill it", worker->pid, worker->event ? worker->event->devpath : "<idle>"); kill(worker->pid, SIGKILL); worker->state = WORKER_KILLED; /* drop reference taken for state 'running' */ worker_unref(worker); if (worker->event) { - log_error("seq %llu '%s' killed\n", + log_error("seq %llu '%s' killed", udev_device_get_seqnum(worker->event->dev), worker->event->devpath); worker->event->exitcode = -64; event_queue_delete(worker->event, true); |