Commit ee15a000 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Pavel Emelyanov

mount: Create binfmt_misc image w/o device suffix

Use name binfmt_misc.img for any mounted binfmt_misc.
Note, that newly created binfmt_misc images won't restore
on old criu.

Iterate over binfmt_misc_list if it's not empty on restore.

Also, because of above, let's change a behaviour of dump and now
we do not create binfmt_misc images if there is no registered
binfmt_misc entries.

v5: New
v6: Use {open,close}_image sequence to determ if image exists
    Iterate over binfmt_misc_list
Suggested-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent cf164e16
...@@ -1369,7 +1369,7 @@ err: ...@@ -1369,7 +1369,7 @@ err:
static int binfmt_misc_dump(struct mount_info *pm) static int binfmt_misc_dump(struct mount_info *pm)
{ {
struct cr_img *img; struct cr_img *img = NULL;
struct dirent *de; struct dirent *de;
DIR *fdir = NULL; DIR *fdir = NULL;
int fd, ret; int fd, ret;
...@@ -1389,10 +1389,6 @@ static int binfmt_misc_dump(struct mount_info *pm) ...@@ -1389,10 +1389,6 @@ static int binfmt_misc_dump(struct mount_info *pm)
} }
ret = -1; ret = -1;
img = open_image(CR_FD_BINFMT_MISC_OLD, O_DUMP, pm->s_dev);
if (!img)
goto out;
while ((de = readdir(fdir))) { while ((de = readdir(fdir))) {
if (dir_dots(de)) if (dir_dots(de))
continue; continue;
...@@ -1401,6 +1397,13 @@ static int binfmt_misc_dump(struct mount_info *pm) ...@@ -1401,6 +1397,13 @@ static int binfmt_misc_dump(struct mount_info *pm)
if (!strcmp(de->d_name, "status")) if (!strcmp(de->d_name, "status"))
continue; continue;
if (!img) {
/* Create image only if an extry exists, i.e. here */
img = open_image(CR_FD_BINFMT_MISC, O_DUMP);
if (!img)
goto out;
}
if (dump_binfmt_misc_entry(fd, de->d_name, img)) if (dump_binfmt_misc_entry(fd, de->d_name, img))
goto out; goto out;
} }
...@@ -1528,8 +1531,24 @@ static int binfmt_misc_restore(struct mount_info *mi) ...@@ -1528,8 +1531,24 @@ static int binfmt_misc_restore(struct mount_info *mi)
if (!buf) if (!buf)
return -1; return -1;
if (!list_empty(&binfmt_misc_list)) {
struct binfmt_misc_info *bmi;
list_for_each_entry(bmi, &binfmt_misc_list, list) {
ret = binfmt_misc_restore_bme(mi, bmi->bme, buf);
if (ret)
break;
}
goto free_buf;
}
img = open_image(CR_FD_BINFMT_MISC_OLD, O_RSTR, mi->s_dev); img = open_image(CR_FD_BINFMT_MISC_OLD, O_RSTR, mi->s_dev);
if (!img) { if (!img) {
pr_err("Can't open binfmt_misc_old image\n");
goto free_buf;
} else if (empty_image(img)) {
close_image(img);
ret = 0;
goto free_buf; goto free_buf;
} }
......
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