mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
mntns: crtools: stat pathes relatively of a mntns root
If we dump tasks with mntns, we should look at pathes from point of a mntns root. Now we support a situation when a root of an init task has the same root as the mntns root, because we have not another way to get a root of mntns. A path to an unix socket is copied, because the origin copy will be gone out from the function, where it was created. Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
3a60163b71
commit
c69be631e1
35
mount.c
35
mount.c
@@ -22,6 +22,7 @@
|
||||
#include "protobuf/mnt.pb-c.h"
|
||||
|
||||
static struct mount_info *mntinfo;
|
||||
int mntns_root = -1;
|
||||
|
||||
int open_mount(unsigned int s_dev)
|
||||
{
|
||||
@@ -499,3 +500,37 @@ void show_mountpoints(int fd, struct cr_options *o)
|
||||
{
|
||||
pb_show_plain(fd, mnt_entry);
|
||||
}
|
||||
|
||||
int mntns_collect_root(pid_t pid)
|
||||
{
|
||||
int fd, pfd;
|
||||
int ret;
|
||||
char path[PATH_MAX + 1];
|
||||
|
||||
/* If /proc/pid/root links on '/', it signs that a root of the task
|
||||
* and a root of mntns is the same. */
|
||||
|
||||
pfd = open_pid_proc(pid);
|
||||
ret = readlinkat(pfd, "root", path, PATH_MAX);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
path[ret + 1] = '\0';
|
||||
|
||||
if (ret != 1 || path[0] != '/') {
|
||||
pr_err("The root task has another root than mntns: %s\n", path);
|
||||
close_pid_proc();
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = openat(pfd, "root", O_RDONLY | O_DIRECTORY, 0);
|
||||
close_pid_proc();
|
||||
if (fd < 0) {
|
||||
pr_perror("Can't open the task root");
|
||||
return -1;
|
||||
}
|
||||
|
||||
mntns_root = fd;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user