aboutgitcodebugslistschat
path: root/pasta.c
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2023-06-23 12:23:50 +0200
committerStefano Brivio <sbrivio@redhat.com>2023-06-25 23:50:42 +0200
commit32660cea04f6e7c353435061b876575539ac8cd9 (patch)
tree261aabbc43bfc2bad98bf2ba2c77113f292c335f /pasta.c
parent594dce66d3bbe30fa3f7ccce8b8eebb0bf3e7f2e (diff)
downloadpasst-32660cea04f6e7c353435061b876575539ac8cd9.tar
passt-32660cea04f6e7c353435061b876575539ac8cd9.tar.gz
passt-32660cea04f6e7c353435061b876575539ac8cd9.tar.bz2
passt-32660cea04f6e7c353435061b876575539ac8cd9.tar.lz
passt-32660cea04f6e7c353435061b876575539ac8cd9.tar.xz
passt-32660cea04f6e7c353435061b876575539ac8cd9.tar.zst
passt-32660cea04f6e7c353435061b876575539ac8cd9.zip
pasta: include errno in error message2023_06_25.32660ce
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> [sbrivio: Split print to fit 80 columns in pasta_open_ns()] Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'pasta.c')
-rw-r--r--pasta.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/pasta.c b/pasta.c
index 13ab18b..8c85546 100644
--- a/pasta.c
+++ b/pasta.c
@@ -135,15 +135,17 @@ void pasta_open_ns(struct ctx *c, const char *netns)
int nfd = -1;
nfd = open(netns, O_RDONLY | O_CLOEXEC);
- if (nfd < 0)
- die("Couldn't open network namespace %s", netns);
+ if (nfd < 0) {
+ 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 +263,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));
}
/**