1#!/bin/bash
2
3#
4# Copyright (c) International Business Machines  Corp., 2005
5# Author: Avantika Mathur (mathurav@us.ibm.com)
6#
7# This library is free software; you can redistribute it and/or
8# modify it under the terms of the GNU Lesser General Public
9# License as published by the Free Software Foundation; either
10# version 2.1 of the License, or (at your option) any later version.
11#
12# This library is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15# Lesser General Public License for more details.
16#
17# You should have received a copy of the GNU Lesser General Public
18# License along with this library; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20#
21
22
23SETS_DEFAULTS="${TCID=test02} ${TST_COUNT=1} ${TST_TOTAL=1}"
24declare -r TCID
25declare -r TST_COUNT
26declare -r TST_TOTAL
27export TCID TST_COUNT TST_TOTAL
28
29tst_resm TINFO "***************TEST02***************"
30tst_resm TINFO "cloneNS: namespaces with parent-slave"
31tst_resm TINFO "************************************"
32
33. "${FS_BIND_ROOT}/bin/setup" || (tst_resm TWARN "Setup of cloneNS/test02 failed" && tst_exit)
34export result=0
35
36
37trap 'ERR=$? ; ERR_MSG="caught error near: ${BASH_SOURCE[0]}:${FUNCNAME[0]}:${LINENO}:$_ (returned ${ERR})"; break' ERR
38
39while /bin/true ; do
40	# This loop is for error recovery purposes only
41
42	cp "${FS_BIND_ROOT}/cloneNS/parent02" ./
43	cp "${FS_BIND_ROOT}/cloneNS/child02" .
44
45	chmod 755 parent02 child02
46
47	"${FS_BIND_ROOT}/bin/makedir" share dir1
48	mount --bind "$disk1" dir1
49
50	mkdir dir2
51	mount --bind dir1 dir2
52	"${FS_BIND_ROOT}/bin/makedir" slave dir2
53
54	"${FS_BIND_ROOT}/bin/nsclone" ./parent02 ./child02 || result=$?
55
56	break
57done
58trap 'ERR=$? ; tst_resm TWARN "cloneNS/test02: caught error near: ${BASH_SOURCE[0]}:${FUNCNAME[0]}:${LINENO}:$_ (returned ${ERR})"' ERR
59if [ -n "${ERR_MSG}" ]; then
60	tst_resm TWARN "cloneNS/test02: ${ERR_MSG}"
61	ERR_MSG=""
62	result=$ERR
63fi
64trap '' ERR
65{
66	umount dir1/a
67	umount dir2/b
68	umount dir1/c
69	umount dir2
70	umount dir1
71	umount dir1
72
73	rm -rf dir* parent* child*
74
75	cleanup
76} >& /dev/null
77if [ $result -ne 0 ]
78then
79	tst_resm TFAIL "cloneNS/test02: FAILED: cloneNS: namespaces with parent-slave"
80	exit 1
81else
82	tst_resm TPASS "cloneNS/test02: PASSED"
83	exit 0
84fi
85tst_exit
86