This patch has the makefile and library required. please apply all the 9
patches before you start testing/reviewing them
This patch addresses the comments for the below 3 files .
libclone/Makefile -
libclone/libclone.h -
Where it adds the flags required for the netns and
function wrapper for unshare
libclone/libnetns.c -
Adds a function() to create the network namespaces.
Signed off by Veerendra C <[EMAIL PROTECTED]>
ACKed by Serge Hallyn <[EMAIL PROTECTED]>
Modified to include the libnetns.a lib
--- containers.old/libclone/Makefile 2008-09-10 22:52:27.000000000 +0530
+++ containers/libclone/Makefile 2008-09-10 22:35:42.000000000 +0530
@@ -23,7 +23,7 @@ OBJS := $(SRCS:%.c=%.o)
HAS_UNSHARE ?= $(shell ../check_for_unshare && echo y)
ifeq ($(HAS_UNSHARE),y)
-TARGET := libclone.a
+TARGET := libclone.a libnetns.a
else
TARGET :=
endif
@@ -33,6 +33,9 @@ all: $(TARGET)
libclone.a: $(OBJS)
$(AR) -cr $@ $^
+libnetns.a: $(OBJS)
+ $(AR) -cr $@ $^
+
clean:
rm -f $(TARGET) $(OBJS)
--- containers.old/libclone/libclone.h 2008-09-10 22:50:38.000000000 +0530
+++ containers/libclone/libclone.h 2008-09-10 22:55:32.000000000 +0530
@@ -82,6 +82,8 @@ extern int __clone2(int (*fn) (void *ar
#define CLONE_NEWNET 0x40000000
#endif
+extern int create_net_namespace(char *, char *);
+
/*
* Run fn1 in a unshared environmnent, and fn2 in the original context
* Fn2 may be NULL.
Evaluating the return value after system() and status value.
--- containers.old/libclone/libnetns.c 2008-09-08 17:18:28.000000000 +0530
+++ containers/libclone/libnetns.c 2008-09-10 22:58:02.000000000 +0530
@@ -84,6 +84,7 @@ int create_net_namespace(char *p1, char
ret = unshare(flags);
if (ret < 0) {
perror("unshare");
+ printf ("Error:Unshare syscall failed for network namespace\n");
return 1;
}
return crtchild(child, c1);
@@ -93,7 +94,7 @@ int create_net_namespace(char *p1, char
//parent
ret = system(par);
status = WEXITSTATUS(ret);
- if (status != 0) {
+ if ( ret == -1 || status != 0) {
printf("Error while running the script\n");
fflush(stdout);
exit(1);
@@ -101,11 +102,10 @@ int create_net_namespace(char *p1, char
fflush(stdout);
ret = waitpid(pid, &status, __WALL);
- if (status != 0 || ret < 0){
- printf("waitpid() returns %d, errno %d\n", ret, errno);
- status = errno;
- }
+ status = WEXITSTATUS(status);
+ if ( ret == -1 || status != 0)
+ printf("Error: waitpid() returns %d, status %d\n", ret, status);
- return 0;
}
+ return status;
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list