diff --git a/cr-restore.c b/cr-restore.c index ce4ff4729..e96f741d4 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -49,6 +49,9 @@ #include "inotify.h" #include "pstree.h" +#include "protobuf.h" +#include "protobuf/sa.pb-c.h" + static struct pstree_item *me; static int restore_task_with_children(void *); @@ -194,7 +197,7 @@ static int prepare_sigactions(int pid) { rt_sigaction_t act, oact; int fd_sigact; - struct sa_entry e; + SaEntry *e; int sig; int ret = -1; @@ -206,14 +209,16 @@ static int prepare_sigactions(int pid) if (sig == SIGKILL || sig == SIGSTOP) continue; - ret = read_img(fd_sigact, &e); + ret = pb_read(fd_sigact, &e, sa_entry); if (ret < 0) break; - ASSIGN_TYPED(act.rt_sa_handler, e.sigaction); - ASSIGN_TYPED(act.rt_sa_flags, e.flags); - ASSIGN_TYPED(act.rt_sa_restorer, e.restorer); - ASSIGN_TYPED(act.rt_sa_mask.sig[0], e.mask); + ASSIGN_TYPED(act.rt_sa_handler, e->sigaction); + ASSIGN_TYPED(act.rt_sa_flags, e->flags); + ASSIGN_TYPED(act.rt_sa_restorer, e->restorer); + ASSIGN_TYPED(act.rt_sa_mask.sig[0], e->mask); + + sa_entry__free_unpacked(e, NULL); if (sig == SIGCHLD) { sigchld_act = act; diff --git a/cr-show.c b/cr-show.c index 8bdfd31f3..f058aff42 100644 --- a/cr-show.c +++ b/cr-show.c @@ -35,6 +35,7 @@ #include "protobuf/pstree.pb-c.h" #include "protobuf/pipe.pb-c.h" #include "protobuf/pipe-data.pb-c.h" +#include "protobuf/sa.pb-c.h" #define DEF_PAGES_PER_LINE 6 @@ -359,22 +360,23 @@ out: void show_sigacts(int fd_sigacts, struct cr_options *o) { - struct sa_entry e; + SaEntry *e; pr_img_head(CR_FD_SIGACT); while (1) { int ret; - ret = read_img_eof(fd_sigacts, &e); + ret = pb_read_eof(fd_sigacts, &e, sa_entry); if (ret <= 0) goto out; pr_msg("sigaction: 0x%016lx mask: 0x%08lx " "flags: 0x%016lx restorer: 0x%016lx\n", - (long)e.sigaction, - (long)e.mask, - (long)e.flags, - (long)e.restorer); + (long)e->sigaction, + (long)e->mask, + (long)e->flags, + (long)e->restorer); + sa_entry__free_unpacked(e, NULL); } out: diff --git a/include/image.h b/include/image.h index 36d4f6c9c..2e6a06e90 100644 --- a/include/image.h +++ b/include/image.h @@ -201,13 +201,6 @@ struct page_entry { u8 data[PAGE_IMAGE_SIZE]; } __packed; -struct sa_entry { - u64 sigaction; - u64 flags; - u64 restorer; - u64 mask; -} __packed; - struct itimer_entry { u64 isec; u64 iusec; diff --git a/parasite-syscall.c b/parasite-syscall.c index 9838f1527..5900d85da 100644 --- a/parasite-syscall.c +++ b/parasite-syscall.c @@ -12,6 +12,9 @@ #include "parasite.h" #include "crtools.h" +#include "protobuf.h" +#include "protobuf/sa.pb-c.h" + #include #include @@ -431,7 +434,7 @@ int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_f { struct parasite_dump_sa_args args; int ret, i, fd; - struct sa_entry se; + SaEntry se = SA_ENTRY__INIT; ret = parasite_execute(PARASITE_CMD_DUMP_SIGACTS, ctl, &args, sizeof(args)); if (ret < 0) @@ -448,7 +451,7 @@ int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_f ASSIGN_TYPED(se.restorer, args.sas[i].rt_sa_restorer); ASSIGN_TYPED(se.mask, args.sas[i].rt_sa_mask.sig[0]); - if (write_img(fd, &se) < 0) + if (pb_write(fd, &se, sa_entry) < 0) return -1; } diff --git a/protobuf/Makefile b/protobuf/Makefile index 4b7c5202d..e18f93ac1 100644 --- a/protobuf/Makefile +++ b/protobuf/Makefile @@ -36,6 +36,7 @@ PROTO_FILES += tcp-stream.proto PROTO_FILES += sk-packet.proto PROTO_FILES += mnt.proto PROTO_FILES += pipe-data.proto +PROTO_FILES += sa.proto HDRS := $(patsubst %.proto,%.pb-c.h,$(PROTO_FILES)) SRCS := $(patsubst %.proto,%.pb-c.c,$(PROTO_FILES)) diff --git a/protobuf/sa.proto b/protobuf/sa.proto new file mode 100644 index 000000000..d5e5a49c2 --- /dev/null +++ b/protobuf/sa.proto @@ -0,0 +1,6 @@ +message sa_entry { + required uint64 sigaction = 1; + required uint64 flags = 2; + required uint64 restorer = 3; + required uint64 mask = 4; +}