[CRIU] Re: [PATCH] dump: global image names introduced

Pavel Emelyanov xemul at parallels.com
Thu Mar 22 12:21:38 EDT 2012


> @@ -106,6 +106,9 @@ int open_image(int type, unsigned long flags, ...);
>  #define open_image_ro(type, ...) open_image(type, O_RDONLY, __VA_ARGS__);
>  extern int open_image_ro_nocheck(const char *fmt, int pid);
>  
> +#define open_glob_image_ro(type) open_image(type, O_RDONLY);

O_APPEND missed.

> +#define open_glob_image_ro_nocheck(fmt) open_image_ro_nocheck(fmt, 0);

Same here.

> +
>  #define LAST_PID_PATH		"/proc/sys/kernel/ns_last_pid"
>  #define LAST_PID_PERM		0666
>  

> @@ -179,6 +180,13 @@ int open_image(int type, unsigned long flags, ...)
>  		}
>  	}
>  
> +	if (flags & O_APPEND) {
> +		struct stat tmp;
> +
> +		if (stat(path, &tmp) == 0)

Using access() will save couple of bytes on stack.

> +			write_magic = 0;
> +	}
> +
>  	ret = openat(image_dir_fd, path, flags, CR_FD_PERM);
>  	if (ret < 0) {
>  		pr_perror("Unable to open %s", path);


More information about the CRIU mailing list