Commit 485c4b50 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

show: Rework show procedure

Added

 - ability to parse every single file crtools
   understands via magic number

 - dumped memory pages can be rendered in two
   modes -- as a simple set of pages' virtual addresses
   or in hexdummp fashion (via -c command line key).

For example

  ./crtools -s -c -f pages-2557.img

CR_FD_PAGES: pages-2557.img
----------------------------------------
    7fffb44ace20: 00 00 00 00 00 00 00 00  00 00 00 74 65 73 74 2f  |. . . . . . . .  . . . t e s t / |
    7fffb44ace30: 74 65 73 74 2d 73 69 67  61 63 74 69 6f 6e 00 48  |t e s t - s i g  a c t i o n . H |
    7fffb44ace40: 4f 53 54 4e 41 4d 45 3d  6c 6f 63 61 6c 68 6f 73  |O S T N A M E =  l o c a l h o s |
    7fffb44ace50: 74 2e 6c 6f 63 61 6c 64  6f 6d 61 69 6e 00 54 45  |t . l o c a l d  o m a i n . T E |
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent c06227ff
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
static char big_buffer[PATH_MAX]; static char big_buffer[PATH_MAX];
static char loc_buf[PAGE_SIZE]; static char loc_buf[PAGE_SIZE];
static void free_pstree(struct list_head *pstree_list) void free_pstree(struct list_head *pstree_list)
{ {
struct pstree_item *item, *p; struct pstree_item *item, *p;
......
This diff is collapsed.
...@@ -233,7 +233,7 @@ int main(int argc, char *argv[]) ...@@ -233,7 +233,7 @@ int main(int argc, char *argv[])
int opt, idx; int opt, idx;
int action = -1; int action = -1;
static const char short_opts[] = "drskp:t:h"; static const char short_opts[] = "drskf:p:t:hc";
static const struct option long_opts[] = { static const struct option long_opts[] = {
{ "dump", no_argument, NULL, 'd' }, { "dump", no_argument, NULL, 'd' },
{ "restore", no_argument, NULL, 'r' }, { "restore", no_argument, NULL, 'r' },
...@@ -274,6 +274,13 @@ int main(int argc, char *argv[]) ...@@ -274,6 +274,13 @@ int main(int argc, char *argv[])
case 's': case 's':
action = opt; action = opt;
break; break;
case 'c':
opts.show_pages_content = true;
break;
case 'f':
opts.show_single_file = true;
opts.show_dump_file = optarg;
break;
case 'k': case 'k':
opts.final_state = CR_TASK_KILL; opts.final_state = CR_TASK_KILL;
break; break;
...@@ -302,6 +309,10 @@ int main(int argc, char *argv[]) ...@@ -302,6 +309,10 @@ int main(int argc, char *argv[])
usage: usage:
printk("\nUsage:\n"); printk("\nUsage:\n");
printk("\tcrtools ([--dump|-d]|[--show|-s]|[--restore|-r]) [-k] (-p|-t) pid\n\n"); printk("\t%s --dump|-d [-k] -p|-t pid\n", argv[0]);
printk("\t%s --restore|-r -p|-t pid\n", argv[0]);
printk("\t%s --show|-s [-c] (-p|-t pid)|(-f file)\n", argv[0]);
printk("\n");
return -1; return -1;
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "image.h" #include "image.h"
extern struct page_entry zero_page_entry; extern struct page_entry zero_page_entry;
extern void free_pstree(struct list_head *pstree_list);
#define CR_FD_PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH) #define CR_FD_PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)
#define CR_FD_PERM_DUMP (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) #define CR_FD_PERM_DUMP (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
...@@ -35,6 +36,9 @@ enum cr_task_final_state { ...@@ -35,6 +36,9 @@ enum cr_task_final_state {
struct cr_options { struct cr_options {
bool leader_only; bool leader_only;
enum cr_task_final_state final_state; enum cr_task_final_state final_state;
bool show_single_file;
bool show_pages_content;
char *show_dump_file;
}; };
/* file descriptors template */ /* file descriptors template */
......
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