[CRIU] Re: [PATCH 03/26] proc_parse.c: Add read_proc_selffd_link helper

Pavel Emelyanov xemul at parallels.com
Tue Jun 19 05:32:17 EDT 2012


On 06/19/2012 12:30 PM, Cyrill Gorcunov wrote:
> 
> It'll be needed for fifo restore and dump_one_reg_file,
> so make a common routine.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  include/proc_parse.h |    1 +
>  proc_parse.c         |   15 +++++++++++++++
>  2 files changed, 16 insertions(+), 0 deletions(-)
> 

> +char *read_proc_selffd_link(int fd, int *len)
> +{
> +	char local[64];
> +
> +	snprintf(local, sizeof(local), "/proc/self/fd/%d", fd);
> +	*len = readlink(local, buf, BUF_SIZE);
> +	if (*len < 0) {
> +		pr_perror("Can't readlink %s", local);
> +		return NULL;
> +	} else

Excessive else.

> +		buf[*len] = '\0';
> +
> +	return buf;
> +}



More information about the CRIU mailing list