diff --git a/cr-show.c b/cr-show.c index 9ce27c6a1..9c388ff09 100644 --- a/cr-show.c +++ b/cr-show.c @@ -28,6 +28,7 @@ #include "protobuf/fdinfo.pb-c.h" #include "protobuf/regfile.pb-c.h" #include "protobuf/ghost-file.pb-c.h" +#include "protobuf/fifo.pb-c.h" #define DEF_PAGES_PER_LINE 6 @@ -217,13 +218,14 @@ void show_fifo_data(int fd, struct cr_options *o) void show_fifo(int fd, struct cr_options *o) { - struct fifo_entry e; + FifoEntry *e; pr_img_head(CR_FD_FIFO); while (1) { - if (read_img_eof(fd, &e) <= 0) + if (pb_read_eof(fd, &e, fifo_entry) <= 0) break; - pr_msg("id: 0x%8x pipeid: 0x%8x\n", e.id, e.pipe_id); + pr_msg("id: 0x%8x pipeid: 0x%8x\n", e->id, e->pipe_id); + fifo_entry__free_unpacked(e, NULL); } pr_img_tail(CR_FD_FIFO); } diff --git a/fifo.c b/fifo.c index a00d7cdde..af7100c72 100644 --- a/fifo.c +++ b/fifo.c @@ -12,7 +12,9 @@ #include "fifo.h" +#include "protobuf.h" #include "protobuf/regfile.pb-c.h" +#include "protobuf/fifo.pb-c.h" /* * FIFO checkpoint and restore is done in a bit unusual manner. @@ -29,7 +31,7 @@ struct fifo_info { struct list_head list; struct file_desc d; - struct fifo_entry *fe; + FifoEntry *fe; bool restore_data; }; @@ -39,7 +41,7 @@ static struct pipe_data_dump pd_fifo = { .img_type = CR_FD_FIFO_DATA, }; static int dump_one_fifo(int lfd, u32 id, const struct fd_parms *p) { int img = fdset_fd(glob_fdset, CR_FD_FIFO); - struct fifo_entry e; + FifoEntry e = FIFO_ENTRY__INIT; /* * It's a trick here, we use regular files dumping @@ -55,7 +57,7 @@ static int dump_one_fifo(int lfd, u32 id, const struct fd_parms *p) e.id = id; e.pipe_id = pipe_id(p); - if (write_img(img, &e) < 0) + if (pb_write(img, &e, fifo_entry)) return -1; return dump_one_pipe_data(&pd_fifo, lfd, p); @@ -136,11 +138,7 @@ int collect_fifo(void) if (!info) break; - info->fe = xzalloc(sizeof(*info->fe)); - if (!info->fe) - break; - - ret = read_img_eof(img, info->fe); + ret = pb_read_eof(img, &info->fe, fifo_entry); if (ret <= 0) break; diff --git a/include/image.h b/include/image.h index c84858719..0f535c5f4 100644 --- a/include/image.h +++ b/include/image.h @@ -142,11 +142,6 @@ struct pipe_data_entry { u8 data[0]; } __packed; -struct fifo_entry { - u32 id; - u32 pipe_id; -} __packed; - #define USK_EXTERN (1 << 0) struct sk_opts_entry { diff --git a/protobuf/Makefile b/protobuf/Makefile index fa12abb42..8f95bdff6 100644 --- a/protobuf/Makefile +++ b/protobuf/Makefile @@ -23,6 +23,7 @@ PROTO_FILES += fdinfo.proto PROTO_FILES += fown.proto PROTO_FILES += regfile.proto PROTO_FILES += ghost-file.proto +PROTO_FILES += fifo.proto HDRS := $(patsubst %.proto,%.pb-c.h,$(PROTO_FILES)) SRCS := $(patsubst %.proto,%.pb-c.c,$(PROTO_FILES)) diff --git a/protobuf/fifo.proto b/protobuf/fifo.proto new file mode 100644 index 000000000..c7938c093 --- /dev/null +++ b/protobuf/fifo.proto @@ -0,0 +1,4 @@ +message fifo_entry { + required uint32 id = 1; + required uint32 pipe_id = 2; +}