public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] pasta: include errno in error message
@ 2023-06-23 10:23 Paul Holzinger
  2023-06-24  1:57 ` David Gibson
  2023-06-26  7:22 ` Stefano Brivio
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Holzinger @ 2023-06-23 10:23 UTC (permalink / raw)
  To: passt-dev; +Cc: Paul Holzinger

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-26  7:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-23 10:23 [PATCH] pasta: include errno in error message Paul Holzinger
2023-06-24  1:57 ` David Gibson
2023-06-26  7:22 ` Stefano Brivio

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).