Commit de66a5d0 authored by Pavel Emelyanov's avatar Pavel Emelyanov

fs: Reserve place for task's root dumping

Do not restore it yet -- the logic we're about to apply to
resolve tasks' paths relative to dumper/restorer is not yet
clear to me and it should better be hidden into a couple of
calls (dump_one_reg_file/open_fe_fd). But since we can't
chroot to fd we're about to expose the logic outside of the
open_fe_fd, which is not desirable ATM.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent e5e57e83
......@@ -494,13 +494,35 @@ static int dump_task_fs(pid_t pid, struct cr_fdset *fdset)
fe.cwd_id = fd_id_generate_special();
ret = dump_one_reg_file(fd, fe.cwd_id, &p);
if (!ret) {
pr_info("Dumping task cwd id %x\n", fe.cwd_id);
ret = write_img(fdset_fd(fdset, CR_FD_FS), &fe);
if (ret < 0)
return ret;
close(fd);
fd = open_proc(pid, "root");
if (fd < 0)
return -1;
if (fstat(fd, &p.stat) < 0) {
pr_perror("Can't stat root");
return -1;
}
p.type = FDINFO_REG;
p.flags = 0;
p.pos = 0;
fe.root_id = fd_id_generate_special();
ret = dump_one_reg_file(fd, fe.root_id, &p);
if (ret < 0)
return ret;
close(fd);
return ret;
pr_info("Dumping task cwd id %x root id %x\n",
fe.cwd_id, fe.root_id);
return write_img(fdset_fd(fdset, CR_FD_FS), &fe);
}
struct shmem_info
......
......@@ -177,8 +177,10 @@ void show_fs(int fd_fs, struct cr_options *o)
pr_img_head(CR_FD_FS);
if (read_img(fd_fs, &fe) > 0)
pr_msg("CWD: %x\n", fe.cwd_id);
if (read_img(fd_fs, &fe) > 0) {
pr_msg("CWD : %x\n", fe.cwd_id);
pr_msg("ROOT: %x\n", fe.root_id);
}
pr_img_tail(CR_FD_FS);
}
......
......@@ -563,6 +563,15 @@ int prepare_fs(int pid)
close(cwd);
close(ifd);
/*
* FIXME: restore task's root. Don't want to do it now, since
* it's not yet clean how we're going to resolve tasks' paths
* relative to the dumper/restorer and all this logic is likely
* to be hidden in a couple of calls (open_fe_fd is one od them)
* but for chroot there's no fchroot call, we have to chroot
* by path thus exposing this (yet unclean) logic here.
*/
return 0;
}
......
......@@ -65,6 +65,7 @@ struct fdinfo_entry {
struct fs_entry {
u32 cwd_id;
u32 root_id;
} __packed;
struct pstree_entry {
......
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