public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH] ip netns: Show error message if mkdir failed to create /var/run/netns
@ 2014-08-28 13:02 vadimk
  2014-08-28 13:54 ` Nicolas Dichtel
  0 siblings, 1 reply; 4+ messages in thread
From: vadimk @ 2014-08-28 13:02 UTC (permalink / raw)
  To: netdev; +Cc: vadimk

Currently if mkdir failed with "Permission denied" error then "mount --make-shared ..."
error message will be showed because /var/run/netns does not exist.
---
 ip/ipnetns.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 633b5b9..7f82908 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
-- 
2.0.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH] ip netns: Show error message if mkdir failed to create /var/run/netns
@ 2014-08-28 12:38 vadimk
  2014-08-28 12:52 ` David Laight
  0 siblings, 1 reply; 4+ messages in thread
From: vadimk @ 2014-08-28 12:38 UTC (permalink / raw)
  To: netdev; +Cc: vadimk

Currently if mkdir failed with "Permission denied" error then "mount --make-shared ..."
error message will be showed because /var/run/netns does not exist.
---
 ip/ipnetns.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 633b5b9..ee06eba 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -407,7 +407,11 @@ 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)) {
+		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
-- 
2.0.4

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

end of thread, other threads:[~2014-08-28 13:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-28 13:02 [PATCH] ip netns: Show error message if mkdir failed to create /var/run/netns vadimk
2014-08-28 13:54 ` Nicolas Dichtel
  -- strict thread matches above, loose matches on Subject: below --
2014-08-28 12:38 vadimk
2014-08-28 12:52 ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox