1 #!/bin/bash 2 # 3 # Copyright (c) International Business Machines Corp., 2005 4 # Author: Avantika Mathur (mathurav (at] 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 21 SETS_DEFAULTS="${TCID=test38} ${TST_COUNT=1} ${TST_TOTAL=1}" 22 declare -r TCID 23 declare -r TST_COUNT 24 declare -r TST_TOTAL 25 export TCID TST_COUNT TST_TOTAL 26 27 tst_resm TINFO "***************TEST38***************" 28 tst_resm TINFO "rbind: private to private - with slave children." 29 tst_resm TINFO "************************************" 30 31 . "${FS_BIND_ROOT}/bin/setup" || (tst_resm TWARN "Setup of rbind/test38 failed" && tst_exit) 32 export result=0 33 34 35 36 trap 'ERR=$? ; ERR_MSG="caught error near: ${BASH_SOURCE[0]}:${FUNCNAME[0]}:${LINENO}:$_ (returned ${ERR})"; break' ERR 37 38 while /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 68 done 69 trap 'ERR=$? ; tst_resm TWARN "rbind/test38: caught error near: ${BASH_SOURCE[0]}:${FUNCNAME[0]}:${LINENO}:$_ (returned ${ERR})"' ERR 70 if [ -n "${ERR_MSG}" ]; then 71 tst_resm TWARN "rbind/test38: ${ERR_MSG}" 72 ERR_MSG="" 73 result=$ERR 74 fi 75 trap '' 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 93 if [ $result -ne 0 ] 94 then 95 tst_resm TFAIL "rbind/test38: FAILED: rbind: private to private - with slave children." 96 exit 1 97 else 98 tst_resm TPASS "rbind/test38: PASSED" 99 exit 0 100 fi 101 tst_exit 102