diff --git a/cr-show.c b/cr-show.c index b7c86d30d..e8a0435e7 100644 --- a/cr-show.c +++ b/cr-show.c @@ -85,12 +85,7 @@ void show_ghost_file(int fd, struct cr_options *o) static void pipe_data_handler(int fd, void *obj, int show_pages_content) { PipeDataEntry *e = obj; - - if (show_pages_content) { - pr_msg("\n"); - print_image_data(fd, e->bytes); - } else - lseek(fd, e->bytes, SEEK_CUR); + print_image_data(fd, e->bytes, show_pages_content); } void show_pipes_data(int fd, struct cr_options *o) @@ -171,11 +166,18 @@ void print_data(unsigned long addr, unsigned char *data, size_t size) } } -void print_image_data(int fd, unsigned int length) +void print_image_data(int fd, unsigned int length, int show) { void *data; int ret; + if (!show) { + lseek(fd, length, SEEK_CUR); + return; + } + + pr_msg("\n"); + data = xmalloc(length); if (!data) return; diff --git a/include/crtools.h b/include/crtools.h index d42ad8523..54907d7df 100644 --- a/include/crtools.h +++ b/include/crtools.h @@ -160,7 +160,7 @@ int check_img_inventory(void); int write_img_inventory(void); extern void print_data(unsigned long addr, unsigned char *data, size_t size); -extern void print_image_data(int fd, unsigned int length); +extern void print_image_data(int fd, unsigned int length, int show); extern struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX]; extern int open_image_dir(void); diff --git a/ipc_ns.c b/ipc_ns.c index 0d3493e9a..223a4363e 100644 --- a/ipc_ns.c +++ b/ipc_ns.c @@ -472,12 +472,7 @@ void show_ipc_sem(int fd, struct cr_options *o) static void ipc_msg_data_handler(int fd, void *obj, int show_pages_content) { IpcMsg *e = obj; - - if (show_pages_content) { - pr_msg("\n"); - print_image_data(fd, round_up(e->msize, sizeof(u64))); - } else - lseek(fd, round_up(e->msize, sizeof(u64)), SEEK_CUR); + print_image_data(fd, round_up(e->msize, sizeof(u64)), show_pages_content); } static void ipc_msg_handler(int fd, void *obj, int show_pages_content) @@ -500,12 +495,7 @@ void show_ipc_msg(int fd, struct cr_options *o) static void ipc_shm_handler(int fd, void *obj, int show_pages_content) { IpcShmEntry *e = obj; - - if (show_pages_content) { - pr_msg("\n"); - print_image_data(fd, round_up(e->size, sizeof(u32))); - } else - lseek(fd, round_up(e->size, sizeof(u32)), SEEK_CUR); + print_image_data(fd, round_up(e->size, sizeof(u32)), show_pages_content); } void show_ipc_shm(int fd, struct cr_options *o) diff --git a/sk-queue.c b/sk-queue.c index af1079989..b96daaae2 100644 --- a/sk-queue.c +++ b/sk-queue.c @@ -173,12 +173,7 @@ err_brk: static void sk_queue_data_handler(int fd, void *obj, int show_pages_content) { SkPacketEntry *e = obj; - - if (show_pages_content) { - pr_msg("\n"); - print_image_data(fd, e->length); - } else - lseek(fd, e->length, SEEK_CUR); + print_image_data(fd, e->length, show_pages_content); } void show_sk_queues(int fd, struct cr_options *o)