[CRIU] Re: [PATCH] dump: Rework dump_one_fd types assignment

Pavel Emelyanov xemul at parallels.com
Tue Apr 10 10:27:35 EDT 2012


> @@ -424,15 +413,25 @@ static int dump_one_fd(pid_t pid, int fd, int lfd,
>  	if (S_ISSOCK(p.stat.st_mode))
>  		return dump_socket(&p, lfd, cr_fdset);
>  
> -	if (S_ISCHR(p.stat.st_mode))
> -		return dump_one_chrdev(&p, lfd, cr_fdset);
> +	if (S_ISFIFO(p.stat.st_mode))
> +		p.type = FDINFO_PIPE;
> +	else if (S_ISREG(p.stat.st_mode) || S_ISDIR(p.stat.st_mode))
> +		p.type = FDINFO_REG;
> +	else if (S_ISCHR(p.stat.st_mode)) {
> +		switch (dumpable_chrdev(&p, lfd, cr_fdset)) {
> +		case 0: /* Skip it */
> +			return 0;
> +		case 1:
> +			p.type = FDINFO_REG;
> +		}
> +	}
> +
> +	if (FDINFO_IS_UNKNOWN(p.type))
> +		return dump_unsupp_fd(&p);
>  
> -	if (S_ISREG(p.stat.st_mode) ||
> -            S_ISDIR(p.stat.st_mode) ||
> -            S_ISFIFO(p.stat.st_mode))
> -		return dump_one_fdinfo(&p, lfd, cr_fdset);
> +	p.id = MAKE_FD_GENID(p.stat.st_dev, p.stat.st_ino, p.pos);
>  
> -	return dump_unsupp_fd(&p);
> +	return do_dump_one_fdinfo(&p, lfd, cr_fdset);

Sorry, this looks ugly, but the idea staying behind this is very nice. I'll
look at it more deeply after I fix the close-on-exec bits.

>  }
>  


More information about the CRIU mailing list