Commit 56e1decf authored by Pavel Emelyanov's avatar Pavel Emelyanov

show: Factor out skipping of data dump into show_image_data

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c33a62df
...@@ -85,12 +85,7 @@ void show_ghost_file(int fd, struct cr_options *o) ...@@ -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) static void pipe_data_handler(int fd, void *obj, int show_pages_content)
{ {
PipeDataEntry *e = obj; PipeDataEntry *e = obj;
print_image_data(fd, e->bytes, show_pages_content);
if (show_pages_content) {
pr_msg("\n");
print_image_data(fd, e->bytes);
} else
lseek(fd, e->bytes, SEEK_CUR);
} }
void show_pipes_data(int fd, struct cr_options *o) 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) ...@@ -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; void *data;
int ret; int ret;
if (!show) {
lseek(fd, length, SEEK_CUR);
return;
}
pr_msg("\n");
data = xmalloc(length); data = xmalloc(length);
if (!data) if (!data)
return; return;
......
...@@ -160,7 +160,7 @@ int check_img_inventory(void); ...@@ -160,7 +160,7 @@ int check_img_inventory(void);
int write_img_inventory(void); int write_img_inventory(void);
extern void print_data(unsigned long addr, unsigned char *data, size_t size); 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 struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX];
extern int open_image_dir(void); extern int open_image_dir(void);
......
...@@ -472,12 +472,7 @@ void show_ipc_sem(int fd, struct cr_options *o) ...@@ -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) static void ipc_msg_data_handler(int fd, void *obj, int show_pages_content)
{ {
IpcMsg *e = obj; IpcMsg *e = obj;
print_image_data(fd, round_up(e->msize, sizeof(u64)), show_pages_content);
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);
} }
static void ipc_msg_handler(int fd, void *obj, int 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) ...@@ -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) static void ipc_shm_handler(int fd, void *obj, int show_pages_content)
{ {
IpcShmEntry *e = obj; IpcShmEntry *e = obj;
print_image_data(fd, round_up(e->size, sizeof(u32)), show_pages_content);
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);
} }
void show_ipc_shm(int fd, struct cr_options *o) void show_ipc_shm(int fd, struct cr_options *o)
......
...@@ -173,12 +173,7 @@ err_brk: ...@@ -173,12 +173,7 @@ err_brk:
static void sk_queue_data_handler(int fd, void *obj, int show_pages_content) static void sk_queue_data_handler(int fd, void *obj, int show_pages_content)
{ {
SkPacketEntry *e = obj; SkPacketEntry *e = obj;
print_image_data(fd, e->length, show_pages_content);
if (show_pages_content) {
pr_msg("\n");
print_image_data(fd, e->length);
} else
lseek(fd, e->length, SEEK_CUR);
} }
void show_sk_queues(int fd, struct cr_options *o) void show_sk_queues(int fd, struct cr_options *o)
......
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