Commit 54fb48d7 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

signalfd: Rework parse_fdinfo no to use callback

Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent c94d0cac
...@@ -302,11 +302,6 @@ static int check_fdinfo_eventfd(void) ...@@ -302,11 +302,6 @@ static int check_fdinfo_eventfd(void)
return 0; return 0;
} }
static int check_one_sfd(union fdinfo_entries *e, void *arg)
{
return 0;
}
int check_mnt_id(void) int check_mnt_id(void)
{ {
struct fdinfo_common fdinfo = { .mnt_id = -1 }; struct fdinfo_common fdinfo = { .mnt_id = -1 };
...@@ -328,6 +323,7 @@ static int check_fdinfo_signalfd(void) ...@@ -328,6 +323,7 @@ static int check_fdinfo_signalfd(void)
{ {
int fd, ret; int fd, ret;
sigset_t mask; sigset_t mask;
SignalfdEntry sfd = SIGNALFD_ENTRY__INIT;
sigemptyset(&mask); sigemptyset(&mask);
sigaddset(&mask, SIGUSR1); sigaddset(&mask, SIGUSR1);
...@@ -337,7 +333,7 @@ static int check_fdinfo_signalfd(void) ...@@ -337,7 +333,7 @@ static int check_fdinfo_signalfd(void)
return -1; return -1;
} }
ret = parse_fdinfo(fd, FD_TYPES__SIGNALFD, check_one_sfd, NULL); ret = parse_fdinfo(fd, FD_TYPES__SIGNALFD, NULL, &sfd);
close(fd); close(fd);
if (ret) { if (ret) {
......
...@@ -31,7 +31,6 @@ struct eventpoll_tfd_entry { ...@@ -31,7 +31,6 @@ struct eventpoll_tfd_entry {
}; };
union fdinfo_entries { union fdinfo_entries {
SignalfdEntry sfd;
struct inotify_wd_entry ify; struct inotify_wd_entry ify;
struct fanotify_mark_entry ffy; struct fanotify_mark_entry ffy;
struct eventpoll_tfd_entry epl; struct eventpoll_tfd_entry epl;
......
...@@ -1768,17 +1768,14 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type, ...@@ -1768,17 +1768,14 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type,
continue; continue;
} }
if (fdinfo_field(str, "sigmask")) { if (fdinfo_field(str, "sigmask")) {
signalfd_entry__init(&entry.sfd); SignalfdEntry *sfd = arg;
if (type != FD_TYPES__SIGNALFD) if (type != FD_TYPES__SIGNALFD)
goto parse_err; goto parse_err;
ret = sscanf(str, "sigmask: %Lx", ret = sscanf(str, "sigmask: %Lx",
(unsigned long long *)&entry.sfd.sigmask); (unsigned long long *)&sfd->sigmask);
if (ret != 1) if (ret != 1)
goto parse_err; goto parse_err;
ret = cb(&entry, arg);
if (ret)
goto out;
entry_met = true; entry_met = true;
continue; continue;
......
...@@ -24,34 +24,19 @@ int is_signalfd_link(char *link) ...@@ -24,34 +24,19 @@ int is_signalfd_link(char *link)
return is_anon_link_type(link, "[signalfd]"); return is_anon_link_type(link, "[signalfd]");
} }
struct signalfd_dump_arg { static int dump_one_signalfd(int lfd, u32 id, const struct fd_parms *p)
u32 id;
const struct fd_parms *p;
bool dumped;
};
static int dump_signalfd_entry(union fdinfo_entries *e, void *arg)
{ {
struct signalfd_dump_arg *da = arg; SignalfdEntry sfd = SIGNALFD_ENTRY__INIT;
if (da->dumped) { if (parse_fdinfo(lfd, FD_TYPES__SIGNALFD, NULL, &sfd))
pr_err("Several counters in a file?\n");
return -1; return -1;
}
da->dumped = true; sfd.id = id;
e->sfd.id = da->id; sfd.flags = p->flags;
e->sfd.flags = da->p->flags; sfd.fown = (FownEntry *)&p->fown;
e->sfd.fown = (FownEntry *)&da->p->fown;
return pb_write_one(img_from_set(glob_imgset, CR_FD_SIGNALFD), return pb_write_one(img_from_set(glob_imgset, CR_FD_SIGNALFD),
&e->sfd, PB_SIGNALFD); &sfd, PB_SIGNALFD);
}
static int dump_one_signalfd(int lfd, u32 id, const struct fd_parms *p)
{
struct signalfd_dump_arg da = { .id = id, .p = p, };
return parse_fdinfo(lfd, FD_TYPES__SIGNALFD, dump_signalfd_entry, &da);
} }
const struct fdtype_ops signalfd_dump_ops = { const struct fdtype_ops signalfd_dump_ops = {
......
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