[CRIU] [PATCH 08/16] dump: hide id set into read_fd_params()
Kinsbursky Stanislav
skinsbursky at openvz.org
Thu Mar 1 12:57:09 EST 2012
Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
cr-dump.c | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/cr-dump.c b/cr-dump.c
index ae12b1e..01015e3 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -286,7 +286,7 @@ err:
return ret;
}
-static int read_fd_params(pid_t pid, char *fd, struct fd_parms *p)
+static int read_fd_params(pid_t pid, char *fd, struct stat *fd_stat, struct fd_parms *p)
{
FILE *file;
int ret;
@@ -309,7 +309,11 @@ static int read_fd_params(pid_t pid, char *fd, struct fd_parms *p)
p->pid = pid;
p->id = FD_ID_INVALID;
-
+ 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);
+ p->type = FDINFO_FD;
+ }
return 0;
}
@@ -323,7 +327,12 @@ static int dump_one_fd(pid_t pid, char *d_name, struct cr_fdset *cr_fdset,
char file_path[128];
snprintf(file_path, sizeof(file_path), "/proc/%d/fd/%s", pid, d_name);
- if (read_fd_params(pid, d_name, &p))
+ if (stat(file_path, &fd_stat)) {
+ pr_perror("Can't stat %s", file_path);
+ return -1;
+ }
+
+ if (read_fd_params(pid, d_name, &fd_stat, &p))
return -1;
lfd = open(file_path, O_RDONLY);
@@ -336,11 +345,6 @@ static int dump_one_fd(pid_t pid, char *d_name, struct cr_fdset *cr_fdset,
return -1;
}
- if (stat(file_path, &fd_stat)) {
- pr_perror("Can't stat %s", file_path);
- goto out_close;
- }
-
if (S_ISCHR(fd_stat.st_mode) &&
(major(fd_stat.st_rdev) == TTY_MAJOR ||
major(fd_stat.st_rdev) == UNIX98_PTY_SLAVE_MAJOR)) {
@@ -355,13 +359,8 @@ static int dump_one_fd(pid_t pid, char *d_name, struct cr_fdset *cr_fdset,
}
if (S_ISREG(fd_stat.st_mode) ||
- (S_ISCHR(fd_stat.st_mode) && major(fd_stat.st_rdev) == MEM_MAJOR)) {
-
- p.id = MAKE_FD_GENID(fd_stat.st_dev, fd_stat.st_ino, p.pos);
- p.type = FDINFO_FD;
-
+ (S_ISCHR(fd_stat.st_mode) && major(fd_stat.st_rdev) == MEM_MAJOR))
return dump_one_reg_file(&p, lfd, cr_fdset, 1);
- }
if (S_ISFIFO(fd_stat.st_mode))
return dump_one_pipe(&p, fd_stat.st_ino, lfd, cr_fdset);
More information about the CRIU
mailing list