compel: Add recv fd helper

The same for libcompel.so user.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Pavel Emelyanov 2017-03-06 21:38:29 +03:00 committed by Andrei Vagin
parent 6794c8c2a9
commit a5752133c7
2 changed files with 12 additions and 0 deletions

View file

@ -2,4 +2,5 @@
#define __COMPEL_INFECT_UTIL_H__
struct parasite_ctl;
extern int compel_util_send_fd(struct parasite_ctl *ctl, int fd);
extern int compel_util_recv_fd(struct parasite_ctl *ctl, int *pfd);
#endif

View file

@ -19,3 +19,14 @@ int compel_util_send_fd(struct parasite_ctl *ctl, int fd)
return 0;
}
int compel_util_recv_fd(struct parasite_ctl *ctl, int *pfd)
{
int sk;
sk = compel_rpc_sock(ctl);
if ((*pfd = recv_fd(sk)) < 0) {
pr_perror("Can't send file descriptor");
return -1;
}
return 0;
}