2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

files: Fix restoration of ghost cwd (and root)

When cwd is removed (it can be) we need to collect the respective
file_desc before starting opening any files to properly handle
ghost refcounts. Otherwise we will miss one refcount from the
cwd's on ghost, which in turn will either BUG inside ghost removal,
or will fail the cwd due to the respective dir being removed too
early.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov
2014-07-03 19:08:14 +04:00
parent ba8671b4c1
commit a919dbc9c6
2 changed files with 20 additions and 8 deletions

24
files.c
View File

@@ -1028,15 +1028,15 @@ int restore_fs(struct pstree_item *me)
* be able to open the cwd one after we chroot.
*/
dd_root = open_reg_by_id(ri->root_id);
dd_root = open_reg_fd(ri->root);
if (dd_root < 0) {
pr_err("Can't open root %#x\n", ri->root_id);
pr_err("Can't open root\n");
goto out;
}
dd_cwd = open_reg_by_id(ri->cwd_id);
dd_cwd = open_reg_fd(ri->cwd);
if (dd_cwd < 0) {
pr_err("Can't open cwd %#x\n", ri->cwd_id);
pr_err("Can't open cwd\n");
goto out;
}
@@ -1086,14 +1086,26 @@ int prepare_fs_pid(struct pstree_item *item)
close(ifd);
ri->cwd_id = fe->cwd_id;
ri->root_id = fe->root_id;
ri->cwd = collect_special_file(fe->cwd_id);
if (!ri->cwd) {
pr_err("Can't find task cwd file\n");
goto out_f;
}
ri->root = collect_special_file(fe->root_id);
if (!ri->root) {
pr_err("Can't find task root file\n");
goto out_f;
}
ri->has_umask = fe->has_umask;
ri->umask = fe->umask;
fs_entry__free_unpacked(fe, NULL);
return 0;
out_f:
fs_entry__free_unpacked(fe, NULL);
out_i:
close(ifd);
out: