public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Paul Holzinger <pholzing@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH] pasta: include errno in error message
Date: Sat, 24 Jun 2023 11:57:15 +1000	[thread overview]
Message-ID: <ZJZNe5xLD2QhtABD@zatzit> (raw)
In-Reply-To: <20230623102350.106830-1-pholzing@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1606 bytes --]

On Fri, Jun 23, 2023 at 12:23:50PM +0200, Paul Holzinger wrote:
> When the open() or setns() calls fails pasta exits early and prints an
> error. However it did not include the errno so it was impossible to know
> why the syscall failed.
> 
> Signed-off-by: Paul Holzinger <pholzing@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  pasta.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/pasta.c b/pasta.c
> index 13ab18b..27809d2 100644
> --- a/pasta.c
> +++ b/pasta.c
> @@ -136,14 +136,14 @@ void pasta_open_ns(struct ctx *c, const char *netns)
>  
>  	nfd = open(netns, O_RDONLY | O_CLOEXEC);
>  	if (nfd < 0)
> -		die("Couldn't open network namespace %s", netns);
> +		die("Couldn't open network namespace %s: %s", netns, strerror(errno));
>  
>  	c->pasta_netns_fd = nfd;
>  
>  	NS_CALL(ns_check, c);
>  
>  	if (c->pasta_netns_fd < 0)
> -		die("Couldn't switch to pasta namespaces");
> +		die("Couldn't switch to pasta namespaces: %s", strerror(errno));
>  
>  	if (!c->no_netns_quit) {
>  		char buf[PATH_MAX] = { 0 };
> @@ -261,7 +261,7 @@ void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid,
>  
>  	NS_CALL(pasta_wait_for_ns, c);
>  	if (c->pasta_netns_fd < 0)
> -		die("Failed to join network namespace");
> +		die("Failed to join network namespace: %s", strerror(errno));
>  }
>  
>  /**

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-06-24  5:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-23 10:23 [PATCH] pasta: include errno in error message Paul Holzinger
2023-06-24  1:57 ` David Gibson [this message]
2023-06-26  7:22 ` Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZJZNe5xLD2QhtABD@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=pholzing@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).