[CRIU] [PATCH v2 2/4] files-reg: Create ghost files in first existing parent directory

Pavel Emelyanov xemul at parallels.com
Mon Dec 28 02:19:38 PST 2015


On 12/22/2015 02:43 PM, Kirill Tkhai wrote:

>  static int mkreg_ghost(char *path, u32 mode, struct ghost_file *gf, struct cr_img *img)
>  {
> -	int gfd, ret;
> +	int gfd, ret, len, i = 0;
>  
> +	len = strlen(path);
> +again:
>  	gfd = open(path, O_WRONLY | O_CREAT | O_EXCL, mode);
> -	if (gfd < 0)
> -		return -1;
> +
> +	if (gfd < 0 && errno == ENOENT) {
> +		if (trim_last_parent(path) < 0) {

It's not correct to change your behavior on restore, depending on the state
of the file system. E.g. -- if we try to restore on completely screwed FS this
code would think that all ghosts sit in removed directories up to the root which
is not correct.

Instead, at dump we should determine the amount of directories unlinked prior to
the file itself and keep this info in the image. On restore act respectively.

-- Pavel



More information about the CRIU mailing list