chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sd-event: fix typo
[elogind.git]
/
src
/
udev
/
udev-ctrl.c
diff --git
a/src/udev/udev-ctrl.c
b/src/udev/udev-ctrl.c
index a235912ffb5eeb48822c3c3ae16f760ed755b89e..c0c5981db8c5a3a1e9619bdaa770d8afeaa9973c 100644
(file)
--- a/
src/udev/udev-ctrl.c
+++ b/
src/udev/udev-ctrl.c
@@
-10,13
+10,11
@@
*/
#include <errno.h>
*/
#include <errno.h>
-#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/socket.h>
#include <sys/un.h>
@@
-70,11
+68,12
@@
struct udev_ctrl_connection {
int sock;
};
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;
struct udev_ctrl *uctrl;
+ const int on = 1;
+ int r;
- uctrl =
calloc(1, sizeof(struct udev_ctrl)
);
+ uctrl =
new0(struct udev_ctrl, 1
);
if (uctrl == NULL)
return NULL;
uctrl->refcount = 1;
if (uctrl == NULL)
return NULL;
uctrl->refcount = 1;
@@
-83,7
+82,7
@@
struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd)
if (fd < 0) {
uctrl->sock = socket(AF_LOCAL, SOCK_SEQPACKET|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
if (uctrl->sock < 0) {
if (fd < 0) {
uctrl->sock = socket(AF_LOCAL, SOCK_SEQPACKET|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
if (uctrl->sock < 0) {
- log_error
("error getting socket: %m\n
");
+ log_error
_errno(errno, "error getting socket: %m
");
udev_ctrl_unref(uctrl);
return NULL;
}
udev_ctrl_unref(uctrl);
return NULL;
}
@@
-91,20
+90,21
@@
struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd)
uctrl->bound = true;
uctrl->sock = fd;
}
uctrl->bound = true;
uctrl->sock = fd;
}
+ r = setsockopt(uctrl->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
+ if (r < 0)
+ log_warning_errno(errno, "could not set SO_PASSCRED: %m");
uctrl->saddr.sun_family = AF_LOCAL;
uctrl->saddr.sun_family = AF_LOCAL;
-
util_
strscpy(uctrl->saddr.sun_path, sizeof(uctrl->saddr.sun_path), "/run/udev/control");
+ strscpy(uctrl->saddr.sun_path, sizeof(uctrl->saddr.sun_path), "/run/udev/control");
uctrl->addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(uctrl->saddr.sun_path);
return uctrl;
}
uctrl->addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(uctrl->saddr.sun_path);
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);
}
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) {
int err;
if (!uctrl->bound) {
@@
-116,14
+116,14
@@
int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl)
if (err < 0) {
err = -errno;
if (err < 0) {
err = -errno;
- log_error
("bind failed: %m\n
");
+ log_error
_errno(errno, "bind failed: %m
");
return err;
}
err = listen(uctrl->sock, 0);
if (err < 0) {
err = -errno;
return err;
}
err = listen(uctrl->sock, 0);
if (err < 0) {
err = -errno;
- log_error
("listen failed: %m\n
");
+ log_error
_errno(errno, "listen failed: %m
");
return err;
}
return err;
}
@@
-133,21
+133,18
@@
int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl)
return 0;
}
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;
}
return uctrl->udev;
}
-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;
}
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--;
if (uctrl == NULL)
return NULL;
uctrl->refcount--;
@@
-159,8
+156,7
@@
struct udev_ctrl *udev_ctrl_unref(struct udev_ctrl *uctrl)
return NULL;
}
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)
if (uctrl == NULL)
return 0;
if (uctrl->cleanup_socket)
@@
-168,21
+164,19
@@
int udev_ctrl_cleanup(struct udev_ctrl *uctrl)
return 0;
}
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;
}
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 udev_ctrl_connection *conn;
- struct ucred ucred;
- socklen_t slen;
+ struct ucred ucred = {};
const int on = 1;
const int on = 1;
+ int r;
- conn =
calloc(1, sizeof(struct udev_ctrl_connection)
);
+ conn =
new(struct udev_ctrl_connection, 1
);
if (conn == NULL)
return NULL;
conn->refcount = 1;
if (conn == NULL)
return NULL;
conn->refcount = 1;
@@
-191,23
+185,26
@@
struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl)
conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK);
if (conn->sock < 0) {
if (errno != EINTR)
conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK);
if (conn->sock < 0) {
if (errno != EINTR)
- log_error
("unable to receive ctrl connection: %m\n
");
+ log_error
_errno(errno, "unable to receive ctrl connection: %m
");
goto err;
}
/* check peer credential of connection */
goto err;
}
/* check peer credential of connection */
-
slen = sizeof(
ucred);
- if (
getsockopt(conn->sock, SOL_SOCKET, SO_PEERCRED, &ucred, &slen)
< 0) {
- log_error
("unable to receive credentials of ctrl connection: %m\n
");
+
r = getpeercred(conn->sock, &
ucred);
+ if (
r
< 0) {
+ log_error
_errno(r, "unable to receive credentials of ctrl connection: %m
");
goto err;
}
if (ucred.uid > 0) {
goto err;
}
if (ucred.uid > 0) {
- log_error("sender uid=
%i, message ignored\n
", ucred.uid);
+ log_error("sender uid=
"UID_FMT", message ignored
", ucred.uid);
goto err;
}
/* enable receiving of the sender credentials in the messages */
goto err;
}
/* enable receiving of the sender credentials in the messages */
- setsockopt(conn->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
+ r = setsockopt(conn->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
+ if (r < 0)
+ log_warning_errno(errno, "could not set SO_PASSCRED: %m");
+
udev_ctrl_ref(uctrl);
return conn;
err:
udev_ctrl_ref(uctrl);
return conn;
err:
@@
-217,16
+214,14
@@
err:
return NULL;
}
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;
}
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--;
if (conn == NULL)
return NULL;
conn->refcount--;
@@
-239,18
+234,17
@@
struct udev_ctrl_connection *udev_ctrl_connection_unref(struct udev_ctrl_connect
return NULL;
}
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;
struct udev_ctrl_msg_wire ctrl_msg_wire;
int err = 0;
- mem
set(&ctrl_msg_wire, 0x00
, sizeof(struct udev_ctrl_msg_wire));
+ mem
zero(&ctrl_msg_wire
, sizeof(struct udev_ctrl_msg_wire));
strcpy(ctrl_msg_wire.version, "udev-" VERSION);
ctrl_msg_wire.magic = UDEV_CTRL_MAGIC;
ctrl_msg_wire.type = type;
if (buf != NULL)
strcpy(ctrl_msg_wire.version, "udev-" VERSION);
ctrl_msg_wire.magic = UDEV_CTRL_MAGIC;
ctrl_msg_wire.type = type;
if (buf != NULL)
-
util_
strscpy(ctrl_msg_wire.buf, sizeof(ctrl_msg_wire.buf), buf);
+ strscpy(ctrl_msg_wire.buf, sizeof(ctrl_msg_wire.buf), buf);
else
ctrl_msg_wire.intval = intval;
else
ctrl_msg_wire.intval = intval;
@@
-273,7
+267,7
@@
static int ctrl_send(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, int
pfd[0].fd = uctrl->sock;
pfd[0].events = POLLIN;
pfd[0].fd = uctrl->sock;
pfd[0].events = POLLIN;
- r = poll(pfd, 1, timeout *
1000
);
+ r = poll(pfd, 1, timeout *
MSEC_PER_SEC
);
if (r < 0) {
if (errno == EINTR)
continue;
if (r < 0) {
if (errno == EINTR)
continue;
@@
-294,57
+288,53
@@
out:
return err;
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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 udev_ctrl_msg *uctrl_msg;
ssize_t size;
- struct msghdr smsg;
struct cmsghdr *cmsg;
struct iovec iov;
struct cmsghdr *cmsg;
struct iovec iov;
- struct ucred *cred;
char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
+ struct msghdr smsg = {
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
+ .msg_control = cred_msg,
+ .msg_controllen = sizeof(cred_msg),
+ };
+ struct ucred *cred;
- uctrl_msg =
calloc(1, sizeof(struct udev_ctrl_msg)
);
+ uctrl_msg =
new0(struct udev_ctrl_msg, 1
);
if (uctrl_msg == NULL)
return NULL;
uctrl_msg->refcount = 1;
if (uctrl_msg == NULL)
return NULL;
uctrl_msg->refcount = 1;
@@
-352,7
+342,7
@@
struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn)
udev_ctrl_connection_ref(conn);
/* wait for the incoming message */
udev_ctrl_connection_ref(conn);
/* wait for the incoming message */
- for(;;) {
+ for
(;;) {
struct pollfd pfd[1];
int r;
struct pollfd pfd[1];
int r;
@@
-365,11
+355,11
@@
struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn)
continue;
goto err;
} else if (r == 0) {
continue;
goto err;
} else if (r == 0) {
- log_error("timeout waiting for ctrl message
\n
");
+ log_error("timeout waiting for ctrl message");
goto err;
} else {
if (!(pfd[0].revents & POLLIN)) {
goto err;
} else {
if (!(pfd[0].revents & POLLIN)) {
- log_error
("ctrl connection error: %m\n
");
+ log_error
_errno(errno, "ctrl connection error: %m
");
goto err;
}
}
goto err;
}
}
@@
-379,31
+369,30
@@
struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn)
iov.iov_base = &uctrl_msg->ctrl_msg_wire;
iov.iov_len = sizeof(struct udev_ctrl_msg_wire);
iov.iov_base = &uctrl_msg->ctrl_msg_wire;
iov.iov_len = sizeof(struct udev_ctrl_msg_wire);
- memset(&smsg, 0x00, sizeof(struct msghdr));
- smsg.msg_iov = &iov;
- smsg.msg_iovlen = 1;
- smsg.msg_control = cred_msg;
- smsg.msg_controllen = sizeof(cred_msg);
+
size = recvmsg(conn->sock, &smsg, 0);
if (size < 0) {
size = recvmsg(conn->sock, &smsg, 0);
if (size < 0) {
- log_error
("unable to receive ctrl message: %m\n
");
+ log_error
_errno(errno, "unable to receive ctrl message: %m
");
goto err;
}
goto err;
}
+
+ cmsg_close_all(&smsg);
+
cmsg = CMSG_FIRSTHDR(&smsg);
cred = (struct ucred *) CMSG_DATA(cmsg);
if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) {
cmsg = CMSG_FIRSTHDR(&smsg);
cred = (struct ucred *) CMSG_DATA(cmsg);
if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) {
- log_error("no sender credentials received, message ignored
\n
");
+ log_error("no sender credentials received, message ignored");
goto err;
}
if (cred->uid != 0) {
goto err;
}
if (cred->uid != 0) {
- log_error("sender uid=
%i, message ignored\n
", cred->uid);
+ log_error("sender uid=
"UID_FMT", message ignored
", cred->uid);
goto err;
}
if (uctrl_msg->ctrl_msg_wire.magic != UDEV_CTRL_MAGIC) {
goto err;
}
if (uctrl_msg->ctrl_msg_wire.magic != UDEV_CTRL_MAGIC) {
- log_error("message magic 0x%08x doesn't match, ignore it
\n
", uctrl_msg->ctrl_msg_wire.magic);
+ log_error("message magic 0x%08x doesn't match, ignore it", uctrl_msg->ctrl_msg_wire.magic);
goto err;
}
goto err;
}
@@
-413,16
+402,7
@@
err:
return NULL;
}
return NULL;
}
-struct udev_ctrl_msg *udev_ctrl_msg_ref(struct udev_ctrl_msg *ctrl_msg)
-{
- if (ctrl_msg == NULL)
- return NULL;
- ctrl_msg->refcount++;
- return ctrl_msg;
-}
-
-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--;
if (ctrl_msg == NULL)
return NULL;
ctrl_msg->refcount--;
@@
-433,57
+413,49
@@
struct udev_ctrl_msg *udev_ctrl_msg_unref(struct udev_ctrl_msg *ctrl_msg)
return NULL;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
if (ctrl_msg->ctrl_msg_wire.type == UDEV_CTRL_EXIT)
return 1;
return -1;