[CRIU] [PATCH 08/78] scm: Move scm_fdset structure into include/common

Cyrill Gorcunov gorcunov at openvz.org
Mon Nov 7 08:35:53 PST 2016


From: Pavel Emelyanov <xemul at virtuozzo.com>

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/include/util-pie.h | 28 ++--------------------------
 criu/pie/util-fd.c      |  2 --
 include/common/scm.h    | 44 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 28 deletions(-)
 create mode 100644 include/common/scm.h

diff --git a/criu/include/util-pie.h b/criu/include/util-pie.h
index a14353361eb0..d2287201d6ea 100644
--- a/criu/include/util-pie.h
+++ b/criu/include/util-pie.h
@@ -11,33 +11,9 @@
 #define SO_PEEK_OFF            42
 #endif
 
-/*
- * Because of kernel doing kmalloc for user data passed
- * in SCM messages, and there is kernel's SCM_MAX_FD as a limit
- * for descriptors passed at once we're trying to reduce
- * the pressue on kernel memory manager and use predefined
- * known to work well size of the message buffer.
- */
-#define CR_SCM_MSG_SIZE		(1024)
-#define CR_SCM_MAX_FD		(252)
+#define SCM_FDSET_HAS_OPTS
 
-struct fd_opts {
-	char flags;
-	struct {
-		u32 uid;
-		u32 euid;
-		u32 signum;
-		u32 pid_type;
-		u32 pid;
-	} fown;
-};
-
-struct scm_fdset {
-	struct msghdr	hdr;
-	struct iovec	iov;
-	char		msg_buf[CR_SCM_MSG_SIZE];
-	struct fd_opts	opts[CR_SCM_MAX_FD];
-};
+#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);
diff --git a/criu/pie/util-fd.c b/criu/pie/util-fd.c
index c29d180c8f19..8e4b596a967a 100644
--- a/criu/pie/util-fd.c
+++ b/criu/pie/util-fd.c
@@ -23,6 +23,4 @@
 
 #include "common/bug.h"
 
-#define SCM_FDSET_HAS_OPTS
-
 #include "common/scm-code.c"
diff --git a/include/common/scm.h b/include/common/scm.h
new file mode 100644
index 000000000000..e68aa2da6ea9
--- /dev/null
+++ b/include/common/scm.h
@@ -0,0 +1,44 @@
+#ifndef __COMMON_SCM_H__
+#define __COMMON_SCM_H__
+
+#include <stdint.h>
+
+/*
+ * Because of kernel doing kmalloc for user data passed
+ * in SCM messages, and there is kernel's SCM_MAX_FD as a limit
+ * for descriptors passed at once we're trying to reduce
+ * the pressue on kernel memory manager and use predefined
+ * known to work well size of the message buffer.
+ */
+#define CR_SCM_MSG_SIZE		(1024)
+#define CR_SCM_MAX_FD		(252)
+
+#ifdef SCM_FDSET_HAS_OPTS
+struct fd_opts {
+	char flags;
+	struct {
+		uint32_t uid;
+		uint32_t euid;
+		uint32_t signum;
+		uint32_t pid_type;
+		uint32_t pid;
+	} fown;
+};
+#endif
+
+struct scm_fdset {
+	struct msghdr	hdr;
+	struct iovec	iov;
+	char		msg_buf[CR_SCM_MSG_SIZE];
+#ifdef SCM_FDSET_HAS_OPTS
+	struct fd_opts	opts[CR_SCM_MAX_FD];
+#else
+	char		dummy;
+#endif
+};
+
+#ifndef F_GETOWNER_UIDS
+#define F_GETOWNER_UIDS	17
+#endif
+
+#endif
-- 
2.7.4



More information about the CRIU mailing list