This patch addresses the comments if any, on the below files
child_propogate.sh - Propagates the contents of the child sysfs to parentNS.
parent_share.sh - Creates a sharable volume of the sysfs for child to access.
parent_view.sh - Parent NS verifies the contents of the child sysfs.
sysfsview.c - Basic program to create namespaces for sysfs checking
Signed off by Veerendra C <[EMAIL PROTECTED]>
ACKed by Serge Hallyn <[EMAIL PROTECTED]>
Renamed the file to child_propagate.sh to address the spelling change !
--- containers.old/netns/child_propogate.sh 2008-09-08 17:18:28.000000000 +0530
+++ containers/netns/child_propogate.sh 1970-01-01 05:30:00.000000000 +0530
@@ -1,47 +0,0 @@
-#!/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
-
-# 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
-#set -x
-export TCID
-export TST_COUNT
-export TST_TOTAL
-
- ret=0
- PROPOGATE=`cat /tmp/FIFO4`
- debug "INFO: CHILD propopagated.."
- mount -t sysfs none /sys || ret=1
- mkdir -p /tmp/mnt/sys || ret=1
- mount --bind /sys /tmp/mnt/sys > /dev/null || ret=1
-
- if [ $ret -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 /tmp/par_sysfs/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
-
- echo $status > /tmp/FIFO6
-
- #cleanup
- rm -f /tmp/parent_sysfs_in_child /tmp/parent_sysfs
- umount /tmp/mnt/sys
--- containers.old/netns/child_propagate.sh 1970-01-01 05:30:00.000000000 +0530
+++ containers/netns/child_propagate.sh 2008-09-10 01:06:42.000000000 +0530
@@ -0,0 +1,46 @@
+#!/bin/bash
+# This script propagates the child sysfs contents to be visible for parent
+# Also it will check the parent sysfs contents are visible.
+#Propagate child sys directory
+
+# The test case ID, the test case count and the total number of test case
+TCID=${TCID:-child_propagate.sh}
+TST_TOTAL=1
+TST_COUNT=1
+#set -x
+export TCID
+export TST_COUNT
+export TST_TOTAL
+
+ ret=0
+ PROPAGATE=`cat /tmp/FIFO4`
+ debug "INFO: CHILD propagated.."
+ mount -t sysfs none /sys || ret=1
+ mkdir -p /tmp/mnt/sys || ret=1
+ mount --bind /sys /tmp/mnt/sys > /dev/null || ret=1
+
+ if [ $ret -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 propagated > /tmp/FIFO5
+
+ #Capture parent sysfs in child
+ ls /tmp/par_sysfs/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 > /dev/null 2>&1 || true
Addressing the spelling error and also removed the redundant entry
of passing status value.
--- containers.old/netns/parent_view.sh 2008-09-08 17:18:28.000000000 +0530
+++ containers/netns/parent_view.sh 2008-09-10 01:06:42.000000000 +0530
@@ -13,9 +13,9 @@ export TST_TOTAL
debug "INFO: Parent SYSFS view"
ls /sys/class/net > /tmp/parent_sysfs
- echo PROPOGATE > /tmp/FIFO4
+ echo PROPAGATE > /tmp/FIFO4
- PROPOGATED=`cat /tmp/FIFO5`
+ PROPAGATED=`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 ]
@@ -27,14 +27,11 @@ export TST_TOTAL
status=-1
fi
- stat=`cat /tmp/FIFO6`
- if [ $stat != 0 ] ; then
- status=$stat
- fi
-
#cleanup temp files
+
rm -f /tmp/child_sysfs_in_parent /tmp/child_sysfs
umount /tmp/par_sysfs
umount /tmp/mnt
sleep 1
rm -rf /tmp/par_sysfs /tmp/mnt > /dev/null 2>&1 || true
+ cleanup $sshpid $vnet0
Modified to include the filename change and to return proper return value.
--- containers.old/netns/sysfsview.c 2008-09-08 17:18:28.000000000 +0530
+++ containers/netns/sysfsview.c 2008-09-10 21:55:00.000000000 +0530
@@ -24,7 +24,7 @@
* 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
+* Scripts used: parent_share.sh parent_view.sh child_propagate.sh
* parentns.sh childns.sh
*
*
@@ -38,7 +38,6 @@
#include <sys/wait.h>
#include "../libclone/libclone.h"
-extern int create_net_namespace(char *, char *);
int main()
{
int len, ret, status = 0;
@@ -59,12 +58,12 @@ int main()
/* Parent should be able to view child sysfs and vice versa */
ret = system(script);
status = WEXITSTATUS(ret);
- if (status != 0) {
+ if ( ret == -1 || status != 0) {
printf("Error while executing the script %s\n", script);
fflush(stdout);
exit(1);
}
- status = create_net_namespace("parent_view.sh","child_propogate.sh");
+ status = create_net_namespace("parent_view.sh","child_propagate.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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list