Commit 81060211 authored by Kinsbursky Stanislav's avatar Kinsbursky Stanislav Committed by Cyrill Gorcunov

dump: hide fd type into fd_params structure

Signed-off-by: 's avatarStanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 42963b94
...@@ -90,12 +90,13 @@ struct fd_parms { ...@@ -90,12 +90,13 @@ struct fd_parms {
unsigned long fd_name; unsigned long fd_name;
unsigned long pos; unsigned long pos;
unsigned int flags; unsigned int flags;
unsigned int type;
u64 id; u64 id;
pid_t pid; pid_t pid;
}; };
static int dump_one_reg_file(int type, struct fd_parms *p, int lfd, static int dump_one_reg_file(struct fd_parms *p, int lfd,
struct cr_fdset *cr_fdset, struct cr_fdset *cr_fdset,
bool do_close_lfd) bool do_close_lfd)
{ {
...@@ -118,7 +119,7 @@ static int dump_one_reg_file(int type, struct fd_parms *p, int lfd, ...@@ -118,7 +119,7 @@ static int dump_one_reg_file(int type, struct fd_parms *p, int lfd,
if (do_close_lfd) if (do_close_lfd)
close(lfd); close(lfd);
e.type = type; e.type = p->type;
e.len = len; e.len = len;
e.flags = p->flags; e.flags = p->flags;
e.pos = p->pos; e.pos = p->pos;
...@@ -143,7 +144,7 @@ static int dump_one_reg_file(int type, struct fd_parms *p, int lfd, ...@@ -143,7 +144,7 @@ static int dump_one_reg_file(int type, struct fd_parms *p, int lfd,
e.id = FD_ID_INVALID; e.id = FD_ID_INVALID;
pr_info("fdinfo: type: %2x len: %2x flags: %4x pos: %8lx addr: %16lx\n", pr_info("fdinfo: type: %2x len: %2x flags: %4x pos: %8lx addr: %16lx\n",
type, len, p->flags, p->pos, p->fd_name); p->type, len, p->flags, p->pos, p->fd_name);
if (write_img(cr_fdset->fds[CR_FD_FDINFO], &e)) if (write_img(cr_fdset->fds[CR_FD_FDINFO], &e))
goto err; goto err;
...@@ -165,12 +166,13 @@ static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset) ...@@ -165,12 +166,13 @@ static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset)
.fd_name = FDINFO_CWD, .fd_name = FDINFO_CWD,
.id = FD_ID_INVALID, .id = FD_ID_INVALID,
.pid = FD_PID_INVALID, .pid = FD_PID_INVALID,
.type = FDINFO_FD,
}; };
fd = open_proc(pid, "cwd"); fd = open_proc(pid, "cwd");
if (fd < 0) if (fd < 0)
return -1; return -1;
ret = dump_one_reg_file(FDINFO_FD, &params, fd, cr_fdset, 1); ret = dump_one_reg_file(&params, fd, cr_fdset, 1);
if (ret) if (ret)
return ret; return ret;
...@@ -179,12 +181,13 @@ static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset) ...@@ -179,12 +181,13 @@ static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset)
.fd_name = FDINFO_EXE, .fd_name = FDINFO_EXE,
.id = FD_ID_INVALID, .id = FD_ID_INVALID,
.pid = FD_PID_INVALID, .pid = FD_PID_INVALID,
.type = FDINFO_FD,
}; };
fd = open_proc(pid, "exe"); fd = open_proc(pid, "exe");
if (fd < 0) if (fd < 0)
return -1; return -1;
ret = dump_one_reg_file(FDINFO_FD, &params, fd, cr_fdset, 1); ret = dump_one_reg_file(&params, fd, cr_fdset, 1);
return ret; return ret;
} }
...@@ -344,8 +347,9 @@ static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct cr_fdset ...@@ -344,8 +347,9 @@ static int dump_one_fd(pid_t pid, int pid_fd_dir, char *d_name, struct cr_fdset
(S_ISCHR(st_buf.st_mode) && major(st_buf.st_rdev) == MEM_MAJOR)) { (S_ISCHR(st_buf.st_mode) && major(st_buf.st_rdev) == MEM_MAJOR)) {
p.id = MAKE_FD_GENID(st_buf.st_dev, st_buf.st_ino, p.pos); p.id = MAKE_FD_GENID(st_buf.st_dev, st_buf.st_ino, p.pos);
p.type = FDINFO_FD;
return dump_one_reg_file(FDINFO_FD, &p, lfd, cr_fdset, 1); return dump_one_reg_file(&p, lfd, cr_fdset, 1);
} }
if (S_ISFIFO(st_buf.st_mode)) { if (S_ISFIFO(st_buf.st_mode)) {
...@@ -446,6 +450,7 @@ static int dump_task_mappings(pid_t pid, struct list_head *vma_area_list, struct ...@@ -446,6 +450,7 @@ static int dump_task_mappings(pid_t pid, struct list_head *vma_area_list, struct
.fd_name = vma->start, .fd_name = vma->start,
.id = FD_ID_INVALID, .id = FD_ID_INVALID,
.pid = pid, .pid = pid,
.type = FDINFO_MAP,
}; };
if (vma->prot & PROT_WRITE && if (vma->prot & PROT_WRITE &&
...@@ -454,7 +459,7 @@ static int dump_task_mappings(pid_t pid, struct list_head *vma_area_list, struct ...@@ -454,7 +459,7 @@ static int dump_task_mappings(pid_t pid, struct list_head *vma_area_list, struct
else else
p.flags = O_RDONLY; p.flags = O_RDONLY;
ret = dump_one_reg_file(FDINFO_MAP, &p, vma_area->vm_file_fd, cr_fdset, 0); ret = dump_one_reg_file(&p, vma_area->vm_file_fd, cr_fdset, 0);
if (ret) if (ret)
goto err; goto err;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment