Skip to contentSkip to conversation

netns: Rename & move get_netns_fd to lib

PATCH New Vadim Kochan 1 participant 1 message Jan 13, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netns: Rename & move get_netns_fd to lib

From: Vadim Kochan <[email protected]>

Renamed get_netns_fd -> netns_get_fd and moved to
lib/namespace.c

---
 include/namespace.h |  1 +
 ip/ip_common.h      |  1 -
 ip/iplink.c         |  3 ++-
 ip/ipnetns.c        | 15 ---------------
 lib/namespace.c     | 15 +++++++++++++++
 5 files changed, 18 insertions(+), 17 deletions(-)
include/namespace.h +1 -0
index 2f13e65..b8c5cad 100644
@@ -42,5 +42,6 @@ static int setns(int fd, int nstype)
 #endif /* HAVE_SETNS */
 
 extern int netns_switch(char *netns);
+extern int netns_get_fd(const char *netns);
 
 #endif /* __NAMESPACE_H__ */
ip/ip_common.h +0 -1
index 75bfb82..89a495e 100644
@@ -87,7 +87,6 @@ struct link_util
 
 struct link_util *get_link_kind(const char *kind);
 struct link_util *get_link_slave_kind(const char *slave_kind);
-int get_netns_fd(const char *name);
 
 #ifndef	INFINITY_LIFE_TIME
 #define     INFINITY_LIFE_TIME      0xFFFFFFFFU
ip/iplink.c +2 -1
index 2709173..c93d1dc 100644
@@ -32,6 +32,7 @@
 #include "rt_names.h"
 #include "utils.h"
 #include "ip_common.h"
+#include "namespace.h"
 
 #define IPLINK_IOCTL_COMPAT	1
 #ifndef LIBDIR
@@ -440,7 +441,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 			NEXT_ARG();
 			if (netns != -1)
 				duparg("netns", *argv);
-			if ((netns = get_netns_fd(*argv)) >= 0)
+			if ((netns = netns_get_fd(*argv)) >= 0)
 				addattr_l(&req->n, sizeof(*req), IFLA_NET_NS_FD, &netns, 4);
 			else if (get_integer(&netns, *argv, 0) == 0)
 				addattr_l(&req->n, sizeof(*req), IFLA_NET_NS_PID, &netns, 4);
ip/ipnetns.c +0 -15
index 519d518..123318e 100644
@@ -31,21 +31,6 @@ static int usage(void)
 	exit(-1);
 }
 
-int get_netns_fd(const char *name)
-{
-	char pathbuf[MAXPATHLEN];
-	const char *path, *ptr;
-
-	path = name;
-	ptr = strchr(name, '/');
-	if (!ptr) {
-		snprintf(pathbuf, sizeof(pathbuf), "%s/%s",
-			NETNS_RUN_DIR, name );
-		path = pathbuf;
-	}
-	return open(path, O_RDONLY);
-}
-
 static int netns_list(int argc, char **argv)
 {
 	struct dirent *entry;
lib/namespace.c +15 -0
index 1554ce0..65c1e3d 100644
@@ -84,3 +84,18 @@ int netns_switch(char *name)
 	bind_etc(name);
 	return 0;
 }
+
+int netns_get_fd(const char *name)
+{
+	char pathbuf[MAXPATHLEN];
+	const char *path, *ptr;
+
+	path = name;
+	ptr = strchr(name, '/');
+	if (!ptr) {
+		snprintf(pathbuf, sizeof(pathbuf), "%s/%s",
+			NETNS_RUN_DIR, name );
+		path = pathbuf;
+	}
+	return open(path, O_RDONLY);
+}
Signature · 1 line
2.1.3