Commit 962af529 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

fsnotify: Add dumping of fanotify objects

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent d5927a47
...@@ -332,6 +332,8 @@ static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_op ...@@ -332,6 +332,8 @@ static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_op
return dump_eventpoll(&p, lfd, fdinfo); return dump_eventpoll(&p, lfd, fdinfo);
else if (is_inotify_link(lfd)) else if (is_inotify_link(lfd))
return dump_inotify(&p, lfd, fdinfo); return dump_inotify(&p, lfd, fdinfo);
else if (is_fanotify_link(lfd))
return dump_fanotify(&p, lfd, fdinfo);
else if (is_signalfd_link(lfd)) else if (is_signalfd_link(lfd))
return dump_signalfd(&p, lfd, fdinfo); return dump_signalfd(&p, lfd, fdinfo);
else else
......
...@@ -135,6 +135,66 @@ int dump_inotify(struct fd_parms *p, int lfd, const int fdinfo) ...@@ -135,6 +135,66 @@ int dump_inotify(struct fd_parms *p, int lfd, const int fdinfo)
return do_dump_gen_file(p, lfd, &inotify_ops, fdinfo); return do_dump_gen_file(p, lfd, &inotify_ops, fdinfo);
} }
static int dump_fanotify_entry(union fdinfo_entries *e, void *arg)
{
struct fsnotify_params *fsn_params = arg;
FanotifyMarkEntry *fme = &e->ffy;
fme->id = fsn_params->id;
pr_info("mark: s_dev 0x%08x i_ino 0x%016lx mask 0x%08x\n",
fme->s_dev, fme->i_ino, fme->mask);
if (fme->type == MARK_TYPE__INODE)
pr_info("\t[fhandle] bytes 0x%08x type 0x%08x __handle 0x%016lx:0x%016lx\n",
fme->f_handle->bytes, fme->f_handle->type,
fme->f_handle->handle[0], fme->f_handle->handle[1]);
if (fme->type == MARK_TYPE__MOUNT) {
struct mount_info *m;
m = lookup_mnt_id(fme->mnt_id);
if (!m) {
pr_err("Can't find mnt_id %x\n", fme->mnt_id);
return -1;
}
fme->s_dev = m->s_dev;
}
return pb_write_one(fdset_fd(glob_fdset, CR_FD_FANOTIFY_MARK), fme, PB_FANOTIFY_MARK);
}
static int dump_one_fanotify(int lfd, u32 id, const struct fd_parms *p)
{
FanotifyFileEntry fe = FANOTIFY_FILE_ENTRY__INIT;
struct fsnotify_params fsn_params = { .id = id, };
fe.id = id;
fe.flags = p->flags;
fe.fown = (FownEntry *)&p->fown;
if (parse_fdinfo(lfd, FD_TYPES__FANOTIFY,
dump_fanotify_entry, &fsn_params) < 0)
return -1;
pr_info("id 0x%08x flags 0x%08x\n", fe.id, fe.flags);
fe.faflags = fsn_params.faflags;
fe.evflags = fsn_params.evflags;
return pb_write_one(fdset_fd(glob_fdset, CR_FD_FANOTIFY), &fe, PB_FANOTIFY);
}
static const struct fdtype_ops fanotify_ops = {
.type = FD_TYPES__FANOTIFY,
.dump = dump_one_fanotify,
};
int dump_fanotify(struct fd_parms *p, int lfd, const int fdinfo)
{
return do_dump_gen_file(p, lfd, &fanotify_ops, fdinfo);
}
static char *get_mark_path(const char *who, struct file_remap *remap, static char *get_mark_path(const char *who, struct file_remap *remap,
FhEntry *f_handle, unsigned long i_ino, FhEntry *f_handle, unsigned long i_ino,
unsigned int s_dev, char *buf, size_t size, unsigned int s_dev, char *buf, size_t size,
......
...@@ -18,6 +18,7 @@ struct fsnotify_params { ...@@ -18,6 +18,7 @@ struct fsnotify_params {
extern int is_inotify_link(int lfd); extern int is_inotify_link(int lfd);
extern int is_fanotify_link(int lfd); extern int is_fanotify_link(int lfd);
extern int dump_inotify(struct fd_parms *p, int lfd, const int fdinfo); extern int dump_inotify(struct fd_parms *p, int lfd, const int fdinfo);
extern int dump_fanotify(struct fd_parms *p, int lfd, const int fdinfo);
extern int collect_inotify(void); extern int collect_inotify(void);
extern void show_inotify_wd(int fd_inotify_wd, struct cr_options *o); extern void show_inotify_wd(int fd_inotify_wd, struct cr_options *o);
extern void show_inotify(int fd_inotify, struct cr_options *o); extern void show_inotify(int fd_inotify, struct cr_options *o);
......
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