[CRIU] [PATCH] image: Don't unlink image we're dumping into

Andrew Vagin avagin at parallels.com
Thu Feb 13 13:01:59 PST 2014


Acked-by: Andrew Vagin <avagin at parallels.com>

On Thu, Feb 13, 2014 at 04:55:40PM +0400, Pavel Emelyanov wrote:
> We want to write into empty image files, so we
> unlink them before dumping into. Let's O_TRUNC
> it instead.
> 
> Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
> ---
>  image.c         | 8 --------
>  include/image.h | 2 +-
>  2 files changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/image.c b/image.c
> index b4495e1..630ac9b 100644
> --- a/image.c
> +++ b/image.c
> @@ -192,14 +192,6 @@ int open_image_at(int dfd, int type, unsigned long flags, ...)
>  	vsnprintf(path, PATH_MAX, fdset_template[type].fmt, args);
>  	va_end(args);
>  
> -	if (flags & O_EXCL) {
> -		ret = unlinkat(dfd, path, 0);
> -		if (ret && errno != ENOENT) {
> -			pr_perror("Unable to unlink %s", path);
> -			goto err;
> -		}
> -	}
> -
>  	ret = openat(dfd, path, flags, CR_FD_PERM);
>  	if (ret < 0) {
>  		pr_perror("Unable to open %s", path);
> diff --git a/include/image.h b/include/image.h
> index 32ee0af..af69de9 100644
> --- a/include/image.h
> +++ b/include/image.h
> @@ -65,7 +65,7 @@
>  extern bool fdinfo_per_id;
>  extern bool ns_per_id;
>  
> -#define O_DUMP	(O_RDWR | O_CREAT | O_EXCL)
> +#define O_DUMP	(O_RDWR | O_CREAT | O_TRUNC)
>  #define O_SHOW	(O_RDONLY)
>  #define O_RSTR	(O_RDONLY)
>  
> -- 
> 1.8.4.2
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list