pasta: include errno in error message
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>
This commit is contained in:
parent
594dce66d3
commit
32660cea04
1 changed files with 6 additions and 4 deletions
10
pasta.c
10
pasta.c
|
@ -135,15 +135,17 @@ void pasta_open_ns(struct ctx *c, const char *netns)
|
||||||
int nfd = -1;
|
int nfd = -1;
|
||||||
|
|
||||||
nfd = open(netns, O_RDONLY | O_CLOEXEC);
|
nfd = open(netns, O_RDONLY | O_CLOEXEC);
|
||||||
if (nfd < 0)
|
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;
|
c->pasta_netns_fd = nfd;
|
||||||
|
|
||||||
NS_CALL(ns_check, c);
|
NS_CALL(ns_check, c);
|
||||||
|
|
||||||
if (c->pasta_netns_fd < 0)
|
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) {
|
if (!c->no_netns_quit) {
|
||||||
char buf[PATH_MAX] = { 0 };
|
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);
|
NS_CALL(pasta_wait_for_ns, c);
|
||||||
if (c->pasta_netns_fd < 0)
|
if (c->pasta_netns_fd < 0)
|
||||||
die("Failed to join network namespace");
|
die("Failed to join network namespace: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue