[CRIU] [PATCH 2/7] signalfd: Rework parse_fdinfo no to use callback
Pavel Emelyanov
xemul at virtuozzo.com
Thu Jun 22 20:38:51 MSK 2017
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/cr-check.c | 8 ++------
criu/include/fdinfo.h | 1 -
criu/proc_parse.c | 7 ++-----
criu/signalfd.c | 29 +++++++----------------------
4 files changed, 11 insertions(+), 34 deletions(-)
diff --git a/criu/cr-check.c b/criu/cr-check.c
index 92de4bf..b626b1b 100644
--- a/criu/cr-check.c
+++ b/criu/cr-check.c
@@ -303,11 +303,6 @@ static int check_fdinfo_eventfd(void)
return 0;
}
-static int check_one_sfd(union fdinfo_entries *e, void *arg)
-{
- return 0;
-}
-
int check_mnt_id(void)
{
struct fdinfo_common fdinfo = { .mnt_id = -1 };
@@ -329,6 +324,7 @@ static int check_fdinfo_signalfd(void)
{
int fd, ret;
sigset_t mask;
+ SignalfdEntry sfd = SIGNALFD_ENTRY__INIT;
sigemptyset(&mask);
sigaddset(&mask, SIGUSR1);
@@ -338,7 +334,7 @@ static int check_fdinfo_signalfd(void)
return -1;
}
- ret = parse_fdinfo(fd, FD_TYPES__SIGNALFD, check_one_sfd, NULL);
+ ret = parse_fdinfo(fd, FD_TYPES__SIGNALFD, NULL, &sfd);
close(fd);
if (ret) {
diff --git a/criu/include/fdinfo.h b/criu/include/fdinfo.h
index 830b3fc..18e85ed 100644
--- a/criu/include/fdinfo.h
+++ b/criu/include/fdinfo.h
@@ -31,7 +31,6 @@ struct eventpoll_tfd_entry {
};
union fdinfo_entries {
- SignalfdEntry sfd;
struct inotify_wd_entry ify;
struct fanotify_mark_entry ffy;
struct eventpoll_tfd_entry epl;
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index 54f5931..e00b0da 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -1840,17 +1840,14 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type,
continue;
}
if (fdinfo_field(str, "sigmask")) {
- signalfd_entry__init(&entry.sfd);
+ SignalfdEntry *sfd = arg;
if (type != FD_TYPES__SIGNALFD)
goto parse_err;
ret = sscanf(str, "sigmask: %Lx",
- (unsigned long long *)&entry.sfd.sigmask);
+ (unsigned long long *)&sfd->sigmask);
if (ret != 1)
goto parse_err;
- ret = cb(&entry, arg);
- if (ret)
- goto out;
entry_met = true;
continue;
diff --git a/criu/signalfd.c b/criu/signalfd.c
index 7c3ab4f..660f510 100644
--- a/criu/signalfd.c
+++ b/criu/signalfd.c
@@ -24,34 +24,19 @@ int is_signalfd_link(char *link)
return is_anon_link_type(link, "[signalfd]");
}
-struct signalfd_dump_arg {
- u32 id;
- const struct fd_parms *p;
- bool dumped;
-};
-
-static int dump_signalfd_entry(union fdinfo_entries *e, void *arg)
+static int dump_one_signalfd(int lfd, u32 id, const struct fd_parms *p)
{
- struct signalfd_dump_arg *da = arg;
+ SignalfdEntry sfd = SIGNALFD_ENTRY__INIT;
- if (da->dumped) {
- pr_err("Several counters in a file?\n");
+ if (parse_fdinfo(lfd, FD_TYPES__SIGNALFD, NULL, &sfd))
return -1;
- }
- da->dumped = true;
- e->sfd.id = da->id;
- e->sfd.flags = da->p->flags;
- e->sfd.fown = (FownEntry *)&da->p->fown;
+ sfd.id = id;
+ sfd.flags = p->flags;
+ sfd.fown = (FownEntry *)&p->fown;
return pb_write_one(img_from_set(glob_imgset, CR_FD_SIGNALFD),
- &e->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);
+ &sfd, PB_SIGNALFD);
}
const struct fdtype_ops signalfd_dump_ops = {
--
2.1.4
More information about the CRIU
mailing list