]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
netns: Rename & move get_netns_fd to lib
authorVadim Kochan <vadim4j@gmail.com>
Tue, 13 Jan 2015 20:08:44 +0000 (22:08 +0200)
committerStephen Hemminger <shemming@brocade.com>
Wed, 14 Jan 2015 01:34:47 +0000 (17:34 -0800)
Renamed get_netns_fd -> netns_get_fd and moved to
lib/namespace.c

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
include/namespace.h
ip/ip_common.h
ip/iplink.c
ip/ipnetns.c
lib/namespace.c

index 2f13e6594d687e9b54b0fc16d09340cd4838bb2b..b8c5cad6aaa28f368af2905b203471e77ae88288 100644 (file)
@@ -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__ */
index 75bfb824ab1f8a5c678f928a819261eb005a180e..89a495ea10747c0f6714cba084ba6f824c11c568 100644 (file)
@@ -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
index 2709173a1391d11e012e3dd1c6415b12ee4f7039..c93d1dc3d5f600b8aeb91e81712ffe77a7b8b944 100644 (file)
@@ -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);
index 519d5183626c015ab845d3f375f82c858fd3bf09..123318eb6adf44bde19e8e5b60becf8f1e4e22f0 100644 (file)
@@ -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;
index 1554ce084f82c2c14a12b2fdf3e45ee48b7d003c..65c1e3d7cd523eeadfac1b702a1320ee1531a2b5 100644 (file)
@@ -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);
+}