[CRIU] [PATCH v2 06/11] dump: add pid_fd_dir for fd params

Kinsbursky Stanislav skinsbursky at openvz.org
Mon Mar 5 07:38:39 EST 2012


Will be usefull later when fd reopen will be perfermed only where required.

Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>

---
 cr-dump.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index 39590b7..b880f8e 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -93,6 +93,7 @@ struct fd_parms {
 	unsigned int	flags;
 	unsigned int	type;
 	ino_t		ino;
+	int		pid_fd_dir;
 
 	u64		id;
 	pid_t		pid;
@@ -287,7 +288,8 @@ err:
 	return ret;
 }
 
-static int read_fd_params(pid_t pid, char *fd, struct stat *fd_stat, struct fd_parms *p)
+static int read_fd_params(pid_t pid, int pid_fd_dir, char *fd,
+			  struct stat *fd_stat, struct fd_parms *p)
 {
 	FILE *file;
 	int ret;
@@ -311,6 +313,7 @@ static int read_fd_params(pid_t pid, char *fd, struct stat *fd_stat, struct fd_p
 	p->pid	= pid;
 	p->id	= FD_ID_INVALID;
 	p->ino	= fd_stat->st_ino;
+	p->pid_fd_dir = pid_fd_dir;
 	p->type = 0;
 	if (S_ISREG(fd_stat->st_mode) || S_ISCHR(fd_stat->st_mode)) {
 		p->id = MAKE_FD_GENID(fd_stat->st_dev, fd_stat->st_ino, p->pos);
@@ -333,10 +336,10 @@ static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct cr_fdset
 		return -1;
 	}
 
-	if (read_fd_params(pid, d_name, &fd_stat, &p))
+	if (read_fd_params(pid, pid_fd_dir, d_name, &fd_stat, &p))
 		return -1;
 
-	lfd = openat(pid_fd_dir, d_name, O_RDONLY);
+	lfd = openat(p.pid_fd_dir, d_name, O_RDONLY);
 
 	switch (fd_stat.st_mode & S_IFMT) {
 	case S_IFCHR:
@@ -347,7 +350,7 @@ static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct cr_fdset
 				if (atoi(d_name) < 3) {
 					err = 0;
 					pr_info("... Skipping tty ... %d/%ld\n",
-						pid_fd_dir, p.fd_name);
+						p.pid_fd_dir, p.fd_name);
 				}
 			}
 			break;
@@ -367,7 +370,7 @@ static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct cr_fdset
 		if (err != 1)
 			return err;
 
-		pr_perror("Failed to open %d/%ld", pid_fd_dir, p.fd_name);
+		pr_perror("Failed to open %d/%ld", p.pid_fd_dir, p.fd_name);
 		return -1;
 	case S_IFDIR:
 	case S_IFLNK:



More information about the CRIU mailing list