public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Paul Holzinger <pholzing@redhat.com>
To: passt-dev@passt.top
Cc: Paul Holzinger <pholzing@redhat.com>
Subject: [PATCH] pasta: include errno in error message
Date: Fri, 23 Jun 2023 12:23:50 +0200	[thread overview]
Message-ID: <20230623102350.106830-1-pholzing@redhat.com> (raw)

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>
---
 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));
 }
 
 /**
-- 
@@ -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));
 }
 
 /**
-- 
2.41.0


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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-23 10:23 Paul Holzinger [this message]
2023-06-24  1:57 ` [PATCH] pasta: include errno in error message David Gibson
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=20230623102350.106830-1-pholzing@redhat.com \
    --to=pholzing@redhat.com \
    --cc=passt-dev@passt.top \
    /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).