2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

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: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov 2012-08-08 15:03:15 +04:00
parent ba0d5fb226
commit c0d83d9e9f

View File

@ -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;
}