summaryrefslogtreecommitdiff
path: root/src/udev/udevd.c
diff options
context:
space:
mode:
authorSimon Peeters <simon@inuits.eu>2016-11-06 16:09:32 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-11-22 10:38:05 +0100
commit40a577165805a4abd6c1b7f9bf210fe8ae3837b3 (patch)
tree20f16079cc3293fd80aedd4c051da631f372e164 /src/udev/udevd.c
parent8a9b3a23fd0153e3b3e6768d03002819c2fc50e4 (diff)
downloadsystemd-40a577165805a4abd6c1b7f9bf210fe8ae3837b3.tar.gz
udevd: use list.h instead of udev_list_node
Diffstat (limited to 'src/udev/udevd.c')
-rw-r--r--src/udev/udevd.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index d18e586d72..61db2c2db4 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -54,6 +54,7 @@
#include "fs-util.h"
#include "hashmap.h"
#include "io-util.h"
+#include "list.h"
#include "netlink-util.h"
#include "parse-util.h"
#include "proc-cmdline.h"
@@ -79,7 +80,7 @@ typedef struct Manager {
struct udev *udev;
sd_event *event;
Hashmap *workers;
- struct udev_list_node events;
+ LIST_HEAD(struct event, events);
const char *cgroup;
pid_t pid; /* the process that originally allocated the manager object */
@@ -109,7 +110,7 @@ enum event_state {
};
struct event {
- struct udev_list_node node;
+ LIST_FIELDS(struct event, event);
Manager *manager;
struct udev *udev;
struct udev_device *dev;
@@ -128,10 +129,6 @@ struct event {
sd_event_source *timeout;
};
-static inline struct event *node_to_event(struct udev_list_node *node) {
- return container_of(node, struct event, node);
-}
-
static void event_queue_cleanup(Manager *manager, enum event_state type);
enum worker_state {
@@ -160,8 +157,9 @@ static void event_free(struct event *event) {
if (!event)
return;
+ assert(event->manager);
- udev_list_node_remove(&event->node);
+ LIST_REMOVE(event, event->manager->events, event);
udev_device_unref(event->dev);
udev_device_unref(event->dev_kernel);
@@ -171,9 +169,7 @@ static void event_free(struct event *event) {
if (event->worker)
event->worker->event = NULL;
- assert(event->manager);
-
- if (udev_list_node_is_empty(&event->manager->events)) {
+ if (LIST_IS_EMPTY(event->manager->events)) {
/* only clean up the queue from the process that created it */
if (event->manager->pid == getpid_cached()) {
r = unlink("/run/udev/queue");
@@ -620,13 +616,13 @@ static int event_queue_insert(Manager *manager, struct udev_device *dev) {
event->state = EVENT_QUEUED;
- if (udev_list_node_is_empty(&manager->events)) {
+ if (LIST_IS_EMPTY(manager->events)) {
r = touch("/run/udev/queue");
if (r < 0)
log_warning_errno(r, "could not touch /run/udev/queue: %m");
}
- udev_list_node_append(&event->node, &manager->events);
+ LIST_APPEND(event, manager->events, event);
return 0;
}
@@ -648,13 +644,11 @@ static void manager_kill_workers(Manager *manager) {
/* lookup event for identical, parent, child device */
static bool is_devpath_busy(Manager *manager, struct event *event) {
- struct udev_list_node *loop;
+ struct event *loop_event;
size_t common;
/* check if queue contains events we depend on */
- udev_list_node_foreach(loop, &manager->events) {
- struct event *loop_event = node_to_event(loop);
-
+ LIST_FOREACH(event, loop_event, manager->events) {
/* we already found a later event, earlier can not block us, no need to check again */
if (loop_event->seqnum < event->delaying_seqnum)
continue;
@@ -783,12 +777,12 @@ static void manager_reload(Manager *manager) {
}
static void event_queue_start(Manager *manager) {
- struct udev_list_node *loop;
+ struct event *event;
usec_t usec;
assert(manager);
- if (udev_list_node_is_empty(&manager->events) ||
+ if (LIST_IS_EMPTY(manager->events) ||
manager->exit || manager->stop_exec_queue)
return;
@@ -811,9 +805,7 @@ static void event_queue_start(Manager *manager) {
return;
}
- udev_list_node_foreach(loop, &manager->events) {
- struct event *event = node_to_event(loop);
-
+ LIST_FOREACH(event,event,manager->events) {
if (event->state != EVENT_QUEUED)
continue;
@@ -826,11 +818,9 @@ static void event_queue_start(Manager *manager) {
}
static void event_queue_cleanup(Manager *manager, enum event_state match_type) {
- struct udev_list_node *loop, *tmp;
-
- udev_list_node_foreach_safe(loop, tmp, &manager->events) {
- struct event *event = node_to_event(loop);
+ struct event *event, *tmp;
+ LIST_FOREACH_SAFE(event, event, tmp, manager->events) {
if (match_type != EVENT_UNDEF && match_type != event->state)
continue;
@@ -1247,7 +1237,7 @@ static int on_post(sd_event_source *s, void *userdata) {
assert(manager);
- if (udev_list_node_is_empty(&manager->events)) {
+ if (LIST_IS_EMPTY(manager->events)) {
/* no pending events */
if (!hashmap_isempty(manager->workers)) {
/* there are idle workers */
@@ -1532,7 +1522,7 @@ static int manager_new(Manager **ret, int fd_ctrl, int fd_uevent, const char *cg
if (!manager->rules)
return log_error_errno(ENOMEM, "error reading rules");
- udev_list_node_init(&manager->events);
+ LIST_HEAD_INIT(manager->events);
udev_list_init(manager->udev, &manager->properties, true);
manager->cgroup = cgroup;