Commit 2b816a59 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

dump: Make struct fd_parms to carry @parasite_ctl pointer

Some file-type specific parameters can be fetched with
parasite code only, so lets carry parasite control block
pointer in struct fd_parms.

This is a bit ugly but requires less code to touch and
enough for now. In long terms we need some more generalized
routine/hooks which would depends on file type.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent a9241a23
......@@ -187,7 +187,7 @@ static int dump_task_exe_link(pid_t pid, MmEntry *mm)
return ret;
}
static int fill_fd_params(pid_t pid, int fd, int lfd,
static int fill_fd_params(struct parasite_ctl *ctl, int fd, int lfd,
struct fd_opts *opts, struct fd_parms *p)
{
if (fstat(lfd, &p->stat) < 0) {
......@@ -195,16 +195,17 @@ static int fill_fd_params(pid_t pid, int fd, int lfd,
return -1;
}
p->ctl = ctl;
p->fd = fd;
p->pos = lseek(lfd, 0, SEEK_CUR);
p->flags = fcntl(lfd, F_GETFL);
p->pid = pid;
p->pid = ctl->pid;
p->fd_flags = opts->flags;
fown_entry__init(&p->fown);
pr_info("%d fdinfo %d: pos: 0x%16lx flags: %16o/%#x\n",
pid, fd, p->pos, p->flags, (int)p->fd_flags);
ctl->pid, fd, p->pos, p->flags, (int)p->fd_flags);
p->fown.signum = fcntl(lfd, F_GETSIG, 0);
if (p->fown.signum < 0) {
......@@ -250,13 +251,13 @@ static int dump_chrdev(struct fd_parms *p, int lfd, const struct cr_fdset *set)
#define PIPEFS_MAGIC 0x50495045
#endif
static int dump_one_file(pid_t pid, int fd, int lfd, struct fd_opts *opts,
static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_opts *opts,
const struct cr_fdset *cr_fdset)
{
struct fd_parms p;
struct statfs statfs;
if (fill_fd_params(pid, fd, lfd, opts, &p) < 0) {
if (fill_fd_params(ctl, fd, lfd, opts, &p) < 0) {
pr_perror("Can't get stat on %d", fd);
return -1;
}
......@@ -322,7 +323,7 @@ static int dump_task_files_seized(struct parasite_ctl *ctl, const struct cr_fdse
goto err2;
for (i = 0; i < dfds->nr_fds; i++) {
ret = dump_one_file(ctl->pid, dfds->fds[i], lfds[i], opts + i, cr_fdset);
ret = dump_one_file(ctl, dfds->fds[i], lfds[i], opts + i, cr_fdset);
close(lfds[i]);
if (ret)
goto err2;
......
......@@ -15,6 +15,7 @@ struct pstree_item;
struct file_desc;
struct cr_fdset;
struct rst_info;
struct parasite_ctl;
struct fd_parms {
int fd;
......@@ -24,6 +25,8 @@ struct fd_parms {
struct stat stat;
pid_t pid;
FownEntry fown;
struct parasite_ctl *ctl;
};
#define FD_PARMS_INIT \
......
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