2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-09-03 07:45:17 +00:00

util-net: Make send/recv fds carry fd flags in message

The flags are only one bit in the kernel (close-on-exec, all the rest are not per-fd, but per-file),
but for simplicity I save it in a char field.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov
2012-04-10 18:36:13 +04:00
parent e8cdf57f40
commit 30224abcb6
4 changed files with 32 additions and 15 deletions

View File

@@ -25,22 +25,23 @@ struct scm_fdset {
struct msghdr hdr;
struct iovec iov;
char msg_buf[CR_SCM_MSG_SIZE];
int msg; /* We are to send at least one byte */
char msg[CR_SCM_MAX_FD];
};
extern int send_fds(int sock, struct sockaddr_un *saddr, int saddr_len, int *fds, int nr_fds);
extern int recv_fds(int sock, int *fds, int nr_fds);
extern int send_fds(int sock, struct sockaddr_un *saddr, int saddr_len,
int *fds, int nr_fds, bool with_flags);
extern int recv_fds(int sock, int *fds, int nr_fds, char *flags);
static inline int send_fd(int sock, struct sockaddr_un *saddr, int saddr_len, int fd)
{
return send_fds(sock, saddr, saddr_len, &fd, 1);
return send_fds(sock, saddr, saddr_len, &fd, 1, false);
}
static inline int recv_fd(int sock)
{
int fd, ret;
ret = recv_fds(sock, &fd, 1);
ret = recv_fds(sock, &fd, 1, NULL);
if (ret)
return -1;