[CRIU] [PATCH 5/5] crtools: move pid_rst_prio to pid.h

Andrey Vagin avagin at openvz.org
Wed Nov 6 05:21:13 PST 2013


crtools.h is too heavy to be included in many sources

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 cr-show.c           |  1 +
 eventfd.c           |  1 -
 eventpoll.c         |  1 -
 fifo.c              |  1 -
 files.c             |  2 --
 fsnotify.c          |  1 -
 image.c             |  1 +
 include/crtools.h   | 10 ----------
 include/files.h     |  2 +-
 include/image.h     |  1 +
 include/pid.h       | 12 ++++++++++++
 include/servicefd.h |  2 ++
 pipes.c             |  1 -
 proc_parse.c        |  1 -
 ptrace.c            |  1 -
 shmem.c             |  2 +-
 signalfd.c          |  1 -
 sk-netlink.c        |  1 -
 sk-queue.c          |  1 -
 sockets.c           |  1 -
 stats.c             |  1 -
 uts_ns.c            |  1 -
 22 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/cr-show.c b/cr-show.c
index 9a1982b..6736ae6 100644
--- a/cr-show.c
+++ b/cr-show.c
@@ -25,6 +25,7 @@
 #include "ipc_ns.h"
 #include "pstree.h"
 #include "cr-show.h"
+#include "crtools.h"
 
 #include "protobuf.h"
 #include "protobuf/pstree.pb-c.h"
diff --git a/eventfd.c b/eventfd.c
index 2f7f124..d4e7bf8 100644
--- a/eventfd.c
+++ b/eventfd.c
@@ -17,7 +17,6 @@
 #include "fdset.h"
 #include "eventfd.h"
 #include "proc_parse.h"
-#include "crtools.h"
 #include "image.h"
 #include "util.h"
 #include "log.h"
diff --git a/eventpoll.c b/eventpoll.c
index fa5003a..d82c19e 100644
--- a/eventpoll.c
+++ b/eventpoll.c
@@ -18,7 +18,6 @@
 #include "rst_info.h"
 #include "eventpoll.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 f3c29de..67d7f56 100644
--- a/fifo.c
+++ b/fifo.c
@@ -4,7 +4,6 @@
 #include <fcntl.h>
 #include <stdlib.h>
 
-#include "crtools.h"
 #include "fdset.h"
 #include "image.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 793446e..d0da4fd 100644
--- a/fsnotify.c
+++ b/fsnotify.c
@@ -27,7 +27,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 b244cf3..c454767 100644
--- a/image.c
+++ b/image.c
@@ -1,5 +1,6 @@
 #include <unistd.h>
 #include <stdarg.h>
+#include "crtools.h"
 #include "cr_options.h"
 #include "fdset.h"
 #include "image.h"
diff --git a/include/crtools.h b/include/crtools.h
index bd8fac3..de35738 100644
--- a/include/crtools.h
+++ b/include/crtools.h
@@ -23,16 +23,6 @@ int convert_to_elf(char *elf_path, int fd_core);
 int cr_check(void);
 int cr_exec(int pid, char **opts);
 
-/*
- * When we have to restore a shared resource, we mush select which
- * task should do it, and make other(s) wait for it. In order to
- * avoid deadlocks, always make task with lower pid be the restorer.
- */
-static inline bool pid_rst_prio(unsigned pid_a, unsigned pid_b)
-{
-	return pid_a < pid_b;
-}
-
 void restrict_uid(unsigned int uid, unsigned int gid);
 struct proc_status_creds;
 bool may_dump(struct proc_status_creds *);
diff --git a/include/files.h b/include/files.h
index 5b65bd7..4728ff1 100644
--- a/include/files.h
+++ b/include/files.h
@@ -6,7 +6,7 @@
 #include "lock.h"
 #include "list.h"
 #include "image.h"
-#include "crtools.h"
+#include "pid.h"
 
 #include "protobuf/fdinfo.pb-c.h"
 #include "protobuf/fown.pb-c.h"
diff --git a/include/image.h b/include/image.h
index f38a51b..00d2e45 100644
--- a/include/image.h
+++ b/include/image.h
@@ -4,6 +4,7 @@
 #include <stdbool.h>
 
 #include "compiler.h"
+#include "servicefd.h"
 #include "image-desc.h"
 #include "magic.h"
 
diff --git a/include/pid.h b/include/pid.h
index 42a2b7e..18a6dfa 100644
--- a/include/pid.h
+++ b/include/pid.h
@@ -1,6 +1,8 @@
 #ifndef __CR_PID_H__
 #define __CR_PID_H__
 
+#include "stdbool.h"
+
 struct pid {
 	/*
 	 * The @real pid is used to fetch tasks during dumping stage,
@@ -17,4 +19,14 @@ struct pid {
 	pid_t virt;
 };
 
+/*
+ * When we have to restore a shared resource, we mush select which
+ * task should do it, and make other(s) wait for it. In order to
+ * avoid deadlocks, always make task with lower pid be the restorer.
+ */
+static inline bool pid_rst_prio(unsigned pid_a, unsigned pid_b)
+{
+	return pid_a < pid_b;
+}
+
 #endif
diff --git a/include/servicefd.h b/include/servicefd.h
index 699d26e..85526b0 100644
--- a/include/servicefd.h
+++ b/include/servicefd.h
@@ -1,6 +1,8 @@
 #ifndef __CR_SERVICE_FD_H__
 #define __CR_SERVICE_FD_H__
 
+#include <stdbool.h>
+
 enum sfd_type {
 	SERVICE_FD_MIN,
 
diff --git a/pipes.c b/pipes.c
index 019ca8f..ef260aa 100644
--- a/pipes.c
+++ b/pipes.c
@@ -5,7 +5,6 @@
 #include <stdlib.h>
 #include <sys/mman.h>
 
-#include "crtools.h"
 #include "fdset.h"
 #include "image.h"
 #include "files.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/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/shmem.c b/shmem.c
index e37581b..18e25c0 100644
--- a/shmem.c
+++ b/shmem.c
@@ -2,9 +2,9 @@
 #include <sys/mman.h>
 #include <stdlib.h>
 
+#include "pid.h"
 #include "shmem.h"
 #include "image.h"
-#include "crtools.h"
 #include "page-pipe.h"
 #include "page-xfer.h"
 #include "rst-malloc.h"
diff --git a/signalfd.c b/signalfd.c
index daceda8..48816ed 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 "fdset.h"
 #include "image.h"
 #include "util.h"
diff --git a/sk-netlink.c b/sk-netlink.c
index ac662e9..83a2090 100644
--- a/sk-netlink.c
+++ b/sk-netlink.c
@@ -3,7 +3,6 @@
 #include <linux/rtnetlink.h>
 #include <poll.h>
 
-#include "crtools.h"
 #include "fdset.h"
 #include "files.h"
 #include "sockets.h"
diff --git a/sk-queue.c b/sk-queue.c
index d1e8656..9180e09 100644
--- a/sk-queue.c
+++ b/sk-queue.c
@@ -15,7 +15,6 @@
 #include "fdset.h"
 #include "image.h"
 #include "servicefd.h"
-#include "crtools.h"
 #include "cr_options.h"
 #include "util.h"
 #include "util-pie.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/stats.c b/stats.c
index cd5b829..fb6a24a 100644
--- a/stats.c
+++ b/stats.c
@@ -3,7 +3,6 @@
 #include "asm/atomic.h"
 #include "protobuf.h"
 #include "stats.h"
-#include "crtools.h"
 #include "image.h"
 #include "protobuf/stats.pb-c.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