[CRIU] [PATCH 05/14] Use pr_perror() on open() failure

Pavel Emelyanov xemul at virtuozzo.com
Wed Mar 22 07:09:47 PDT 2017


On 03/22/2017 01:00 AM, Kir Kolyshkin wrote:
> It makes sense to show errno to a user.
> 
> Signed-off-by: Kir Kolyshkin <kir at openvz.org>
> ---
>  criu/namespaces.c | 2 +-
>  criu/sk-unix.c    | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/criu/namespaces.c b/criu/namespaces.c
> index 77308cc..01afca4 100644
> --- a/criu/namespaces.c
> +++ b/criu/namespaces.c
> @@ -2210,7 +2210,7 @@ static int create_user_ns_hierarhy_fn(void *in_arg)
>  		futex_set_and_wake(p_futex, NS__CREATED);
>  		fd = open("/proc/self/ns/user", O_RDONLY);

BTW, would someone also scan for open("/proc...")-s and fix
them to use open_proc-s?

-- Pavel

>  		if (fd < 0) {
> -			pr_err("Can't get self user ns");
> +			pr_perror("Can't get self user ns");
>  			goto out;
>  		}
>  		me->user.nsfd_id = fdstore_add(fd);
> diff --git a/criu/sk-unix.c b/criu/sk-unix.c
> index a44d998..c0759dc 100644
> --- a/criu/sk-unix.c
> +++ b/criu/sk-unix.c
> @@ -887,7 +887,7 @@ static int prep_unix_sk_cwd(struct unix_sk_info *ui, int *prev_cwd_fd, int *prev
>  
>  	*prev_cwd_fd = open(".", O_RDONLY);
>  	if (*prev_cwd_fd < 0) {
> -		pr_err("Can't open current dir\n");
> +		pr_perror("Can't open current dir");
>  		return -1;
>  	}
>  
> @@ -896,7 +896,7 @@ static int prep_unix_sk_cwd(struct unix_sk_info *ui, int *prev_cwd_fd, int *prev
>  			root = lookup_ns_by_id(root_item->ids->mnt_ns_id, &mnt_ns_desc);
>  		*prev_root_fd = open("/", O_RDONLY);
>  		if (*prev_root_fd < 0) {
> -			pr_err("Can't open current root\n");
> +			pr_perror("Can't open current root");
>  			goto err;
>  		}
>  
> 



More information about the CRIU mailing list