[CRIU] [PATCH 36/38] compel: Move into ptrace code

Cyrill Gorcunov gorcunov at openvz.org
Tue Oct 11 09:04:26 PDT 2016


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 compel/Makefile                   |  1 +
 compel/include/compel/ptrace.h    | 81 +++++++++++++++++++++++++++++++++++++++
 {criu => compel/src/lib}/ptrace.c | 17 +-------
 criu/Makefile.crtools             |  1 -
 criu/arch/aarch64/crtools.c       |  2 +-
 criu/arch/arm/crtools.c           |  2 +-
 criu/arch/ppc64/crtools.c         |  2 +-
 criu/arch/x86/crtools.c           |  2 +-
 criu/cr-check.c                   |  2 +-
 criu/cr-dump.c                    |  2 +-
 criu/cr-exec.c                    |  2 +-
 criu/cr-restore.c                 |  2 +-
 criu/include/ptrace.h             | 80 --------------------------------------
 criu/infect.c                     |  2 +-
 criu/parasite-syscall.c           |  2 +-
 criu/seccomp.c                    |  2 +-
 criu/seize.c                      |  2 +-
 17 files changed, 96 insertions(+), 108 deletions(-)
 create mode 100644 compel/include/compel/ptrace.h
 rename {criu => compel/src/lib}/ptrace.c (82%)
 delete mode 100644 criu/include/ptrace.h

diff --git a/compel/Makefile b/compel/Makefile
index 02e9840b144d..29c92d11c1a2 100644
--- a/compel/Makefile
+++ b/compel/Makefile
@@ -17,6 +17,7 @@ host-lib-y		+= src/lib/handle-elf.o
 
 lib-y			+= src/lib/argv.o
 lib-y			+= src/lib/compel.o
+lib-y			+= src/lib/ptrace.o
 
 lib-y			+= src/lib/log.o
 host-lib-y		+= src/lib/log.o
diff --git a/compel/include/compel/ptrace.h b/compel/include/compel/ptrace.h
new file mode 100644
index 000000000000..e9c362a30ac5
--- /dev/null
+++ b/compel/include/compel/ptrace.h
@@ -0,0 +1,81 @@
+#ifndef __CR_PTRACE_H__
+#define __CR_PTRACE_H__
+
+#include <linux/types.h>
+#include <sys/ptrace.h>
+#include <stdint.h>
+
+//#include "config.h"
+
+/* some constants for ptrace */
+#ifndef PTRACE_SEIZE
+# define PTRACE_SEIZE			0x4206
+#endif
+
+#ifndef PTRACE_O_SUSPEND_SECCOMP
+# define PTRACE_O_SUSPEND_SECCOMP	(1 << 21)
+#endif
+
+#ifndef PTRACE_INTERRUPT
+# define PTRACE_INTERRUPT		0x4207
+#endif
+
+#ifndef PTRACE_LISTEN
+# define PTRACE_LISTEN			0x4208
+#endif
+
+#ifndef PTRACE_PEEKSIGINFO
+# define PTRACE_PEEKSIGINFO		0x4209
+
+/* Read signals from a shared (process wide) queue */
+# define PTRACE_PEEKSIGINFO_SHARED	(1 << 0)
+#endif
+
+#ifndef CONFIG_HAS_PTRACE_PEEKSIGINFO
+struct ptrace_peeksiginfo_args {
+	uint64_t off;	/* from which siginfo to start */
+	uint32_t flags;
+	uint32_t nr;	/* how may siginfos to take */
+};
+#endif
+
+#ifndef PTRACE_GETREGSET
+# define PTRACE_GETREGSET		0x4204
+# define PTRACE_SETREGSET		0x4205
+#endif
+
+#ifndef PTRACE_GETSIGMASK
+# define PTRACE_GETSIGMASK		0x420a
+# define PTRACE_SETSIGMASK		0x420b
+#endif
+
+#ifndef PTRACE_SECCOMP_GET_FILTER
+#define PTRACE_SECCOMP_GET_FILTER	0x420c
+#endif
+
+#define PTRACE_SEIZE_DEVEL		0x80000000
+
+#define PTRACE_EVENT_FORK		1
+#define PTRACE_EVENT_VFORK		2
+#define PTRACE_EVENT_CLONE		3
+#define PTRACE_EVENT_EXEC		4
+#define PTRACE_EVENT_VFORK_DONE		5
+#define PTRACE_EVENT_EXIT		6
+#define PTRACE_EVENT_STOP		128
+
+#define PTRACE_O_TRACESYSGOOD		0x00000001
+#define PTRACE_O_TRACEFORK		0x00000002
+#define PTRACE_O_TRACEVFORK		0x00000004
+#define PTRACE_O_TRACECLONE		0x00000008
+#define PTRACE_O_TRACEEXEC		0x00000010
+#define PTRACE_O_TRACEVFORKDONE		0x00000020
+#define PTRACE_O_TRACEEXIT		0x00000040
+
+#define SI_EVENT(_si_code)		(((_si_code) & 0xFFFF) >> 8)
+
+extern int suspend_seccomp(pid_t pid);
+extern int ptrace_peek_area(pid_t pid, void *dst, void *addr, long bytes);
+extern int ptrace_poke_area(pid_t pid, void *src, void *addr, long bytes);
+extern int ptrace_swap_area(pid_t pid, void *dst, void *src, long bytes);
+
+#endif /* __CR_PTRACE_H__ */
diff --git a/criu/ptrace.c b/compel/src/lib/ptrace.c
similarity index 82%
rename from criu/ptrace.c
rename to compel/src/lib/ptrace.c
index 17171b99ef01..8f27984d1022 100644
--- a/criu/ptrace.c
+++ b/compel/src/lib/ptrace.c
@@ -1,27 +1,14 @@
-#include <stdlib.h>
 #include <stdio.h>
-#include <stdarg.h>
+#include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
-#include <stdbool.h>
-#include <limits.h>
-#include <signal.h>
 
 #include <sys/ptrace.h>
 #include <sys/types.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
 
-#include "compiler.h"
-#include "asm/types.h"
-#include "util.h"
 #include "ptrace.h"
-#include "pid.h"
-#include "proc_parse.h"
-#include "seccomp.h"
-#include "cr_options.h"
+#include "log.h"
 
 int suspend_seccomp(pid_t pid)
 {
diff --git a/criu/Makefile.crtools b/criu/Makefile.crtools
index c27faa9fecb1..ca10c235adee 100644
--- a/criu/Makefile.crtools
+++ b/criu/Makefile.crtools
@@ -60,7 +60,6 @@ obj-y			+= proc_parse.o
 obj-y			+= protobuf-desc.o
 obj-y			+= protobuf.o
 obj-y			+= pstree.o
-obj-y			+= ptrace.o
 obj-y			+= rbtree.o
 obj-y			+= rst-malloc.o
 obj-y			+= seccomp.o
diff --git a/criu/arch/aarch64/crtools.c b/criu/arch/aarch64/crtools.c
index 4492f2b913b6..4db1d9a897d9 100644
--- a/criu/arch/aarch64/crtools.c
+++ b/criu/arch/aarch64/crtools.c
@@ -6,7 +6,7 @@
 #include "asm/types.h"
 #include "asm/restorer.h"
 #include "compiler.h"
-#include "ptrace.h"
+#include "compel/ptrace.h"
 #include "compel/asm/processor-flags.h"
 #include "asm/dump.h"
 #include "protobuf.h"
diff --git a/criu/arch/arm/crtools.c b/criu/arch/arm/crtools.c
index b944e6298ea6..e3016b8c58e5 100644
--- a/criu/arch/arm/crtools.c
+++ b/criu/arch/arm/crtools.c
@@ -5,7 +5,7 @@
 #include "asm/restorer.h"
 #include "asm/dump.h"
 #include "compiler.h"
-#include "ptrace.h"
+#include "compel/ptrace.h"
 #include "compel/asm/processor-flags.h"
 #include "protobuf.h"
 #include "images/core.pb-c.h"
diff --git a/criu/arch/ppc64/crtools.c b/criu/arch/ppc64/crtools.c
index ef0e6be19990..c938647986e4 100644
--- a/criu/arch/ppc64/crtools.c
+++ b/criu/arch/ppc64/crtools.c
@@ -12,7 +12,7 @@
 
 #include "cr_options.h"
 #include "compiler.h"
-#include "ptrace.h"
+#include "compel/ptrace.h"
 #include "parasite-syscall.h"
 #include "log.h"
 #include "util.h"
diff --git a/criu/arch/x86/crtools.c b/criu/arch/x86/crtools.c
index 01bbf7d0fb51..804f12deb18d 100644
--- a/criu/arch/x86/crtools.c
+++ b/criu/arch/x86/crtools.c
@@ -16,7 +16,7 @@
 #include "cr_options.h"
 #include "compiler.h"
 #include "restorer.h"
-#include "ptrace.h"
+#include "compel/ptrace.h"
 #include "parasite-syscall.h"
 #include "log.h"
 #include "util.h"
diff --git a/criu/cr-check.c b/criu/cr-check.c
index bb4d97807bf7..17246f6abcbc 100644
--- a/criu/cr-check.c
+++ b/criu/cr-check.c
@@ -34,7 +34,7 @@
 #include "proc_parse.h"
 #include "mount.h"
 #include "tty.h"
-#include "ptrace.h"
+#include "compel/ptrace.h"
 #include "kerndat.h"
 #include "timerfd.h"
 #include "tun.h"
diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 44dce53e8b13..cf7b0bf1cb26 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -42,7 +42,7 @@
 #include "cr_options.h"
 #include "servicefd.h"
 #include "string.h"
-#include "ptrace.h"
+#include "compel/ptrace.h"
 #include "util.h"
 #include "namespaces.h"
 #include "image.h"
diff --git a/criu/cr-exec.c b/criu/cr-exec.c
index 098bf96d7ced..e2e511f5b232 100644
--- a/criu/cr-exec.c
+++ b/criu/cr-exec.c
@@ -4,7 +4,7 @@
 #include "crtools.h"
 #include "parasite-syscall.h"
 #include "proc_parse.h"
-#include "ptrace.h"
+#include "compel/ptrace.h"
 #include "pstree.h"
 #include "vma.h"
 #include "log.h"
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index ebc3026991ad..7e75f20b77fe 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -24,7 +24,7 @@
 
 #include <sys/sendfile.h>
 
-#include "ptrace.h"
+#include "compel/ptrace.h"
 #include "compiler.h"
 #include "asm/types.h"
 #include "asm/restorer.h"
diff --git a/criu/include/ptrace.h b/criu/include/ptrace.h
deleted file mode 100644
index b3343fdf83a5..000000000000
--- a/criu/include/ptrace.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef __CR_PTRACE_H__
-#define __CR_PTRACE_H__
-
-#include <linux/types.h>
-#include <sys/ptrace.h>
-
-#include "config.h"
-
-/* some constants for ptrace */
-#ifndef PTRACE_SEIZE
-# define PTRACE_SEIZE		0x4206
-#endif
-
-#ifndef PTRACE_O_SUSPEND_SECCOMP
-# define PTRACE_O_SUSPEND_SECCOMP (1 << 21)
-#endif
-
-#ifndef PTRACE_INTERRUPT
-# define PTRACE_INTERRUPT	0x4207
-#endif
-
-#ifndef PTRACE_LISTEN
-#define PTRACE_LISTEN		0x4208
-#endif
-
-#ifndef PTRACE_PEEKSIGINFO
-#define PTRACE_PEEKSIGINFO      0x4209
-
-/* Read signals from a shared (process wide) queue */
-#define PTRACE_PEEKSIGINFO_SHARED       (1 << 0)
-#endif
-
-#ifndef CONFIG_HAS_PTRACE_PEEKSIGINFO
-struct ptrace_peeksiginfo_args {
-        __u64 off;	/* from which siginfo to start */
-        __u32 flags;
-        __u32 nr;	/* how may siginfos to take */
-};
-#endif
-
-#ifndef PTRACE_GETREGSET
-# define PTRACE_GETREGSET	0x4204
-# define PTRACE_SETREGSET	0x4205
-#endif
-
-#ifndef PTRACE_GETSIGMASK
-# define PTRACE_GETSIGMASK	0x420a
-# define PTRACE_SETSIGMASK	0x420b
-#endif
-
-#ifndef PTRACE_SECCOMP_GET_FILTER
-#define PTRACE_SECCOMP_GET_FILTER	0x420c
-#endif
-
-#define PTRACE_SEIZE_DEVEL	0x80000000
-
-#define PTRACE_EVENT_FORK	1
-#define PTRACE_EVENT_VFORK	2
-#define PTRACE_EVENT_CLONE	3
-#define PTRACE_EVENT_EXEC	4
-#define PTRACE_EVENT_VFORK_DONE	5
-#define PTRACE_EVENT_EXIT	6
-#define PTRACE_EVENT_STOP	128
-
-#define PTRACE_O_TRACESYSGOOD	0x00000001
-#define PTRACE_O_TRACEFORK	0x00000002
-#define PTRACE_O_TRACEVFORK	0x00000004
-#define PTRACE_O_TRACECLONE	0x00000008
-#define PTRACE_O_TRACEEXEC	0x00000010
-#define PTRACE_O_TRACEVFORKDONE	0x00000020
-#define PTRACE_O_TRACEEXIT	0x00000040
-
-#define SI_EVENT(_si_code)	(((_si_code) & 0xFFFF) >> 8)
-
-extern int suspend_seccomp(pid_t pid);
-extern int ptrace_peek_area(pid_t pid, void *dst, void *addr, long bytes);
-extern int ptrace_poke_area(pid_t pid, void *src, void *addr, long bytes);
-extern int ptrace_swap_area(pid_t pid, void *dst, void *src, long bytes);
-
-#endif /* __CR_PTRACE_H__ */
diff --git a/criu/infect.c b/criu/infect.c
index c3df5d44b5e4..74107c73da96 100644
--- a/criu/infect.c
+++ b/criu/infect.c
@@ -6,7 +6,7 @@
 #include <signal.h>
 #include <linux/seccomp.h>
 
-#include "ptrace.h"
+#include "compel/ptrace.h"
 #include "signal.h"
 #include "asm/parasite-syscall.h"
 #include "asm/dump.h"
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index 619506f19869..4dd159a7ed60 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -13,7 +13,7 @@
 #include "images/pagemap.pb-c.h"
 
 #include "imgset.h"
-#include "ptrace.h"
+#include "compel/ptrace.h"
 #include "compel/asm/processor-flags.h"
 #include "parasite-syscall.h"
 #include "parasite-blob.h"
diff --git a/criu/seccomp.c b/criu/seccomp.c
index c569e7c1a036..95cea8432e86 100644
--- a/criu/seccomp.c
+++ b/criu/seccomp.c
@@ -7,7 +7,7 @@
 #include "imgset.h"
 #include "kcmp.h"
 #include "pstree.h"
-#include "ptrace.h"
+#include "compel/ptrace.h"
 #include "proc_parse.h"
 #include "restorer.h"
 #include "seccomp.h"
diff --git a/criu/seize.c b/criu/seize.c
index 0e81b18c950a..5d7a48ad3881 100644
--- a/criu/seize.c
+++ b/criu/seize.c
@@ -13,7 +13,7 @@
 #include "cr_options.h"
 #include "cr-errno.h"
 #include "pstree.h"
-#include "ptrace.h"
+#include "compel/ptrace.h"
 #include "proc_parse.h"
 #include "seize.h"
 #include "stats.h"
-- 
2.7.4



More information about the CRIU mailing list