[CRIU] Re: [PATCH cr 3/3] mount: add support of tmpfs

Pavel Emelyanov xemul at parallels.com
Wed Aug 8 09:02:33 EDT 2012


On 08/08/2012 04:47 PM, Andrey Vagin wrote:
> 
> tar is used for dumping content of tmpfs
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  image.c                             |    1 +
>  include/crtools.h                   |    2 +
>  include/image.h                     |    1 +
>  mount.c                             |   99 +++++++++++++++++++++++++++++++++++
>  test/zdtm/live/static/mountpoints.c |   12 ++++-
>  5 files changed, 114 insertions(+), 1 deletions(-)
> 

> +		fd = open_mountpoint(pm);
> +		if (fd < 0)
> +			exit(1);
> +
...
> +
> +		snprintf(tmpfs_path, sizeof(tmpfs_path),
> +					       "/proc/self/fd/%d", fd);
> +

1. It should be commented why /proc/self/fd is used.
2. You shouldn't tar a tmpfs mountpoint if something is mounted on top of it
3. ... and the --one-file-system is not needed in this case

> +		execlp("tar", "tar", "-czlp",
> +			"--sparse",
> +			"--numeric-owner",
> +			"--one-file-system",
> +			"-C", tmpfs_path, ".", NULL);

> +		fd_img = open_image(CR_FD_TMPFS, O_DUMP, pm->mnt_id);
> +		if (fd_img < 0)
> +			exit(1);
> +
> +		ret = dup2(fd_img, STDOUT_FILENO);
> +		if (ret < 0) {
> +			pr_perror("dup2() failed");
> +			exit(1);
> +		}
> +		close(fd_img);

It's also worth duping logfd into stderr fileno of tar.

Thanks,
Pavel


More information about the CRIU mailing list