Commit 67c572df authored by Pavel Emelyanov's avatar Pavel Emelyanov

fd: Helper for local fd dump

An aux code to dump the received file and report back its
ID and type.
Reviewed-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 858f1509
...@@ -529,6 +529,23 @@ static int dump_one_file(struct pid *pid, int fd, int lfd, struct fd_opts *opts, ...@@ -529,6 +529,23 @@ static int dump_one_file(struct pid *pid, int fd, int lfd, struct fd_opts *opts,
return dump_unsupp_fd(&p, lfd, "unknown", link.name + 1, e); return dump_unsupp_fd(&p, lfd, "unknown", link.name + 1, e);
} }
int dump_my_file(int lfd, u32 *id, int *type)
{
struct pid me = {};
struct fd_opts fo = {};
FdinfoEntry e = FDINFO_ENTRY__INIT;
me.real = getpid();
me.ns[0].virt = -1; /* FIXME */
if (dump_one_file(&me, lfd, lfd, &fo, NULL, &e))
return -1;
*id = e.id;
*type = e.type;
return 0;
}
int dump_task_files_seized(struct parasite_ctl *ctl, struct pstree_item *item, int dump_task_files_seized(struct parasite_ctl *ctl, struct pstree_item *item,
struct parasite_drain_fd *dfds) struct parasite_drain_fd *dfds)
{ {
......
...@@ -133,6 +133,7 @@ struct fdtype_ops { ...@@ -133,6 +133,7 @@ struct fdtype_ops {
struct cr_img; struct cr_img;
extern int dump_my_file(int lfd, u32 *, int *type);
extern int do_dump_gen_file(struct fd_parms *p, int lfd, extern int do_dump_gen_file(struct fd_parms *p, int lfd,
const struct fdtype_ops *ops, const struct fdtype_ops *ops,
FdinfoEntry *e); FdinfoEntry *e);
......
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