Veerendra wrote:
Signed-off-by: Veerendra C <[EMAIL PROTECTED]>
This patch consists of the files..
containers/netns/child_propogate.sh
containers/netns/parent_share.sh
containers/netns/parent_view.sh
containers/netns/sysfsview.c
Regards
Veerendra C
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"lxc-dev" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/lxc-dev?hl=en
-~----------~----~----~----~------~----~------~--~---
Attaching the patch..
Index: containers/netns/child_propogate.sh
===================================================================
--- /dev/null
+++ containers/netns/child_propogate.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+# This script propogates the child sysfs contents to be visible for parent
+# Also it will check the parent sysfs contents are visible.
+
+#Propogate child sys directory
+#set -x
+# The test case ID, the test case count and the total number of test case
+TCID=${TCID:-child_propogate.sh}
+TST_TOTAL=1
+TST_COUNT=1
+export TCID
+export TST_COUNT
+export TST_TOTAL
+
+PROPOGATE=`cat /tmp/FIFO4`
+tst_resm TINFO "CHILD propopagated.."
+mount -t sysfs none /sys
+mkdir -p /tmp/mnt/sys
+mount --bind /sys /tmp/mnt/sys > /dev/null
+
+if [ $? -ne 0 ]
+then
+ status=-1
+ tst_resm TFAIL "error while doing bind mount"
+ exit $status
+fi
+#Capture childs sysfs contents
+ls /sys/class/net > /tmp/child_sysfs
+echo propogated > /tmp/FIFO5
+
+#Capture parent sysfs in child
+ls /oldsys/class/net > /tmp/parent_sysfs_in_child
+diff /tmp/parent_sysfs_in_child /tmp/parent_sysfs > /dev/null 2>&1
+if [ $? -eq 0 ]
+then
+ tst_resm TINFO "Pass:Child is able to view parent sysfs"
+ status=0
+else
+ tst_resm TFAIL "Fail:Child view of sysfs is not same as parent sysfs"
+ status=-1
+fi
+
+#cleanup
+rm -f /tmp/parent_sysfs_in_child /tmp/parent_sysfs
+umount /tmp/mnt/sys
+#rm -rf /tmp/mnt
+cleanup $sshpid veth9
+exit $status
Index: containers/netns/parent_share.sh
===================================================================
--- /dev/null
+++ containers/netns/parent_share.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+# This script is executed in the parent NS.
+# It binds and does sharable mount of sysfs .
+#
+#For child to refer parent sys
+#set -x
+
+# The test case ID, the test case count and the total number of test case
+TCID=${TCID:-parent_share.sh}
+TST_TOTAL=1
+TST_COUNT=1
+export TCID
+export TST_COUNT
+export TST_TOTAL
+
+
+source initialize.sh
+mkdir -p /oldsys /tmp/mnt
+mount --bind /sys /oldsys
+
+#share parent namespace
+mount --bind /tmp/mnt /tmp/mnt
+#mount --make-shared /mnt
+tst_resm TINFO "$smount"
+$smount /tmp/mnt shared > /dev/null
+if [ $? -ne 0 ]
+then
+ status=-1
+ tst_resm TFAIL "Error whild doing shared mount"
+ exit $status
+fi
+
+tst_resm TINFO "End of $0 script..."
+
Index: containers/netns/parent_view.sh
===================================================================
--- /dev/null
+++ containers/netns/parent_view.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+# This script verifies the contents of child sysfs is visible in parent NS.
+
+# The test case ID, the test case count and the total number of test case
+TCID=${TCID:-parent_view.sh}
+TST_TOTAL=1
+TST_COUNT=1
+export TCID
+export TST_COUNT
+export TST_TOTAL
+
+
+#capture parent /sys contents
+
+tst_resm TINFO "Parent SYSFS view"
+ls /sys/class/net > /tmp/parent_sysfs
+echo PROPOGATE > /tmp/FIFO4
+
+PROPOGATED=`cat /tmp/FIFO5`
+ls /tmp/mnt/sys/class/net > /tmp/child_sysfs_in_parent
+diff /tmp/child_sysfs_in_parent /tmp/child_sysfs
+if [ $? -eq 0 ]
+then
+ tst_resm TINFO "Pass: Parent is able to view child sysfs"
+ status=0
+else
+ tst_resm TFAIL "Fail: Parent is not able to view Child-NS sysfs"
+ status=-1
+fi
+
+#cleanup temp files
+rm -f /tmp/child_sysfs_in_parent /tmp/child_sysfs
+umount /oldsys
+umount /tmp/mnt
Index: containers/netns/sysfsview.c
===================================================================
--- /dev/null
+++ containers/netns/sysfsview.c
@@ -0,0 +1,46 @@
+
+/*************************************************************************
+* Copyright (c) International Business Machines Corp., 2008
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+* the GNU General Public License for more details.
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*
+***************************************************************************/
+
+/* ============================================================================
+* This testcase uses the libnetns.c from the lib to create network NS1.
+* In libnetns.c it uses 2 scripts parentns.sh and childns.sh to create this.
+*
+* This testcase verifies sysfs contents of parentNS is visible from child NS.
+* Also it checks the sysfs contents of the child are visible from the parent NS.
+* On Success it returns PASS else returns FAIL
+*
+* Scripts used: parent_share.sh parent_view.sh child_propogate.sh
+* parentns.sh childns.sh
+*
+*
+* Authors: Poornima Nayak <[EMAIL PROTECTED]>
+* Veerendra C <[EMAIL PROTECTED]>
+* 31/07/2008
+* ============================================================================*/
+#include <stdlib.h>
+
+extern int create_net_namespace(char *, char *);
+int main()
+{
+ int status = 0;
+
+ /* Parent should be able to view child sysfs and vice versa */
+ system ("./parent_share.sh");
+ status = create_net_namespace("parent_view.sh","child_propogate.sh");
+ 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list