[CRIU] [PATCH 4/4] proc: move parts about fdinfo from proc_parse.h into fdinfo.h

Andrei Vagin avagin at openvz.org
Tue Aug 16 08:22:25 PDT 2016


From: Andrei Vagin <avagin at virtuozzo.com>

proc_parse.h is too generic and it is a bad idea to include it everywhere.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/autofs.c             |  2 +-
 criu/cr-check.c           |  2 +-
 criu/eventfd.c            |  2 +-
 criu/eventpoll.c          |  2 +-
 criu/files.c              |  2 +-
 criu/fsnotify.c           |  2 +-
 criu/include/autofs.h     |  2 ++
 criu/include/fdinfo.h     | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 criu/include/proc_parse.h | 52 ------------------------------------------
 criu/proc_parse.c         |  1 +
 criu/signalfd.c           |  2 +-
 criu/timerfd.c            |  2 +-
 12 files changed, 69 insertions(+), 60 deletions(-)
 create mode 100644 criu/include/fdinfo.h

diff --git a/criu/autofs.c b/criu/autofs.c
index 6b2fa7e..3db060a 100644
--- a/criu/autofs.c
+++ b/criu/autofs.c
@@ -4,7 +4,7 @@
 #include <sys/mount.h>
 #include <sys/wait.h>
 
-#include "proc_parse.h"
+#include "fdinfo.h"
 #include "autofs.h"
 #include "rst-malloc.h"
 #include "mount.h"
diff --git a/criu/cr-check.c b/criu/cr-check.c
index b639afb..2bee096 100644
--- a/criu/cr-check.c
+++ b/criu/cr-check.c
@@ -23,7 +23,7 @@
 #include <linux/aio_abi.h>
 #include <sys/mount.h>
 
-#include "proc_parse.h"
+#include "fdinfo.h"
 #include "sockets.h"
 #include "crtools.h"
 #include "log.h"
diff --git a/criu/eventfd.c b/criu/eventfd.c
index 887c2db..f120886 100644
--- a/criu/eventfd.c
+++ b/criu/eventfd.c
@@ -16,7 +16,7 @@
 #include "asm/types.h"
 #include "imgset.h"
 #include "eventfd.h"
-#include "proc_parse.h"
+#include "fdinfo.h"
 #include "image.h"
 #include "util.h"
 #include "log.h"
diff --git a/criu/eventpoll.c b/criu/eventpoll.c
index 38afeef..5ecabe1 100644
--- a/criu/eventpoll.c
+++ b/criu/eventpoll.c
@@ -17,7 +17,7 @@
 #include "imgset.h"
 #include "rst_info.h"
 #include "eventpoll.h"
-#include "proc_parse.h"
+#include "fdinfo.h"
 #include "image.h"
 #include "util.h"
 #include "log.h"
diff --git a/criu/files.c b/criu/files.c
index 8c0da76..7e7e3a5 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -37,7 +37,7 @@
 #include "timerfd.h"
 #include "imgset.h"
 #include "fs-magic.h"
-#include "proc_parse.h"
+#include "fdinfo.h"
 #include "cr_options.h"
 #include "autofs.h"
 
diff --git a/criu/fsnotify.c b/criu/fsnotify.c
index 022aed8..f1e66d0 100644
--- a/criu/fsnotify.c
+++ b/criu/fsnotify.c
@@ -26,7 +26,7 @@
 #include "asm/types.h"
 #include "imgset.h"
 #include "fsnotify.h"
-#include "proc_parse.h"
+#include "fdinfo.h"
 #include "mount.h"
 #include "image.h"
 #include "util.h"
diff --git a/criu/include/autofs.h b/criu/include/autofs.h
index f7df6ab..d294277 100644
--- a/criu/include/autofs.h
+++ b/criu/include/autofs.h
@@ -5,6 +5,8 @@
 #define AUTOFS_MINOR	235
 #endif
 
+#include <stdbool.h>
+
 bool is_autofs_pipe(unsigned long inode);
 
 struct mount_info;
diff --git a/criu/include/fdinfo.h b/criu/include/fdinfo.h
new file mode 100644
index 0000000..3cabadd
--- /dev/null
+++ b/criu/include/fdinfo.h
@@ -0,0 +1,58 @@
+#ifndef __CR_FDINFO_H__
+#define __CR_FDINFO_H__
+
+#include "list.h"
+
+#include "images/eventfd.pb-c.h"
+#include "images/eventpoll.pb-c.h"
+#include "images/signalfd.pb-c.h"
+#include "images/fsnotify.pb-c.h"
+#include "images/timerfd.pb-c.h"
+
+struct inotify_wd_entry {
+	InotifyWdEntry e;
+	FhEntry f_handle;
+	struct list_head node;
+};
+
+struct fanotify_mark_entry {
+	FanotifyMarkEntry e;
+	FhEntry f_handle;
+	struct list_head node;
+	union {
+		FanotifyInodeMarkEntry ie;
+		FanotifyMountMarkEntry me;
+	};
+};
+
+struct eventpoll_tfd_entry {
+	EventpollTfdEntry e;
+	struct list_head node;
+};
+
+union fdinfo_entries {
+	EventfdFileEntry efd;
+	SignalfdEntry sfd;
+	struct inotify_wd_entry ify;
+	struct fanotify_mark_entry ffy;
+	struct eventpoll_tfd_entry epl;
+	TimerfdEntry tfy;
+};
+
+extern void free_inotify_wd_entry(union fdinfo_entries *e);
+extern void free_fanotify_mark_entry(union fdinfo_entries *e);
+extern void free_event_poll_entry(union fdinfo_entries *e);
+
+struct fdinfo_common {
+	off64_t pos;
+	int flags;
+	int mnt_id;
+	int owner;
+};
+
+extern int parse_fdinfo(int fd, int type,
+		int (*cb)(union fdinfo_entries *e, void *arg), void *arg);
+extern int parse_fdinfo_pid(int pid, int fd, int type,
+		int (*cb)(union fdinfo_entries *e, void *arg), void *arg);
+
+#endif
diff --git a/criu/include/proc_parse.h b/criu/include/proc_parse.h
index a530f49..fb0d643 100644
--- a/criu/include/proc_parse.h
+++ b/criu/include/proc_parse.h
@@ -3,13 +3,7 @@
 
 #include <sys/types.h>
 #include "asm/types.h"
-#include "list.h"
 
-#include "images/eventfd.pb-c.h"
-#include "images/eventpoll.pb-c.h"
-#include "images/signalfd.pb-c.h"
-#include "images/fsnotify.pb-c.h"
-#include "images/timerfd.pb-c.h"
 #include "images/seccomp.pb-c.h"
 
 #define PROC_TASK_COMM_LEN	32
@@ -110,52 +104,6 @@ extern unsigned int parse_pid_loginuid(pid_t pid, int *err, bool ignore_noent);
 extern int parse_pid_oom_score_adj(pid_t pid, int *err);
 extern int prepare_loginuid(unsigned int value, unsigned int loglevel);
 extern int parse_pid_status(pid_t pid, struct proc_status_creds *);
-
-struct inotify_wd_entry {
-	InotifyWdEntry e;
-	FhEntry f_handle;
-	struct list_head node;
-};
-
-struct fanotify_mark_entry {
-	FanotifyMarkEntry e;
-	FhEntry f_handle;
-	struct list_head node;
-	union {
-		FanotifyInodeMarkEntry ie;
-		FanotifyMountMarkEntry me;
-	};
-};
-
-struct eventpoll_tfd_entry {
-	EventpollTfdEntry e;
-	struct list_head node;
-};
-
-union fdinfo_entries {
-	EventfdFileEntry efd;
-	SignalfdEntry sfd;
-	struct inotify_wd_entry ify;
-	struct fanotify_mark_entry ffy;
-	struct eventpoll_tfd_entry epl;
-	TimerfdEntry tfy;
-};
-
-extern void free_inotify_wd_entry(union fdinfo_entries *e);
-extern void free_fanotify_mark_entry(union fdinfo_entries *e);
-extern void free_event_poll_entry(union fdinfo_entries *e);
-
-struct fdinfo_common {
-	off64_t pos;
-	int flags;
-	int mnt_id;
-	int owner;
-};
-
-extern int parse_fdinfo(int fd, int type,
-		int (*cb)(union fdinfo_entries *e, void *arg), void *arg);
-extern int parse_fdinfo_pid(int pid, int fd, int type,
-		int (*cb)(union fdinfo_entries *e, void *arg), void *arg);
 extern int parse_file_locks(void);
 extern int get_fd_mntid(int fd, int *mnt_id);
 
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index 7bbdad3..49d6c1a 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -25,6 +25,7 @@
 #include "vma.h"
 #include "bfd.h"
 #include "proc_parse.h"
+#include "fdinfo.h"
 #include "parasite.h"
 #include "cr_options.h"
 #include "sysfs_parse.h"
diff --git a/criu/signalfd.c b/criu/signalfd.c
index 064ebda..c992274 100644
--- a/criu/signalfd.c
+++ b/criu/signalfd.c
@@ -5,7 +5,7 @@
 #include "compiler.h"
 #include "asm/types.h"
 #include "signalfd.h"
-#include "proc_parse.h"
+#include "fdinfo.h"
 #include "imgset.h"
 #include "image.h"
 #include "util.h"
diff --git a/criu/timerfd.c b/criu/timerfd.c
index 55f7b85..83b92b3 100644
--- a/criu/timerfd.c
+++ b/criu/timerfd.c
@@ -8,7 +8,7 @@
 #include "protobuf.h"
 #include "images/timerfd.pb-c.h"
 
-#include "proc_parse.h"
+#include "fdinfo.h"
 #include "rst-malloc.h"
 #include "cr_options.h"
 #include "restorer.h"
-- 
2.7.4



More information about the CRIU mailing list