[CRIU] [PATCH 02/16] proc_parse: parse mnt_id from /proc/PID/fdinfo/FD

Andrey Vagin avagin at openvz.org
Tue Apr 8 16:34:54 PDT 2014


It will be used for restoring files from proper mounts.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 files.c              | 2 +-
 include/proc_parse.h | 1 +
 proc_parse.c         | 5 ++++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/files.c b/files.c
index 28faf0b..e2ebeb6 100644
--- a/files.c
+++ b/files.c
@@ -205,7 +205,7 @@ static int fill_fd_params(struct parasite_ctl *ctl, int fd, int lfd,
 {
 	int ret;
 	struct statfs fsbuf;
-	struct fdinfo_common fdinfo;
+	struct fdinfo_common fdinfo = {.mnt_id = -1};
 
 	if (fstat(lfd, &p->stat) < 0) {
 		pr_perror("Can't stat fd %d", lfd);
diff --git a/include/proc_parse.h b/include/proc_parse.h
index aa30dd4..c42a48c 100644
--- a/include/proc_parse.h
+++ b/include/proc_parse.h
@@ -157,6 +157,7 @@ union fdinfo_entries {
 struct fdinfo_common {
 	off64_t pos;
 	int flags;
+	int mnt_id;
 };
 
 extern int parse_fdinfo(int fd, int type,
diff --git a/proc_parse.c b/proc_parse.c
index 972e3d5..b90a79d 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -1021,7 +1021,8 @@ static int parse_fdinfo_pid_s(char *pid, int fd, int type,
 		union fdinfo_entries entry;
 
 		if (fdinfo_field(str, "pos") ||
-		    fdinfo_field(str, "flags")) {
+		    fdinfo_field(str, "flags") ||
+		    fdinfo_field(str, "mnt_id")) {
 			unsigned long long val;
 			struct fdinfo_common *fdinfo = arg;
 
@@ -1035,6 +1036,8 @@ static int parse_fdinfo_pid_s(char *pid, int fd, int type,
 				fdinfo->pos = val;
 			else if (fdinfo_field(str, "flags"))
 				fdinfo->flags = val;
+			else if (fdinfo_field(str, "mnt_id"))
+				fdinfo->mnt_id = val;
 
 			entry_met = true;
 			continue;
-- 
1.8.5.3



More information about the CRIU mailing list