lib/waiter: Add timeout waiters
[petitboot] / discover / user-event.c
index db12bd14135b3d84d4ea1d79bd38f5f36abb43fe..013357b49bff6340f671af561d0cb25ec12a18fc 100644 (file)
@@ -42,22 +42,32 @@ struct user_event {
        int socket;
 };
 
+static const char *event_action_name(enum event_action action)
+{
+       switch (action) {
+       case EVENT_ACTION_ADD:
+               return "add";
+       case EVENT_ACTION_REMOVE:
+               return "remove";
+       case EVENT_ACTION_CONF:
+               return "conf";
+       default:
+               break;
+       }
+
+       return "unknown";
+}
+
 static void user_event_print_event(struct event __attribute__((unused)) *event)
 {
-       const char *action, *params[] = {
-               "name", "image", "args",
-               NULL,
-       };
        int i;
 
-       action = event->action == EVENT_ACTION_ADD ? "add" : "remove";
-
-       pb_log("user_event %s event:\n", action);
+       pb_log("user_event %s event:\n", event_action_name(event->action));
        pb_log("\tdevice: %s\n", event->device);
 
-       for (i = 0; params[i]; i++)
+       for (i = 0; i < event->n_params; i++)
                pb_log("\t%-12s => %s\n",
-                               params[i], event_get_param(event, params[i]));
+                       event->params[i].name, event->params[i].value);
 }
 
 static void user_event_handle_message(struct user_event *uev, char *buf,
@@ -148,7 +158,8 @@ struct user_event *user_event_init(struct waitset *waitset,
                        strerror(errno));
        }
 
-       waiter_register(waitset, uev->socket, WAIT_IN, user_event_process, uev);
+       waiter_register_io(waitset, uev->socket, WAIT_IN,
+                       user_event_process, uev);
 
        pb_log("%s: waiting on %s\n", __func__, PBOOT_USER_EVENT_SOCKET);