Browse Source

Regroup struct definitions on top

develop
Damien Goutte-Gattat 8 years ago
parent
commit
386fc420f8
  1. 28
      src/wait4pid.c

28
src/wait4pid.c

@ -31,9 +31,23 @@
#include <linux/connector.h>
#include <linux/cn_proc.h>
/* Netlink message to (un)register a proc events listener. */
struct __attribute__ ((__packed__)) cn_proc_op {
struct cn_msg msg;
enum proc_cn_mcast_op op;
};
/* Netlink message sent on a proc event. */
struct __attribute__ ((__packed__)) cn_proc_msg {
struct cn_msg msg;
struct proc_event evt;
};
int sock = 0;
int listener_set = 0;
static ssize_t
do_send(int sock, const void *buf, size_t len, int flags)
{
@ -63,11 +77,8 @@ static int
set_proc_listen(int sock, int enable)
{
struct nlmsghdr *hdr;
struct __attribute__ ((__packed__)) payload_t {
struct cn_msg msg;
enum proc_cn_mcast_op op;
} *payload;
char buf[NLMSG_SPACE(sizeof(struct payload_t))];
struct cn_proc_op *payload;
char buf[NLMSG_SPACE(sizeof(struct cn_proc_op))];
memset(buf, 0, sizeof(buf));
@ -77,7 +88,7 @@ set_proc_listen(int sock, int enable)
hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*payload));
hdr->nlmsg_pid = getpid();
payload = (struct payload_t *) NLMSG_DATA(hdr);
payload = (struct cn_proc_op *) NLMSG_DATA(hdr);
payload->msg.id.idx = CN_IDX_PROC;
payload->msg.id.val = CN_VAL_PROC;
payload->msg.len = sizeof(payload->op);
@ -127,11 +138,6 @@ wait4pid_init(void)
return 0;
}
struct __attribute__ ((__packed__)) cn_proc_msg {
struct cn_msg msg;
struct proc_event evt;
};
#ifdef HAVE_LINUX_FILTER_H
#include <linux/filter.h>

Loading…
Cancel
Save