From 7d68eb1bdfd430760fa2759d1d99b2654ffa0169 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 29 Aug 2018 16:03:45 +0900 Subject: [PATCH] udev-ctrl: move prototypes of udev_ctrl_*() to udev-ctrl.h --- src/udev/meson.build | 1 + src/udev/udev-ctrl.c | 3 ++- src/udev/udev-ctrl.h | 41 ++++++++++++++++++++++++++++++++++++++ src/udev/udev.h | 35 -------------------------------- src/udev/udevadm-control.c | 4 +++- src/udev/udevadm-settle.c | 4 +++- src/udev/udevd.c | 1 + 7 files changed, 51 insertions(+), 38 deletions(-) create mode 100644 src/udev/udev-ctrl.h diff --git a/src/udev/meson.build b/src/udev/meson.build index 0b02d838ca..726bae585e 100644 --- a/src/udev/meson.build +++ b/src/udev/meson.build @@ -20,6 +20,7 @@ systemd_udevd_sources = files('udevd.c') libudev_core_sources = ''' udev.h udev-ctrl.c + udev-ctrl.h udev-event.c udev-node.c udev-node.h diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c index a9b19051bf..64024100fe 100644 --- a/src/udev/udev-ctrl.c +++ b/src/udev/udev-ctrl.c @@ -21,7 +21,8 @@ #include "fd-util.h" #include "format-util.h" #include "socket-util.h" -#include "udev.h" +#include "strxcpyx.h" +#include "udev-ctrl.h" /* wire protocol magic must match */ #define UDEV_CTRL_MAGIC 0xdead1dea diff --git a/src/udev/udev-ctrl.h b/src/udev/udev-ctrl.h new file mode 100644 index 0000000000..87021cb880 --- /dev/null +++ b/src/udev/udev-ctrl.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +#pragma once + +#include "macro.h" + +struct udev_ctrl; +struct udev_ctrl *udev_ctrl_new(void); +struct udev_ctrl *udev_ctrl_new_from_fd(int fd); +int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl); +struct udev_ctrl *udev_ctrl_unref(struct udev_ctrl *uctrl); +int udev_ctrl_cleanup(struct udev_ctrl *uctrl); +int udev_ctrl_get_fd(struct udev_ctrl *uctrl); +int udev_ctrl_send_set_log_level(struct udev_ctrl *uctrl, int priority, int timeout); +int udev_ctrl_send_stop_exec_queue(struct udev_ctrl *uctrl, int timeout); +int udev_ctrl_send_start_exec_queue(struct udev_ctrl *uctrl, int timeout); +int udev_ctrl_send_reload(struct udev_ctrl *uctrl, int timeout); +int udev_ctrl_send_ping(struct udev_ctrl *uctrl, int timeout); +int udev_ctrl_send_exit(struct udev_ctrl *uctrl, int timeout); +int udev_ctrl_send_set_env(struct udev_ctrl *uctrl, const char *key, int timeout); +int udev_ctrl_send_set_children_max(struct udev_ctrl *uctrl, int count, int timeout); + +struct udev_ctrl_connection; +struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl); +struct udev_ctrl_connection *udev_ctrl_connection_ref(struct udev_ctrl_connection *conn); +struct udev_ctrl_connection *udev_ctrl_connection_unref(struct udev_ctrl_connection *conn); + +struct udev_ctrl_msg; +struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn); +struct udev_ctrl_msg *udev_ctrl_msg_unref(struct udev_ctrl_msg *ctrl_msg); +int udev_ctrl_get_set_log_level(struct udev_ctrl_msg *ctrl_msg); +int udev_ctrl_get_stop_exec_queue(struct udev_ctrl_msg *ctrl_msg); +int udev_ctrl_get_start_exec_queue(struct udev_ctrl_msg *ctrl_msg); +int udev_ctrl_get_reload(struct udev_ctrl_msg *ctrl_msg); +int udev_ctrl_get_ping(struct udev_ctrl_msg *ctrl_msg); +int udev_ctrl_get_exit(struct udev_ctrl_msg *ctrl_msg); +const char *udev_ctrl_get_set_env(struct udev_ctrl_msg *ctrl_msg); +int udev_ctrl_get_set_children_max(struct udev_ctrl_msg *ctrl_msg); + +DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_ctrl*, udev_ctrl_unref); +DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_ctrl_connection*, udev_ctrl_connection_unref); +DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_ctrl_msg*, udev_ctrl_msg_unref); diff --git a/src/udev/udev.h b/src/udev/udev.h index 2ba407d7a5..ac71a2c163 100644 --- a/src/udev/udev.h +++ b/src/udev/udev.h @@ -77,38 +77,6 @@ void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules); void udev_event_execute_run(struct udev_event *event, usec_t timeout_usec, usec_t timeout_warn_usec); -/* udev-ctrl.c */ -struct udev_ctrl; -struct udev_ctrl *udev_ctrl_new(void); -struct udev_ctrl *udev_ctrl_new_from_fd(int fd); -int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl); -struct udev_ctrl *udev_ctrl_unref(struct udev_ctrl *uctrl); -int udev_ctrl_cleanup(struct udev_ctrl *uctrl); -int udev_ctrl_get_fd(struct udev_ctrl *uctrl); -int udev_ctrl_send_set_log_level(struct udev_ctrl *uctrl, int priority, int timeout); -int udev_ctrl_send_stop_exec_queue(struct udev_ctrl *uctrl, int timeout); -int udev_ctrl_send_start_exec_queue(struct udev_ctrl *uctrl, int timeout); -int udev_ctrl_send_reload(struct udev_ctrl *uctrl, int timeout); -int udev_ctrl_send_ping(struct udev_ctrl *uctrl, int timeout); -int udev_ctrl_send_exit(struct udev_ctrl *uctrl, int timeout); -int udev_ctrl_send_set_env(struct udev_ctrl *uctrl, const char *key, int timeout); -int udev_ctrl_send_set_children_max(struct udev_ctrl *uctrl, int count, int timeout); -struct udev_ctrl_connection; -struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl); -struct udev_ctrl_connection *udev_ctrl_connection_ref(struct udev_ctrl_connection *conn); -struct udev_ctrl_connection *udev_ctrl_connection_unref(struct udev_ctrl_connection *conn); -struct udev_ctrl_msg; -struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn); -struct udev_ctrl_msg *udev_ctrl_msg_unref(struct udev_ctrl_msg *ctrl_msg); -int udev_ctrl_get_set_log_level(struct udev_ctrl_msg *ctrl_msg); -int udev_ctrl_get_stop_exec_queue(struct udev_ctrl_msg *ctrl_msg); -int udev_ctrl_get_start_exec_queue(struct udev_ctrl_msg *ctrl_msg); -int udev_ctrl_get_reload(struct udev_ctrl_msg *ctrl_msg); -int udev_ctrl_get_ping(struct udev_ctrl_msg *ctrl_msg); -int udev_ctrl_get_exit(struct udev_ctrl_msg *ctrl_msg); -const char *udev_ctrl_get_set_env(struct udev_ctrl_msg *ctrl_msg); -int udev_ctrl_get_set_children_max(struct udev_ctrl_msg *ctrl_msg); - /* built-in commands */ enum udev_builtin_cmd { #if HAVE_BLKID @@ -169,6 +137,3 @@ int udev_builtin_hwdb_lookup(struct udev_device *dev, const char *prefix, const /* Cleanup functions */ DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_event*, udev_event_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_rules*, udev_rules_unref); -DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_ctrl*, udev_ctrl_unref); -DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_ctrl_connection*, udev_ctrl_connection_unref); -DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_ctrl_msg*, udev_ctrl_msg_unref); diff --git a/src/udev/udevadm-control.c b/src/udev/udevadm-control.c index 3125a18088..22ac4962ed 100644 --- a/src/udev/udevadm-control.c +++ b/src/udev/udevadm-control.c @@ -19,11 +19,13 @@ #include #include +#include "libudev-private.h" #include "parse-util.h" #include "process-util.h" #include "time-util.h" -#include "udev.h" #include "udevadm.h" +#include "udev-ctrl.h" +#include "util.h" static int help(void) { printf("%s control OPTION\n\n" diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c index 7e02275ba4..6960324516 100644 --- a/src/udev/udevadm-settle.c +++ b/src/udev/udevadm-settle.c @@ -13,9 +13,11 @@ #include #include +#include "libudev-private.h" #include "time-util.h" #include "udevadm.h" -#include "udev.h" +#include "udev-ctrl.h" +#include "util.h" static usec_t arg_timeout = 120 * USEC_PER_SEC; static const char *arg_exists = NULL; diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 3259d45c10..8f8a2fcaa8 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -52,6 +52,7 @@ #include "socket-util.h" #include "string-util.h" #include "terminal-util.h" +#include "udev-ctrl.h" #include "udev-util.h" #include "udev-watch.h" #include "udev.h"