[CRIU] [PATCH 2/7] crtools: move all stuff about fdset in a separate header

Andrey Vagin avagin at openvz.org
Wed Nov 6 02:34:28 PST 2013


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 cr-dump.c          |  1 +
 cr-show.c          |  1 +
 eventfd.c          |  1 +
 eventpoll.c        |  1 +
 fifo.c             |  1 +
 file-lock.c        |  1 +
 files-reg.c        |  1 +
 fsnotify.c         |  1 +
 image.c            |  1 +
 include/crtools.h  | 28 ----------------------------
 include/fdset.h    | 36 ++++++++++++++++++++++++++++++++++++
 ipc_ns.c           |  1 +
 namespaces.c       |  1 +
 net.c              |  1 +
 parasite-syscall.c |  1 +
 pipes.c            |  1 +
 signalfd.c         |  1 +
 sk-inet.c          |  1 +
 sk-netlink.c       |  1 +
 sk-packet.c        |  1 +
 sk-queue.c         |  1 +
 sk-unix.c          |  1 +
 tty.c              |  1 +
 tun.c              |  1 +
 24 files changed, 58 insertions(+), 28 deletions(-)
 create mode 100644 include/fdset.h

diff --git a/cr-dump.c b/cr-dump.c
index 58a39c7..5ced199 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -32,6 +32,7 @@
 
 #include "asm/types.h"
 #include "list.h"
+#include "fdset.h"
 #include "file-ids.h"
 #include "kcmp-ids.h"
 #include "compiler.h"
diff --git a/cr-show.c b/cr-show.c
index 58ab315..edbd67b 100644
--- a/cr-show.c
+++ b/cr-show.c
@@ -14,6 +14,7 @@
 
 #include "asm/types.h"
 #include "list.h"
+#include "fdset.h"
 #include "namespaces.h"
 #include "compiler.h"
 #include "crtools.h"
diff --git a/eventfd.c b/eventfd.c
index aab1976..2f7f124 100644
--- a/eventfd.c
+++ b/eventfd.c
@@ -14,6 +14,7 @@
 
 #include "compiler.h"
 #include "asm/types.h"
+#include "fdset.h"
 #include "eventfd.h"
 #include "proc_parse.h"
 #include "crtools.h"
diff --git a/eventpoll.c b/eventpoll.c
index e80597c..3766909 100644
--- a/eventpoll.c
+++ b/eventpoll.c
@@ -14,6 +14,7 @@
 
 #include "compiler.h"
 #include "asm/types.h"
+#include "fdset.h"
 #include "eventpoll.h"
 #include "proc_parse.h"
 #include "crtools.h"
diff --git a/fifo.c b/fifo.c
index 530a6d0..f3c29de 100644
--- a/fifo.c
+++ b/fifo.c
@@ -5,6 +5,7 @@
 #include <stdlib.h>
 
 #include "crtools.h"
+#include "fdset.h"
 #include "image.h"
 #include "files.h"
 #include "files-reg.h"
diff --git a/file-lock.c b/file-lock.c
index d89fcd8..b55cc64 100644
--- a/file-lock.c
+++ b/file-lock.c
@@ -6,6 +6,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#include "fdset.h"
 #include "file-lock.h"
 #include "parasite.h"
 #include "parasite-syscall.h"
diff --git a/files-reg.c b/files-reg.c
index 640cb60..f14c1f9 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -6,6 +6,7 @@
 #include <sys/stat.h>
 
 #include "crtools.h"
+#include "fdset.h"
 #include "file-ids.h"
 #include "mount.h"
 #include "files.h"
diff --git a/fsnotify.c b/fsnotify.c
index 2370cc1..793446e 100644
--- a/fsnotify.c
+++ b/fsnotify.c
@@ -23,6 +23,7 @@
 
 #include "compiler.h"
 #include "asm/types.h"
+#include "fdset.h"
 #include "fsnotify.h"
 #include "proc_parse.h"
 #include "syscall.h"
diff --git a/image.c b/image.c
index 427f69b..3a26600 100644
--- a/image.c
+++ b/image.c
@@ -1,6 +1,7 @@
 #include <unistd.h>
 #include <stdarg.h>
 #include "crtools.h"
+#include "fdset.h"
 #include "image.h"
 #include "eventpoll.h"
 #include "signalfd.h"
diff --git a/include/crtools.h b/include/crtools.h
index 3609c75..9d0aebf 100644
--- a/include/crtools.h
+++ b/include/crtools.h
@@ -57,7 +57,6 @@ void kill_inventory(void);
 
 extern void print_data(unsigned long addr, unsigned char *data, size_t size);
 extern void print_image_data(int fd, unsigned int length, int show);
-extern struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX];
 
 extern int open_image_dir(void);
 extern void close_image_dir(void);
@@ -70,24 +69,6 @@ void up_page_ids_base(void);
 
 #define LAST_PID_PATH		"/proc/sys/kernel/ns_last_pid"
 
-struct cr_fdset {
-	int fd_off;
-	int fd_nr;
-	int *_fds;
-};
-
-static inline int fdset_fd(const struct cr_fdset *fdset, int type)
-{
-	int idx;
-
-	idx = type - fdset->fd_off;
-	BUG_ON(idx > fdset->fd_nr);
-
-	return fdset->_fds[idx];
-}
-
-extern struct cr_fdset *glob_fdset;
-
 int cr_dump_tasks(pid_t pid);
 int cr_pre_dump_tasks(pid_t pid);
 int cr_restore_tasks(void);
@@ -100,15 +81,6 @@ int cr_exec(int pid, char **opts);
 #define O_SHOW	(O_RDONLY)
 #define O_RSTR	(O_RDONLY)
 
-struct cr_fdset *cr_task_fdset_open(int pid, int mode);
-struct cr_fdset *cr_fdset_open_range(int pid, int from, int to,
-			       unsigned long flags);
-#define cr_fdset_open(pid, type, flags) cr_fdset_open_range(pid, \
-		_CR_FD_##type##_FROM, _CR_FD_##type##_TO, flags)
-struct cr_fdset *cr_glob_fdset_open(int mode);
-
-void close_cr_fdset(struct cr_fdset **cr_fdset);
-
 struct fdt {
 	int			nr;		/* How many tasks share this fd table */
 	pid_t			pid;		/* Who should restore this fd table */
diff --git a/include/fdset.h b/include/fdset.h
new file mode 100644
index 0000000..8fe9774
--- /dev/null
+++ b/include/fdset.h
@@ -0,0 +1,36 @@
+#ifndef __CR_FDSET_H__
+#define __CR_FDSET_H__
+
+#include "image-desc.h"
+#include "bug.h"
+
+struct cr_fdset {
+	int fd_off;
+	int fd_nr;
+	int *_fds;
+};
+
+static inline int fdset_fd(const struct cr_fdset *fdset, int type)
+{
+	int idx;
+
+	idx = type - fdset->fd_off;
+	BUG_ON(idx > fdset->fd_nr);
+
+	return fdset->_fds[idx];
+}
+
+extern struct cr_fdset *glob_fdset;
+
+extern struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX];
+
+struct cr_fdset *cr_task_fdset_open(int pid, int mode);
+struct cr_fdset *cr_fdset_open_range(int pid, int from, int to,
+			       unsigned long flags);
+#define cr_fdset_open(pid, type, flags) cr_fdset_open_range(pid, \
+		_CR_FD_##type##_FROM, _CR_FD_##type##_TO, flags)
+struct cr_fdset *cr_glob_fdset_open(int mode);
+
+void close_cr_fdset(struct cr_fdset **cr_fdset);
+
+#endif
diff --git a/ipc_ns.c b/ipc_ns.c
index aab47c0..318e98b 100644
--- a/ipc_ns.c
+++ b/ipc_ns.c
@@ -9,6 +9,7 @@
 
 #include "util.h"
 #include "crtools.h"
+#include "fdset.h"
 #include "syscall.h"
 #include "namespaces.h"
 #include "sysctl.h"
diff --git a/namespaces.c b/namespaces.c
index 31ce2fd..ee88e31 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -3,6 +3,7 @@
 #include <sys/wait.h>
 #include <stdlib.h>
 #include "util.h"
+#include "fdset.h"
 #include "syscall.h"
 #include "uts_ns.h"
 #include "ipc_ns.h"
diff --git a/net.c b/net.c
index 6037ff6..57a755e 100644
--- a/net.c
+++ b/net.c
@@ -8,6 +8,7 @@
 #include <sched.h>
 #include <sys/mount.h>
 
+#include "fdset.h"
 #include "syscall-types.h"
 #include "namespaces.h"
 #include "net.h"
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 133afeb..f3c6478 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -12,6 +12,7 @@
 #include "protobuf/core.pb-c.h"
 #include "protobuf/pagemap.pb-c.h"
 
+#include "fdset.h"
 #include "syscall.h"
 #include "ptrace.h"
 #include "asm/processor-flags.h"
diff --git a/pipes.c b/pipes.c
index b5d141a..019ca8f 100644
--- a/pipes.c
+++ b/pipes.c
@@ -6,6 +6,7 @@
 #include <sys/mman.h>
 
 #include "crtools.h"
+#include "fdset.h"
 #include "image.h"
 #include "files.h"
 #include "pipes.h"
diff --git a/signalfd.c b/signalfd.c
index 1c91157..daceda8 100644
--- a/signalfd.c
+++ b/signalfd.c
@@ -7,6 +7,7 @@
 #include "signalfd.h"
 #include "proc_parse.h"
 #include "crtools.h"
+#include "fdset.h"
 #include "image.h"
 #include "util.h"
 #include "log.h"
diff --git a/sk-inet.c b/sk-inet.c
index 1c0dbf0..69e7548 100644
--- a/sk-inet.c
+++ b/sk-inet.c
@@ -12,6 +12,7 @@
 #include "asm/types.h"
 #include "libnetlink.h"
 #include "crtools.h"
+#include "fdset.h"
 #include "inet_diag.h"
 #include "files.h"
 #include "image.h"
diff --git a/sk-netlink.c b/sk-netlink.c
index f519cf4..ac662e9 100644
--- a/sk-netlink.c
+++ b/sk-netlink.c
@@ -4,6 +4,7 @@
 #include <poll.h>
 
 #include "crtools.h"
+#include "fdset.h"
 #include "files.h"
 #include "sockets.h"
 #include "util.h"
diff --git a/sk-packet.c b/sk-packet.c
index dcc7af3..2ed7ca6 100644
--- a/sk-packet.c
+++ b/sk-packet.c
@@ -5,6 +5,7 @@
 #include <unistd.h>
 #include <string.h>
 #include "asm/types.h"
+#include "fdset.h"
 #include "files.h"
 #include "sockets.h"
 #include "libnetlink.h"
diff --git a/sk-queue.c b/sk-queue.c
index 5896e97..b2eb08f 100644
--- a/sk-queue.c
+++ b/sk-queue.c
@@ -12,6 +12,7 @@
 
 #include "asm/types.h"
 #include "list.h"
+#include "fdset.h"
 #include "image.h"
 #include "crtools.h"
 #include "util.h"
diff --git a/sk-unix.c b/sk-unix.c
index c8bc09c..3045489 100644
--- a/sk-unix.c
+++ b/sk-unix.c
@@ -11,6 +11,7 @@
 #include "asm/types.h"
 #include "libnetlink.h"
 #include "crtools.h"
+#include "fdset.h"
 #include "unix_diag.h"
 #include "files.h"
 #include "file-ids.h"
diff --git a/tty.c b/tty.c
index 98c6698..d1ac692 100644
--- a/tty.c
+++ b/tty.c
@@ -18,6 +18,7 @@
 #include "syscall.h"
 #include "files.h"
 #include "crtools.h"
+#include "fdset.h"
 #include "servicefd.h"
 #include "image.h"
 #include "util.h"
diff --git a/tun.c b/tun.c
index 07be911..d484e31 100644
--- a/tun.c
+++ b/tun.c
@@ -5,6 +5,7 @@
 #include <sys/ioctl.h>
 
 #include "crtools.h"
+#include "fdset.h"
 #include "protobuf.h"
 #include "cr-show.h"
 #include "string.h"
-- 
1.8.3.1



More information about the CRIU mailing list