From 2b816a593aa2cb640b1ccf0242420a18c26563c2 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Mon, 15 Oct 2012 23:42:50 +0400 Subject: [PATCH] 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: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- cr-dump.c | 13 +++++++------ include/files.h | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cr-dump.c b/cr-dump.c index 4e8a7ae3e..fdd7810ed 100644 --- a/cr-dump.c +++ b/cr-dump.c @@ -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; diff --git a/include/files.h b/include/files.h index cc0e46faf..4bdc9fe24 100644 --- a/include/files.h +++ b/include/files.h @@ -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 \