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