[CRIU] [PATCH 1/4] fsnotify: Make open_inotify_fd and open_fanotify_fd to look similar

Andrew Vagin avagin at parallels.com
Thu Sep 4 12:26:01 PDT 2014


Acked-by: Andrew Vagin <avagin at parallels.com>
On Thu, Sep 04, 2014 at 10:23:35PM +0400, Cyrill Gorcunov wrote:
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  fsnotify.c | 36 +++++++++++++++++++-----------------
>  1 file changed, 19 insertions(+), 17 deletions(-)
> 
> diff --git a/fsnotify.c b/fsnotify.c
> index 33563eba800b..1c348ce5a0d0 100644
> --- a/fsnotify.c
> +++ b/fsnotify.c
> @@ -588,16 +588,17 @@ static int open_inotify_fd(struct file_desc *d)
>  
>  	list_for_each_entry(wd_info, &info->marks, list) {
>  		pr_info("\tRestore %d wd for 0x%08x\n", wd_info->iwe->wd, wd_info->iwe->id);
> -		if (restore_one_inotify(tmp, wd_info)) {
> -			close_safe(&tmp);
> -			break;
> -		}
> +		if (restore_one_inotify(tmp, wd_info))
> +			goto err;
>  	}
>  
>  	if (restore_fown(tmp, info->ife->fown))
> -		close_safe(&tmp);
> +		goto err;
>  
>  	return tmp;
> +err:
> +	close_safe(&tmp);
> +	return -1;
>  }
>  
>  static int open_fanotify_fd(struct file_desc *d)
> @@ -605,7 +606,7 @@ static int open_fanotify_fd(struct file_desc *d)
>  	struct fsnotify_file_info *info;
>  	struct fsnotify_mark_info *mark;
>  	unsigned int flags = 0;
> -	int ret;
> +	int tmp;
>  
>  	info = container_of(d, struct fsnotify_file_info, d);
>  
> @@ -615,25 +616,26 @@ static int open_fanotify_fd(struct file_desc *d)
>  	if (info->ffe->flags & O_NONBLOCK)
>  		flags |= FAN_NONBLOCK;
>  
> -	ret = sys_fanotify_init(flags, info->ffe->evflags);
> -	if (ret < 0) {
> -		errno = -ret;
> -		pr_perror("Can't init fanotify mark (%d)", ret);
> +	tmp = sys_fanotify_init(flags, info->ffe->evflags);
> +	if (tmp < 0) {
> +		errno = -tmp;
> +		pr_perror("Can't init fanotify mark (%d)", tmp);
>  		return -1;
>  	}
>  
>  	list_for_each_entry(mark, &info->marks, list) {
>  		pr_info("\tRestore fanotify for 0x%08x\n", mark->fme->id);
> -		if (restore_one_fanotify(ret, mark)) {
> -			close_safe(&ret);
> -			break;
> -		}
> +		if (restore_one_fanotify(tmp, mark))
> +			goto err;
>  	}
>  
> -	if (restore_fown(ret, info->ffe->fown))
> -		close_safe(&ret);
> +	if (restore_fown(tmp, info->ffe->fown))
> +		goto err;
>  
> -	return ret;
> +	return tmp;
> +err:
> +	close_safe(&tmp);
> +	return -1;
>  }
>  
>  static struct file_desc_ops inotify_desc_ops = {
> -- 
> 1.9.3
> 


More information about the CRIU mailing list