Home | History | Annotate | Download | only in rbind
      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=test02} ${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 "***************TEST02***************"
     28 tst_resm TINFO "rbind: shared child to private parent."
     29 tst_resm TINFO "************************************"
     30 
     31 . "${FS_BIND_ROOT}/bin/setup" || (tst_resm TWARN "Setup of rbind/test02 failed" && tst_exit)
     32 export result=0
     33 
     34 
     35 trap 'ERR=$? ; ERR_MSG="caught error near: ${BASH_SOURCE[0]}:${FUNCNAME[0]}:${LINENO}:$_ (returned ${ERR})"; break' ERR
     36 
     37 while /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
     64 done
     65 trap 'ERR=$? ; tst_resm TWARN "rbind/test02: caught error near: ${BASH_SOURCE[0]}:${FUNCNAME[0]}:${LINENO}:$_ (returned ${ERR})"' ERR
     66 if [ -n "${ERR_MSG}" ]; then
     67 	tst_resm TWARN "rbind/test02: ${ERR_MSG}"
     68 	ERR_MSG=""
     69 	result=$ERR
     70 fi
     71 trap '' 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 
     87 if [ $result -ne 0 ]
     88 then
     89 	tst_resm TFAIL "rbind/test02: FAILED: rbind: shared child to private parent."
     90 	exit 1
     91 else
     92 	tst_resm TPASS "rbind/test02: PASSED"
     93 	exit 0
     94 fi
     95 
     96 
     97 tst_exit
     98