[CRIU] [PATCH v2 02/11] dump: hide pararms id set into
read_fd_params()
Kinsbursky Stanislav
skinsbursky at openvz.org
Mon Mar 5 07:38:11 EST 2012
This is a cleanup patch - let's do all params task in one place.
Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
cr-dump.c | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/cr-dump.c b/cr-dump.c
index 01399b6..c2577f7 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -287,7 +287,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;
@@ -310,7 +310,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;
}
@@ -322,12 +326,9 @@ static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct cr_fdset
struct fd_parms p;
int lfd;
- if (read_fd_params(pid, d_name, &p))
- return -1;
-
lfd = openat(pid_fd_dir, d_name, O_RDONLY);
if (lfd < 0) {
- err = try_dump_socket(pid, p.fd_name, cr_fdset, sk_queue);
+ err = try_dump_socket(pid, atoi(d_name), cr_fdset, sk_queue);
if (err != 1)
return err;
@@ -340,6 +341,9 @@ static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct cr_fdset
goto out_close;
}
+ if (read_fd_params(pid, d_name, &fd_stat, &p))
+ return -1;
+
if (S_ISCHR(fd_stat.st_mode) &&
(major(fd_stat.st_rdev) == TTY_MAJOR ||
major(fd_stat.st_rdev) == UNIX98_PTY_SLAVE_MAJOR)) {
@@ -354,13 +358,8 @@ static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct 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