Commit c0d83d9e authored by Pavel Emelyanov's avatar Pavel Emelyanov

show: Add 'hinting' ability

The crtools produces not only dump in its internal format (i.e. -- pb),
but also may call other tools to create files with some state (e.g.
ip tool dumps route and ifaddr info, tmpfs will be tar-ed, iptables
utility will produce the iptables-save file, etc.).

The show functionality cannot read these images, but we can guess what
can be in the file provided by its magic.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ba0d5fb2
......@@ -357,6 +357,26 @@ void show_mm(int fd_mm, struct cr_options *o)
pb_show_vertical(fd_mm, PB_MM);
}
static struct {
u32 magic;
u32 mask;
char *hint;
} magic_hints[] = {
{ .magic = 0x45311224, .mask = 0xffffffff, .hint = "ip route dump", },
{ .magic = 0x47361222, .mask = 0xffffffff, .hint = "ip ifaddr dump", },
{ .magic = 0x00008b1f, .mask = 0x0000ffff, .hint = "gzip file", },
{ },
};
static void try_hint_magic(u32 magic)
{
int i;
for (i = 0; magic_hints[i].hint != 0; i++)
if ((magic & magic_hints[i].mask) == magic_hints[i].magic)
pr_msg("This can be %s\n", magic_hints[i].hint);
}
static int cr_parse_file(struct cr_options *opts)
{
u32 magic;
......@@ -378,6 +398,7 @@ static int cr_parse_file(struct cr_options *opts)
if (i == CR_FD_MAX) {
pr_err("Unknown magic %#x in %s\n",
magic, opts->show_dump_file);
try_hint_magic(magic);
goto err;
}
......
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