[2/3] compel: Add recv fd helper

Submitted by Pavel Emelianov on March 6, 2017, 4:40 p.m.

Details

Message ID 58BD90FA.8000101@virtuozzo.com
State New
Series "compel: Turn FDs plugin on"
Headers show

Commit Message

Pavel Emelianov March 6, 2017, 4:40 p.m.
The same for libcompel.so user.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 compel/include/uapi/infect-util.h |  1 +
 compel/src/lib/infect-util.c      | 11 +++++++++++
 2 files changed, 12 insertions(+)

Patch hide | download patch | download mbox

diff --git a/compel/include/uapi/infect-util.h b/compel/include/uapi/infect-util.h
index bd2010c..7307ba5 100644
--- a/compel/include/uapi/infect-util.h
+++ b/compel/include/uapi/infect-util.h
@@ -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
diff --git a/compel/src/lib/infect-util.c b/compel/src/lib/infect-util.c
index b8f20bf..5d6d0dd 100644
--- a/compel/src/lib/infect-util.c
+++ b/compel/src/lib/infect-util.c
@@ -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;
+}