[CRIU] Re: [PATCH cr] [RFC] crtools: check pathes relatively mntns
root
Pavel Emelyanov
xemul at parallels.com
Tue Jul 17 06:59:20 EDT 2012
On 07/17/2012 04:40 AM, Andrey Vagin wrote:
>
> Get mntns root and check a pathes relatively it.
This comment really sucks.
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
> cr-dump.c | 7 +++++++
> files-reg.c | 15 ++++++++++-----
> include/mount.h | 11 +++++++++++
> include/parasite-syscall.h | 1 +
> include/parasite.h | 1 +
> include/syscall-x86-64.def | 1 +
> mount.c | 1 +
> parasite-syscall.c | 17 +++++++++++++++++
> parasite.c | 30 ++++++++++++++++++++++++++++++
> sk-unix.c | 8 ++++++--
> 10 files changed, 85 insertions(+), 7 deletions(-)
>
> + if (item == root_item) {
> + ret = parasite_get_root_seized(parasite_ctl, &mntns_root);
> + if (ret)
> + goto err;
> + }
> +
You can get task's root by opening it's proc root link. No need in
parasite help here.
> @@ -295,12 +299,13 @@ static int check_path_remap(char *path, const struct stat *ost, int lfd, u32 id)
> int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
> {
> char fd_str[128];
> - char path[PATH_MAX];
> + RPATH(rpath);
> + char *path = rpath.path;
> int len, rfd;
> struct reg_file_entry rfe;
>
> snprintf(fd_str, sizeof(fd_str), "/proc/self/fd/%d", lfd);
> - len = readlink(fd_str, path, sizeof(path) - 1);
> + len = readlink(fd_str, path, sizeof(rpath.path));
> if (len < 0) {
> pr_perror("Can't readlink %s", fd_str);
> return len;
readlink(fd_str, path + 1, sizeof(path) - 1);
path[0] = '.';
looks ... cleaner :)
Thanks,
Pavel
More information about the CRIU
mailing list