[CRIU] [PATCH 3/5] compel: plugins,fds -- Unify prototypes

Cyrill Gorcunov gorcunov at openvz.org
Tue Nov 15 01:42:58 PST 2016


 - Declare send_fds, recv_fds in sch.h, these
   are prototypes used in both compel and criu
 - Drop old protos from plugin-fds.h uapi file
 - Drop old code from fds.c source

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 compel/plugins/fds/fds.c                 | 17 -----------------
 compel/plugins/include/uapi/plugin-fds.h | 25 +------------------------
 include/common/scm.h                     | 11 +++++++++++
 3 files changed, 12 insertions(+), 41 deletions(-)

diff --git a/compel/plugins/fds/fds.c b/compel/plugins/fds/fds.c
index 75249c0bdd17..a19c66287367 100644
--- a/compel/plugins/fds/fds.c
+++ b/compel/plugins/fds/fds.c
@@ -15,23 +15,6 @@
 #define __sys(foo)	sys_##foo
 #define __memcpy	std_memcpy
 
-#ifdef SCM_FDSET_HAS_OPTS
-#error "Spurious SCM_FDSET_HAS_OPTS"
-#endif
-
-#define SCM_FDSET_HAS_OPTS
-
-#include "common/scm.h"
 #include "common/scm-code.c"
 
-int fds_send(int *fds, int nr_fds)
-{
-	return 0; // fds_send_via(std_ctl_sock(), fds, nr_fds);
-}
-
-int fds_recv(int *fds, int nr_fds)
-{
-	return -1; //fds_recv_via(std_ctl_sock(), fds, nr_fds);
-}
-
 PLUGIN_REGISTER_DUMMY(fds)
diff --git a/compel/plugins/include/uapi/plugin-fds.h b/compel/plugins/include/uapi/plugin-fds.h
index 095ae687e7b7..6a96f768138b 100644
--- a/compel/plugins/include/uapi/plugin-fds.h
+++ b/compel/plugins/include/uapi/plugin-fds.h
@@ -5,32 +5,9 @@
 #ifndef __COMPEL_PLUGIN_FDS_H__
 #define __COMPEL_PLUGIN_FDS_H__
 
-#include <sys/socket.h>
 #include <sys/un.h>
 
-extern int recv_fds(int sock, int *fds, int nr_fds, struct fd_opts *opts);
-
-extern int fds_send(int *fds, int nr_fds);
-extern int fds_recv(int *fds, int nr_fds);
-
-static inline int fds_send_one(int fd)
-{
-	return fds_send(&fd, 1);
-}
-
-static inline int fds_recv_one(void)
-{
-	int fd, ret;
-
-	ret = fds_recv(&fd, 1);
-	if (ret)
-		fd = -1;
-
-	return fd;
-}
-
-extern int send_fds(int sock, struct sockaddr_un *saddr, int len,
-		    int *fds, int nr_fds, bool with_flags);
+#include "common/scm.h"
 
 static inline int send_fd(int sock, struct sockaddr_un *saddr, int saddr_len, int fd)
 {
diff --git a/include/common/scm.h b/include/common/scm.h
index e68aa2da6ea9..144d96049a48 100644
--- a/include/common/scm.h
+++ b/include/common/scm.h
@@ -2,6 +2,8 @@
 #define __COMMON_SCM_H__
 
 #include <stdint.h>
+#include <stdbool.h>
+#include <sys/un.h>
 
 /*
  * Because of kernel doing kmalloc for user data passed
@@ -41,4 +43,13 @@ struct scm_fdset {
 #define F_GETOWNER_UIDS	17
 #endif
 
+extern int send_fds(int sock, struct sockaddr_un *saddr, int len,
+		    int *fds, int nr_fds, bool with_flags);
+
+#ifdef SCM_FDSET_HAS_OPTS
+extern int recv_fds(int sock, int *fds, int nr_fds, struct fd_opts *opts);
+#else
+extern int recv_fds(int sock, int *fds, int nr_fds, char *opts);
+#endif
+
 #endif
-- 
2.7.4



More information about the CRIU mailing list