[CRIU] Re: [PATCH 2/3] files-reg: Create fifo ghost node if needed

Pavel Emelyanov xemul at parallels.com
Wed Jun 27 13:18:07 EDT 2012


On 06/26/2012 06:49 PM, Cyrill Gorcunov wrote:
> 
> Allow file path remap engine to create fifo nodes.
> Note for fifos the copy_file is not called since
> we will restore fifo data via pipe-data engine.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  cr-show.c       |    2 +-
>  files-reg.c     |   29 ++++++++++++++++++++++-------
>  include/image.h |    1 +
>  3 files changed, 24 insertions(+), 8 deletions(-)
> 

> @@ -184,12 +196,13 @@ static int dump_ghost_file(int _fd, u32 id, const struct stat *st)
>  	 * permissions when drained
>  	 */
>  	snprintf(lpath, sizeof(lpath), "/proc/self/fd/%d", _fd);
> -	fd = open(lpath, O_RDONLY);
> +	fd = open(lpath, O_RDWR); /* To not block if fifo */

You don't have to open fifo here at all.

>  	if (fd < 0) {
>  		pr_perror("Can't open ghost original file");
>  		return -1;
>  	}
>  
> +	gfe.dev = st->st_dev;
>  	gfe.uid = st->st_uid;
>  	gfe.gid = st->st_gid;
>  	gfe.mode = st->st_mode;

> @@ -94,7 +94,17 @@ static int open_remap_ghost(struct reg_file_info *rfi,
>  		goto err;
>  
>  	snprintf(gf->path, PATH_MAX, "%s.cr.%x.ghost", rfi->path, rfe->remap_id);
> -	gfd = open(gf->path, O_WRONLY | O_CREAT | O_EXCL, gfe.mode);
> +
> +	if (S_ISFIFO(gfe.mode)) {
> +		if (mknod(gf->path, gfe.mode, gfe.dev)) {

dev is ignored for fifos by mknod.

> +			pr_perror("Can't create node for ghost file\n");
> +			goto err;
> +		}
> +		ghost_flags = O_RDWR; /* To not block */
> +	} else
> +		ghost_flags = O_WRONLY | O_CREAT | O_EXCL;
> +
> +	gfd = open(gf->path, ghost_flags, gfe.mode);
>  	if (gfd < 0) {
>  		pr_perror("Can't open ghost file");
>  		goto err;



More information about the CRIU mailing list