From: vadimk Date: Thu, 28 Aug 2014 13:56:03 +0000 (+0300) Subject: ip netns: Show error message if mkdir failed to create /var/run/netns X-Git-Tag: v3.17.0~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcf1aae8a8f6abcebfe49eaf6a3d78dff5c20f3e;p=thirdparty%2Fiproute2.git ip netns: Show error message if mkdir failed to create /var/run/netns Currently if mkdir failed with "Permission denied" error then "mount --make-shared ..." error message will be showed because /var/run/netns does not exist. Signed-off-by: Vadim Kochan Signed-off-by: Stephen Hemminger --- diff --git a/ip/ipnetns.c b/ip/ipnetns.c index 633b5b962..7f829088f 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -407,7 +407,13 @@ static int netns_add(int argc, char **argv) snprintf(netns_path, sizeof(netns_path), "%s/%s", NETNS_RUN_DIR, name); /* Create the base netns directory if it doesn't exist */ - mkdir(NETNS_RUN_DIR, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH); + if (mkdir(NETNS_RUN_DIR, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)) { + if (errno != EEXIST) { + fprintf(stderr, "mkdir %s failed: %s\n", + NETNS_RUN_DIR, strerror(errno)); + return -1; + } + } /* Make it possible for network namespace mounts to propagate between * mount namespaces. This makes it likely that a unmounting a network