[CRIU] [PATCH 24/28] dump: do not dump fdinfo entry for vma files

Kinsbursky Stanislav skinsbursky at openvz.org
Thu Mar 22 14:00:12 EDT 2012


From: Stanislav Kinsbursky <skinsbursky at openvz.org>

This patch also makes search for vma files by map by vma->shmid.

Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
 cr-dump.c |    6 +++---
 files.c   |   44 ++++++++++++++------------------------------
 2 files changed, 17 insertions(+), 33 deletions(-)
-------------- next part --------------
diff --git a/cr-dump.c b/cr-dump.c
index 7fb9e83..96cfe60 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -148,14 +148,14 @@ static int dump_one_reg_file(struct file_entry *p, pid_t pid,
 			return -1;
 	}
 
+	if (fd_is_special(fde))
+		return id;
+
 	pr_info("fdinfo: type: %2x len: %2x flags: %4x pos: %8lx addr: %16lx\n",
 		p->type, len, p->flags, p->pos, target_fd);
 
-	e.addr = target_fd;
 	if (write_img(cr_fdset->fds[CR_FD_FDINFO], &e))
 		return -1;
-	if (fd_is_special(fde))
-		return id;
 	return 0;
 }
 
diff --git a/files.c b/files.c
index 4bc9f08..6f4bc70 100644
--- a/files.c
+++ b/files.c
@@ -432,22 +432,13 @@ int prepare_fds(int pid)
 				 * so simply skip it for a while.
 				 */
 				continue;
-
-			if (fd_is_special(&fe.fde)) {
-				if  (state == FD_STATE_RECV)
-					if (collect_fmap(pid, &fe, fdinfo_fd))
-						goto err;
-
-				lseek(fdinfo_fd, fe.len, SEEK_CUR);
+			if (fe.fde.type == FDINFO_MAP)
 				continue;
-			}
 
 			offset = lseek(fdinfo_fd, 0, SEEK_CUR);
 
 			if (open_fdinfo(pid, &fe.fde, &fdinfo_fd, state))
 				goto err;
-
-			lseek(fdinfo_fd, offset + fe.len, SEEK_SET);
 		}
 	}
 	BUG_ON(cwd_id == 0);
@@ -480,27 +471,20 @@ static struct fmap_fd *pull_fmap_fd(int pid, unsigned long start)
 
 int get_filemap_fd(int pid, struct vma_entry *vma_entry)
 {
-	struct fmap_fd *fmap_fd = pull_fmap_fd(pid, vma_entry->start);
-
-	if (fmap_fd) {
-		struct file_info *fi;
-		const struct file_entry *rfe;
-		int fd;
+	struct file_info *fi;
+	int fd;
 
-		fi = file_search(FDINFO_MAP, fmap_fd->id);
-		if (fi == NULL) {
-			pr_err("Failed to find map shared file: id %d\n\n", fmap_fd->id);
-			return -1;
-		}
-		rfe = fi->rfe;
+	fi = file_search(FDINFO_MAP, vma_entry->shmid);
+	if (fi == NULL) {
+		pr_err("Failed to find map shared file: id %ld\n\n", vma_entry->shmid);
+		return -1;
+	}
 
-		fd = open((char *)rfe->name, rfe->flags);
-		if (fd < 0) {
-			pr_perror("Can't open file %s", rfe->name);
-			return -1;
-		}
-		lseek(fd, rfe->pos, SEEK_SET);
-		return fd;
+	fd = open((char *)fi->rfe->name, fi->rfe->flags);
+	if (fd < 0) {
+		pr_perror("Can't open file %s", fi->rfe->name);
+		return -1;
 	}
-	return -1;
+	lseek(fd, fi->rfe->pos, SEEK_SET);
+	return fd;
 }


More information about the CRIU mailing list