[CRIU] Re: on servie fd handling code

Pavel Emelyanov xemul at parallels.com
Thu Sep 6 11:10:02 EDT 2012


On 09/06/2012 02:32 PM, Cyrill Gorcunov wrote:
> Does the one attached look better?

> diff --git a/util.c b/util.c
> index 1fad14c..6f6cf6d 100644
> --- a/util.c
> +++ b/util.c
> @@ -224,23 +224,6 @@ int do_open_proc(pid_t pid, int flags, const char *fmt, ...)
>  	return openat(dirfd, path, flags);
>  }
>  
> -int get_service_fd(int type)
> -{
> -	struct rlimit rlimit;
> -
> -	/*
> -	 * Service FDs are thouse that most likely won't
> -	 * conflict with any 'real-life' ones
> -	 */
> -
> -	if (getrlimit(RLIMIT_NOFILE, &rlimit)) {
> -		pr_perror("Can't get rlimit");
> -		return -1;
> -	}
> -
> -	return rlimit.rlim_cur - type;
> -}
> -

Leave the whole thing in util.c

>  int copy_file(int fd_in, int fd_out, size_t bytes)
>  {
>  	ssize_t written = 0;

> +bool is_service_fd(int fd, int type)
> +{
> +	return fd > rlim_min && fd == get_service_fd(type);

return fd > rlim_cur - SFD_OFF_MAX;

> +}



More information about the CRIU mailing list