[CRIU] [PATCH 4/5] scm: Unweave fds mess
Cyrill Gorcunov
gorcunov at openvz.org
Tue Nov 15 01:42:59 PST 2016
Currently criu built with criu/pie-util-fd (which
is a symlink to criu/pie/util-fd) with same flags
as we use in general compel infection code. Moreover
the criu link with libcompel.a, so we get a problem
where send_fds/recv_fds are multiple defined. Lets
rather unweave this mess:
- drop criu/pie-util-fd.c completely
- move send_fd/recv_fd inliners into scm.h
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
compel/plugins/include/uapi/plugin-fds.h | 5 -----
compel/src/lib/infect.c | 9 +++++++++
criu/Makefile.crtools | 1 -
criu/include/util-pie.h | 20 --------------------
criu/pie-util-fd.c | 1 -
include/common/scm.h | 16 ++++++++++++++++
6 files changed, 25 insertions(+), 27 deletions(-)
delete mode 120000 criu/pie-util-fd.c
diff --git a/compel/plugins/include/uapi/plugin-fds.h b/compel/plugins/include/uapi/plugin-fds.h
index 6a96f768138b..4d2feedb3965 100644
--- a/compel/plugins/include/uapi/plugin-fds.h
+++ b/compel/plugins/include/uapi/plugin-fds.h
@@ -9,9 +9,4 @@
#include "common/scm.h"
-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, false);
-}
-
#endif /* __COMPEL_PLUGIN_FDS_H__ */
diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c
index d9fd05239b38..bfbe1631c139 100644
--- a/compel/src/lib/infect.c
+++ b/compel/src/lib/infect.c
@@ -27,6 +27,15 @@
#include "infect-priv.h"
#include "infect-util.h"
#include "rpc-pie-priv.h"
+#include "infect-util.h"
+
+#define __sys(foo) foo
+#define __memcpy memcpy
+
+#define SCM_FDSET_HAS_OPTS
+
+#include "common/scm.h"
+#include "common/scm-code.c"
#define UNIX_PATH_MAX (sizeof(struct sockaddr_un) - \
(size_t)((struct sockaddr_un *) 0)->sun_path)
diff --git a/criu/Makefile.crtools b/criu/Makefile.crtools
index b33728ca82e0..8c5b0ce081e1 100644
--- a/criu/Makefile.crtools
+++ b/criu/Makefile.crtools
@@ -47,7 +47,6 @@ obj-y += page-pipe.o
obj-y += pagemap.o
obj-y += page-xfer.o
obj-y += parasite-syscall.o
-obj-y += pie-util-fd.o
obj-y += pie-util.o
obj-y += pipes.o
obj-y += plugin.o
diff --git a/criu/include/util-pie.h b/criu/include/util-pie.h
index d2287201d6ea..3c81849f15a0 100644
--- a/criu/include/util-pie.h
+++ b/criu/include/util-pie.h
@@ -15,26 +15,6 @@
#include "common/scm.h"
-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, struct fd_opts *opts);
-
-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, false);
-}
-
-static inline int recv_fd(int sock)
-{
- int fd, ret;
-
- ret = recv_fds(sock, &fd, 1, NULL);
- if (ret)
- return -1;
-
- return fd;
-}
-
extern int open_detach_mount(char *dir);
#endif /* __CR_UTIL_NET_H__ */
diff --git a/criu/pie-util-fd.c b/criu/pie-util-fd.c
deleted file mode 120000
index 4af261ede48c..000000000000
--- a/criu/pie-util-fd.c
+++ /dev/null
@@ -1 +0,0 @@
-pie/util-fd.c
\ No newline at end of file
diff --git a/include/common/scm.h b/include/common/scm.h
index 144d96049a48..f7bc5e6f3c5e 100644
--- a/include/common/scm.h
+++ b/include/common/scm.h
@@ -52,4 +52,20 @@ extern int recv_fds(int sock, int *fds, int nr_fds, struct fd_opts *opts);
extern int recv_fds(int sock, int *fds, int nr_fds, char *opts);
#endif
+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, false);
+}
+
+static inline int recv_fd(int sock)
+{
+ int fd, ret;
+
+ ret = recv_fds(sock, &fd, 1, NULL);
+ if (ret)
+ return -1;
+
+ return fd;
+}
+
#endif
--
2.7.4
More information about the CRIU
mailing list