summaryrefslogtreecommitdiff
path: root/src/udev/udev-ctrl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/udev/udev-ctrl.c')
-rw-r--r--src/udev/udev-ctrl.c90
1 files changed, 30 insertions, 60 deletions
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 74bbd3a99e..6fb5bb4a7a 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -70,8 +70,7 @@ struct udev_ctrl_connection {
int sock;
};
-struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd)
-{
+struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd) {
struct udev_ctrl *uctrl;
const int on = 1;
@@ -100,13 +99,11 @@ struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd)
return uctrl;
}
-struct udev_ctrl *udev_ctrl_new(struct udev *udev)
-{
+struct udev_ctrl *udev_ctrl_new(struct udev *udev) {
return udev_ctrl_new_from_fd(udev, -1);
}
-int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl)
-{
+int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl) {
int err;
if (!uctrl->bound) {
@@ -135,21 +132,18 @@ int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl)
return 0;
}
-struct udev *udev_ctrl_get_udev(struct udev_ctrl *uctrl)
-{
+struct udev *udev_ctrl_get_udev(struct udev_ctrl *uctrl) {
return uctrl->udev;
}
-static struct udev_ctrl *udev_ctrl_ref(struct udev_ctrl *uctrl)
-{
+static struct udev_ctrl *udev_ctrl_ref(struct udev_ctrl *uctrl) {
if (uctrl == NULL)
return NULL;
uctrl->refcount++;
return uctrl;
}
-struct udev_ctrl *udev_ctrl_unref(struct udev_ctrl *uctrl)
-{
+struct udev_ctrl *udev_ctrl_unref(struct udev_ctrl *uctrl) {
if (uctrl == NULL)
return NULL;
uctrl->refcount--;
@@ -161,8 +155,7 @@ struct udev_ctrl *udev_ctrl_unref(struct udev_ctrl *uctrl)
return NULL;
}
-int udev_ctrl_cleanup(struct udev_ctrl *uctrl)
-{
+int udev_ctrl_cleanup(struct udev_ctrl *uctrl) {
if (uctrl == NULL)
return 0;
if (uctrl->cleanup_socket)
@@ -170,15 +163,13 @@ int udev_ctrl_cleanup(struct udev_ctrl *uctrl)
return 0;
}
-int udev_ctrl_get_fd(struct udev_ctrl *uctrl)
-{
+int udev_ctrl_get_fd(struct udev_ctrl *uctrl) {
if (uctrl == NULL)
return -EINVAL;
return uctrl->sock;
}
-struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl)
-{
+struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
struct udev_ctrl_connection *conn;
struct ucred ucred = {};
const int on = 1;
@@ -219,16 +210,14 @@ err:
return NULL;
}
-struct udev_ctrl_connection *udev_ctrl_connection_ref(struct udev_ctrl_connection *conn)
-{
+struct udev_ctrl_connection *udev_ctrl_connection_ref(struct udev_ctrl_connection *conn) {
if (conn == NULL)
return NULL;
conn->refcount++;
return conn;
}
-struct udev_ctrl_connection *udev_ctrl_connection_unref(struct udev_ctrl_connection *conn)
-{
+struct udev_ctrl_connection *udev_ctrl_connection_unref(struct udev_ctrl_connection *conn) {
if (conn == NULL)
return NULL;
conn->refcount--;
@@ -241,8 +230,7 @@ struct udev_ctrl_connection *udev_ctrl_connection_unref(struct udev_ctrl_connect
return NULL;
}
-static int ctrl_send(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, int intval, const char *buf, int timeout)
-{
+static int ctrl_send(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, int intval, const char *buf, int timeout) {
struct udev_ctrl_msg_wire ctrl_msg_wire;
int err = 0;
@@ -296,48 +284,39 @@ out:
return err;
}
-int udev_ctrl_send_set_log_level(struct udev_ctrl *uctrl, int priority, int timeout)
-{
+int udev_ctrl_send_set_log_level(struct udev_ctrl *uctrl, int priority, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_SET_LOG_LEVEL, priority, NULL, timeout);
}
-int udev_ctrl_send_stop_exec_queue(struct udev_ctrl *uctrl, int timeout)
-{
+int udev_ctrl_send_stop_exec_queue(struct udev_ctrl *uctrl, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_STOP_EXEC_QUEUE, 0, NULL, timeout);
}
-int udev_ctrl_send_start_exec_queue(struct udev_ctrl *uctrl, int timeout)
-{
+int udev_ctrl_send_start_exec_queue(struct udev_ctrl *uctrl, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_START_EXEC_QUEUE, 0, NULL, timeout);
}
-int udev_ctrl_send_reload(struct udev_ctrl *uctrl, int timeout)
-{
+int udev_ctrl_send_reload(struct udev_ctrl *uctrl, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_RELOAD, 0, NULL, timeout);
}
-int udev_ctrl_send_set_env(struct udev_ctrl *uctrl, const char *key, int timeout)
-{
+int udev_ctrl_send_set_env(struct udev_ctrl *uctrl, const char *key, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_SET_ENV, 0, key, timeout);
}
-int udev_ctrl_send_set_children_max(struct udev_ctrl *uctrl, int count, int timeout)
-{
+int udev_ctrl_send_set_children_max(struct udev_ctrl *uctrl, int count, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_SET_CHILDREN_MAX, count, NULL, timeout);
}
-int udev_ctrl_send_ping(struct udev_ctrl *uctrl, int timeout)
-{
+int udev_ctrl_send_ping(struct udev_ctrl *uctrl, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_PING, 0, NULL, timeout);
}
-int udev_ctrl_send_exit(struct udev_ctrl *uctrl, int timeout)
-{
+int udev_ctrl_send_exit(struct udev_ctrl *uctrl, int timeout) {
return ctrl_send(uctrl, UDEV_CTRL_EXIT, 0, NULL, timeout);
}
-struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn)
-{
+struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) {
struct udev_ctrl_msg *uctrl_msg;
ssize_t size;
struct cmsghdr *cmsg;
@@ -416,8 +395,7 @@ err:
return NULL;
}
-struct udev_ctrl_msg *udev_ctrl_msg_unref(struct udev_ctrl_msg *ctrl_msg)
-{
+struct udev_ctrl_msg *udev_ctrl_msg_unref(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg == NULL)
return NULL;
ctrl_msg->refcount--;
@@ -428,57 +406,49 @@ struct udev_ctrl_msg *udev_ctrl_msg_unref(struct udev_ctrl_msg *ctrl_msg)
return NULL;
}
-int udev_ctrl_get_set_log_level(struct udev_ctrl_msg *ctrl_msg)
-{
+int udev_ctrl_get_set_log_level(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_SET_LOG_LEVEL)
return ctrl_msg->ctrl_msg_wire.intval;
return -1;
}
-int udev_ctrl_get_stop_exec_queue(struct udev_ctrl_msg *ctrl_msg)
-{
+int udev_ctrl_get_stop_exec_queue(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_STOP_EXEC_QUEUE)
return 1;
return -1;
}
-int udev_ctrl_get_start_exec_queue(struct udev_ctrl_msg *ctrl_msg)
-{
+int udev_ctrl_get_start_exec_queue(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_START_EXEC_QUEUE)
return 1;
return -1;
}
-int udev_ctrl_get_reload(struct udev_ctrl_msg *ctrl_msg)
-{
+int udev_ctrl_get_reload(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_RELOAD)
return 1;
return -1;
}
-const char *udev_ctrl_get_set_env(struct udev_ctrl_msg *ctrl_msg)
-{
+const char *udev_ctrl_get_set_env(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_SET_ENV)
return ctrl_msg->ctrl_msg_wire.buf;
return NULL;
}
-int udev_ctrl_get_set_children_max(struct udev_ctrl_msg *ctrl_msg)
-{
+int udev_ctrl_get_set_children_max(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_SET_CHILDREN_MAX)
return ctrl_msg->ctrl_msg_wire.intval;
return -1;
}
-int udev_ctrl_get_ping(struct udev_ctrl_msg *ctrl_msg)
-{
+int udev_ctrl_get_ping(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_PING)
return 1;
return -1;
}
-int udev_ctrl_get_exit(struct udev_ctrl_msg *ctrl_msg)
-{
+int udev_ctrl_get_exit(struct udev_ctrl_msg *ctrl_msg) {
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_EXIT)
return 1;
return -1;