[CRIU] [PATCH 15/15] crtools: avoid inclusion of crtools.h

Andrey Vagin avagin at openvz.org
Mon Nov 4 22:00:37 PST 2013


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 eventfd.c                  |  1 -
 fifo.c                     |  1 -
 files-reg.c                |  1 -
 files.c                    |  2 --
 fsnotify.c                 |  1 -
 image.c                    | 11 +++++------
 include/common.h           | 13 +++++++++++++
 include/crtools.h          | 12 ------------
 include/eventfd.h          |  7 +------
 include/eventpoll.h        |  7 +------
 include/fsnotify.h         |  7 +------
 include/ipc_ns.h           |  2 +-
 include/namespaces.h       |  1 -
 include/parasite-syscall.h |  2 ++
 include/posix-timer.h      |  2 ++
 include/restorer.h         |  1 -
 include/tty.h              |  1 -
 include/uts_ns.h           |  2 +-
 ipc_ns.c                   |  1 -
 mem.c                      |  1 -
 mount.c                    |  1 -
 namespaces.c               |  1 +
 net.c                      |  1 -
 pipes.c                    |  1 -
 proc_parse.c               |  1 -
 protobuf.c                 |  2 --
 ptrace.c                   |  1 -
 security.c                 |  1 -
 signalfd.c                 |  1 -
 sk-inet.c                  |  1 -
 sk-netlink.c               |  1 -
 sk-tcp.c                   |  1 -
 sk-unix.c                  |  1 -
 sockets.c                  |  1 -
 tty.c                      |  2 +-
 tun.c                      |  1 -
 uts_ns.c                   |  1 -
 37 files changed, 29 insertions(+), 66 deletions(-)

diff --git a/eventfd.c b/eventfd.c
index aab1976..07b3bb4 100644
--- a/eventfd.c
+++ b/eventfd.c
@@ -16,7 +16,6 @@
 #include "asm/types.h"
 #include "eventfd.h"
 #include "proc_parse.h"
-#include "crtools.h"
 #include "image.h"
 #include "util.h"
 #include "log.h"
diff --git a/fifo.c b/fifo.c
index 530a6d0..24bdba9 100644
--- a/fifo.c
+++ b/fifo.c
@@ -4,7 +4,6 @@
 #include <fcntl.h>
 #include <stdlib.h>
 
-#include "crtools.h"
 #include "image.h"
 #include "files.h"
 #include "files-reg.h"
diff --git a/files-reg.c b/files-reg.c
index 41050ef..b438d9d 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -5,7 +5,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include "crtools.h"
 #include "file-ids.h"
 #include "mount.h"
 #include "files.h"
diff --git a/files.c b/files.c
index 0dd1b9f..3960ee9 100644
--- a/files.c
+++ b/files.c
@@ -13,8 +13,6 @@
 #include <sys/un.h>
 #include <stdlib.h>
 
-#include "crtools.h"
-
 #include "files.h"
 #include "file-ids.h"
 #include "files-reg.h"
diff --git a/fsnotify.c b/fsnotify.c
index 2370cc1..219bbc5 100644
--- a/fsnotify.c
+++ b/fsnotify.c
@@ -26,7 +26,6 @@
 #include "fsnotify.h"
 #include "proc_parse.h"
 #include "syscall.h"
-#include "crtools.h"
 #include "mount.h"
 #include "image.h"
 #include "util.h"
diff --git a/image.c b/image.c
index 427f69b..47e5770 100644
--- a/image.c
+++ b/image.c
@@ -1,6 +1,5 @@
 #include <unistd.h>
 #include <stdarg.h>
-#include "crtools.h"
 #include "image.h"
 #include "eventpoll.h"
 #include "signalfd.h"
@@ -236,6 +235,11 @@ err:
 	return -1;
 }
 
+void close_image_dir(void)
+{
+	close_service_fd(IMG_FD_OFF);
+}
+
 int open_image_dir(void)
 {
 	int fd, ret;
@@ -275,11 +279,6 @@ err:
 	return -1;
 }
 
-void close_image_dir(void)
-{
-	close_service_fd(IMG_FD_OFF);
-}
-
 static unsigned long page_ids = 1;
 
 void up_page_ids_base(void)
diff --git a/include/common.h b/include/common.h
index 6efca6b..f49c57b 100644
--- a/include/common.h
+++ b/include/common.h
@@ -5,6 +5,9 @@
 
 #include "bug.h"
 #include "list.h"
+#include "lock.h"
+
+#define CR_FD_PERM		(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)
 
 struct pid {
 	/*
@@ -97,4 +100,14 @@ struct script {
 	char *path;
 };
 
+struct fdt {
+	int			nr;		/* How many tasks share this fd table */
+	pid_t			pid;		/* Who should restore this fd table */
+	/*
+	 * The fd table is ready for restoing, if fdt_lock is equal to nr
+	 * The fdt table was restrored, if fdt_lock is equal to nr + 1
+	 */
+	futex_t			fdt_lock;
+};
+
 #endif
diff --git a/include/crtools.h b/include/crtools.h
index 751b4d8..81972ba 100644
--- a/include/crtools.h
+++ b/include/crtools.h
@@ -12,8 +12,6 @@
 
 #include "protobuf/vma.pb-c.h"
 
-#define CR_FD_PERM		(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)
-
 int check_img_inventory(void);
 int write_img_inventory(void);
 void kill_inventory(void);
@@ -31,16 +29,6 @@ int convert_to_elf(char *elf_path, int fd_core);
 int cr_check(void);
 int cr_exec(int pid, char **opts);
 
-struct fdt {
-	int			nr;		/* How many tasks share this fd table */
-	pid_t			pid;		/* Who should restore this fd table */
-	/*
-	 * The fd table is ready for restoing, if fdt_lock is equal to nr
-	 * The fdt table was restrored, if fdt_lock is equal to nr + 1
-	 */
-	futex_t			fdt_lock;
-};
-
 void restrict_uid(unsigned int uid, unsigned int gid);
 struct proc_status_creds;
 bool may_dump(struct proc_status_creds *);
diff --git a/include/eventfd.h b/include/eventfd.h
index 5666e50..44175da 100644
--- a/include/eventfd.h
+++ b/include/eventfd.h
@@ -1,13 +1,8 @@
 #ifndef __CR_EVENTFD_H__
 #define __CR_EVENTFD_H__
 
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "compiler.h"
-#include "asm/types.h"
 #include "files.h"
-#include "crtools.h"
+#include "protobuf.h"
 
 extern int is_eventfd_link(int lfd);
 extern const struct fdtype_ops eventfd_dump_ops;
diff --git a/include/eventpoll.h b/include/eventpoll.h
index e67a2e5..72ad6bd 100644
--- a/include/eventpoll.h
+++ b/include/eventpoll.h
@@ -1,13 +1,8 @@
 #ifndef __CR_EVENTPOLL_H__
 #define __CR_EVENTPOLL_H__
 
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "compiler.h"
-#include "asm/types.h"
+#include "protobuf.h"
 #include "files.h"
-#include "crtools.h"
 
 extern int is_eventpoll_link(int lfd);
 extern const struct fdtype_ops eventpoll_dump_ops;
diff --git a/include/fsnotify.h b/include/fsnotify.h
index eb33370..cc716d0 100644
--- a/include/fsnotify.h
+++ b/include/fsnotify.h
@@ -1,13 +1,8 @@
 #ifndef __CR_FSNOTIFY_H__
 #define __CR_FSNOTIFY_H__
 
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "compiler.h"
-#include "asm/types.h"
+#include "protobuf.h"
 #include "files.h"
-#include "crtools.h"
 
 struct fsnotify_params {
 	u32	id;
diff --git a/include/ipc_ns.h b/include/ipc_ns.h
index 2f3adf3..4ad852d 100644
--- a/include/ipc_ns.h
+++ b/include/ipc_ns.h
@@ -1,7 +1,7 @@
 #ifndef __CR_IPC_NS_H__
 #define __CR_IPC_NS_H__
 
-#include "crtools.h"
+#include "namespaces.h"
 
 extern int dump_ipc_ns(int ns_pid, int ns_id);
 extern int prepare_ipc_ns(int pid);
diff --git a/include/namespaces.h b/include/namespaces.h
index 5694e00..14061d3 100644
--- a/include/namespaces.h
+++ b/include/namespaces.h
@@ -1,7 +1,6 @@
 #ifndef __CR_NS_H__
 #define __CR_NS_H__
 
-#include "crtools.h"
 #include "files.h"
 
 struct ns_desc {
diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h
index 3bb2d8c..932e5d0 100644
--- a/include/parasite-syscall.h
+++ b/include/parasite-syscall.h
@@ -1,6 +1,8 @@
 #ifndef __CR_PARASITE_SYSCALL_H__
 #define __CR_PARASITE_SYSCALL_H__
 
+#include "asm/types.h"
+
 #include "common.h"
 #include "list.h"
 
diff --git a/include/posix-timer.h b/include/posix-timer.h
index 70b007f..344566e 100644
--- a/include/posix-timer.h
+++ b/include/posix-timer.h
@@ -1,6 +1,8 @@
 #ifndef __CR_PROC_POSIX_TIMER_H__
 #define __CR_PROC_POSIX_TIMER_H__
 
+#include "list.h"
+
 struct str_posix_timer {
 	long it_id;
 	int clock_id;
diff --git a/include/restorer.h b/include/restorer.h
index a133c86..34c899e 100644
--- a/include/restorer.h
+++ b/include/restorer.h
@@ -11,7 +11,6 @@
 #include "image.h"
 #include "lock.h"
 #include "util.h"
-#include "crtools.h"
 #include "asm/restorer.h"
 
 #include "posix-timer.h"
diff --git a/include/tty.h b/include/tty.h
index 43a737c..d2c31e2 100644
--- a/include/tty.h
+++ b/include/tty.h
@@ -2,7 +2,6 @@
 #define __CR_TTY_H__
 
 #include "files.h"
-#include "crtools.h"
 
 /* Kernel's limit */
 #define TERMIOS_NCC	19
diff --git a/include/uts_ns.h b/include/uts_ns.h
index 7919923..e58840d 100644
--- a/include/uts_ns.h
+++ b/include/uts_ns.h
@@ -1,7 +1,7 @@
 #ifndef __CR_UTS_NS_H__
 #define __CR_UTS_NS_H__
 
-#include "crtools.h"
+#include "namespaces.h"
 
 int dump_uts_ns(int ns_pid, int ns_id);
 int prepare_utsns(int pid);
diff --git a/ipc_ns.c b/ipc_ns.c
index aab47c0..e0384cf 100644
--- a/ipc_ns.c
+++ b/ipc_ns.c
@@ -8,7 +8,6 @@
 #include <sys/shm.h>
 
 #include "util.h"
-#include "crtools.h"
 #include "syscall.h"
 #include "namespaces.h"
 #include "sysctl.h"
diff --git a/mem.c b/mem.c
index bebd938..60ddf77 100644
--- a/mem.c
+++ b/mem.c
@@ -3,7 +3,6 @@
 #include <sys/mman.h>
 #include <errno.h>
 
-#include "crtools.h"
 #include "servicefd.h"
 #include "mem.h"
 #include "parasite-syscall.h"
diff --git a/mount.c b/mount.c
index 1f92653..1683345 100644
--- a/mount.c
+++ b/mount.c
@@ -12,7 +12,6 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
-#include "crtools.h"
 #include "asm/types.h"
 #include "util.h"
 #include "util-pie.h"
diff --git a/namespaces.c b/namespaces.c
index 31ce2fd..d1e2cee 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -9,6 +9,7 @@
 #include "mount.h"
 #include "pstree.h"
 #include "namespaces.h"
+#include "cr-show.h"
 #include "net.h"
 
 #include "protobuf.h"
diff --git a/net.c b/net.c
index 6037ff6..586d2e8 100644
--- a/net.c
+++ b/net.c
@@ -12,7 +12,6 @@
 #include "namespaces.h"
 #include "net.h"
 #include "libnetlink.h"
-#include "crtools.h"
 #include "sk-inet.h"
 #include "tun.h"
 #include "util-pie.h"
diff --git a/pipes.c b/pipes.c
index b5d141a..bae448b 100644
--- a/pipes.c
+++ b/pipes.c
@@ -5,7 +5,6 @@
 #include <stdlib.h>
 #include <sys/mman.h>
 
-#include "crtools.h"
 #include "image.h"
 #include "files.h"
 #include "pipes.h"
diff --git a/proc_parse.c b/proc_parse.c
index a333716..fee4bf9 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -12,7 +12,6 @@
 #include "asm/types.h"
 #include "list.h"
 #include "util.h"
-#include "crtools.h"
 #include "mount.h"
 #include "cpu.h"
 #include "file-lock.h"
diff --git a/protobuf.c b/protobuf.c
index 10c844c..42f2e48 100644
--- a/protobuf.c
+++ b/protobuf.c
@@ -8,14 +8,12 @@
 
 #include <google/protobuf-c/protobuf-c.h>
 
-#include "crtools.h"
 #include "compiler.h"
 #include "asm/types.h"
 #include "log.h"
 #include "util.h"
 #include "image.h"
 #include "string.h"
-#include "sockets.h"
 
 #include "protobuf.h"
 
diff --git a/ptrace.c b/ptrace.c
index f3d2056..b3b8241 100644
--- a/ptrace.c
+++ b/ptrace.c
@@ -13,7 +13,6 @@
 #include <sys/resource.h>
 #include <sys/wait.h>
 
-#include "crtools.h"
 #include "compiler.h"
 #include "asm/types.h"
 #include "util.h"
diff --git a/security.c b/security.c
index 27eaf2e..59ceb06 100644
--- a/security.c
+++ b/security.c
@@ -1,5 +1,4 @@
 #include <unistd.h>
-#include "crtools.h"
 #include "proc_parse.h"
 #include "log.h"
 
diff --git a/signalfd.c b/signalfd.c
index 1c91157..19e9020 100644
--- a/signalfd.c
+++ b/signalfd.c
@@ -6,7 +6,6 @@
 #include "asm/types.h"
 #include "signalfd.h"
 #include "proc_parse.h"
-#include "crtools.h"
 #include "image.h"
 #include "util.h"
 #include "log.h"
diff --git a/sk-inet.c b/sk-inet.c
index 1c0dbf0..f3f5d4e 100644
--- a/sk-inet.c
+++ b/sk-inet.c
@@ -11,7 +11,6 @@
 
 #include "asm/types.h"
 #include "libnetlink.h"
-#include "crtools.h"
 #include "inet_diag.h"
 #include "files.h"
 #include "image.h"
diff --git a/sk-netlink.c b/sk-netlink.c
index f519cf4..d390559 100644
--- a/sk-netlink.c
+++ b/sk-netlink.c
@@ -3,7 +3,6 @@
 #include <linux/rtnetlink.h>
 #include <poll.h>
 
-#include "crtools.h"
 #include "files.h"
 #include "sockets.h"
 #include "util.h"
diff --git a/sk-tcp.c b/sk-tcp.c
index 8136aec..3b15b9a 100644
--- a/sk-tcp.c
+++ b/sk-tcp.c
@@ -6,7 +6,6 @@
 #include <sys/mman.h>
 #include <string.h>
 
-#include "crtools.h"
 #include "util.h"
 #include "list.h"
 #include "log.h"
diff --git a/sk-unix.c b/sk-unix.c
index c8bc09c..b4de1b8 100644
--- a/sk-unix.c
+++ b/sk-unix.c
@@ -10,7 +10,6 @@
 
 #include "asm/types.h"
 #include "libnetlink.h"
-#include "crtools.h"
 #include "unix_diag.h"
 #include "files.h"
 #include "file-ids.h"
diff --git a/sockets.c b/sockets.c
index c25ca69..3869efc 100644
--- a/sockets.c
+++ b/sockets.c
@@ -18,7 +18,6 @@
 #include "util-pie.h"
 #include "sk-packet.h"
 #include "namespaces.h"
-#include "crtools.h"
 #include "net.h"
 
 #ifndef NETLINK_SOCK_DIAG
diff --git a/tty.c b/tty.c
index 98c6698..f928991 100644
--- a/tty.c
+++ b/tty.c
@@ -17,7 +17,7 @@
 
 #include "syscall.h"
 #include "files.h"
-#include "crtools.h"
+#include "common.h"
 #include "servicefd.h"
 #include "image.h"
 #include "util.h"
diff --git a/tun.c b/tun.c
index 07be911..a43767b 100644
--- a/tun.c
+++ b/tun.c
@@ -4,7 +4,6 @@
 #include <linux/if_tun.h>
 #include <sys/ioctl.h>
 
-#include "crtools.h"
 #include "protobuf.h"
 #include "cr-show.h"
 #include "string.h"
diff --git a/uts_ns.c b/uts_ns.c
index 777b3af..b495bbb 100644
--- a/uts_ns.c
+++ b/uts_ns.c
@@ -4,7 +4,6 @@
 #include <string.h>
 
 #include "util.h"
-#include "crtools.h"
 #include "syscall.h"
 #include "namespaces.h"
 #include "sysctl.h"
-- 
1.8.3.1



More information about the CRIU mailing list