• 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=test38} ${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 "***************TEST38***************"
28tst_resm TINFO "rbind: private to private - with slave children."
29tst_resm TINFO "************************************"
30
31. "${FS_BIND_ROOT}/bin/setup" || (tst_resm TWARN "Setup of rbind/test38 failed" && tst_exit)
32export result=0
33
34
35
36trap 'ERR=$? ; ERR_MSG="caught error near: ${BASH_SOURCE[0]}:${FUNCNAME[0]}:${LINENO}:$_ (returned ${ERR})"; break' ERR
37
38while /bin/true ; do
39	# This loop is for error recovery purposes only
40
41
42	mkdir parent1 parent2 parent1/child1 parent2/child2
43	"${FS_BIND_ROOT}/bin/makedir" share share1
44	"${FS_BIND_ROOT}/bin/makedir" share share2
45	mount --rbind share1 parent1/child1
46	mount --rbind share2 parent2/child2
47	"${FS_BIND_ROOT}/bin/makedir" slave parent1/child1
48	"${FS_BIND_ROOT}/bin/makedir" slave parent2/child2
49
50	mount --bind "$disk1" share1
51
52	mount --rbind parent1 parent2
53
54	check parent1 parent2
55	check parent1/child1 parent2/child1
56
57	mount --bind "$disk2" share1/a
58	check parent1/child1/a parent2/child1/a share1/a
59
60	mount --bind "$disk3" parent1/child1/b
61	check -n parent1/child1/b share1/b
62
63	mount --bind "$disk4" parent2/child1/c
64	check -n parent2/child1/c share1/c
65
66
67	break
68done
69trap 'ERR=$? ; tst_resm TWARN "rbind/test38: caught error near: ${BASH_SOURCE[0]}:${FUNCNAME[0]}:${LINENO}:$_ (returned ${ERR})"' ERR
70if [ -n "${ERR_MSG}" ]; then
71	tst_resm TWARN "rbind/test38: ${ERR_MSG}"
72	ERR_MSG=""
73	result=$ERR
74fi
75trap '' ERR
76{
77	umount share1/a
78	umount parent1/child1/b
79	umount parent2/child1/c
80	umount parent1/child1
81	umount parent1/child1
82	umount parent2/child1
83	umount parent2/child1
84	umount parent2
85	umount share1
86	umount share1
87	umount share2
88	umount parent2/child2
89
90	rm -rf parent* share*
91	cleanup
92} >& /dev/null
93if [ $result -ne 0 ]
94then
95	tst_resm TFAIL "rbind/test38: FAILED: rbind: private to private - with slave children."
96	exit 1
97else
98	tst_resm TPASS "rbind/test38: PASSED"
99	exit 0
100fi
101tst_exit
102