1#!/bin/bash -v
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
23disk1=disk1
24disk2=disk2
25disk3=disk3
26disk4=disk4
27fs=ext3
28
29mkdir -p $disk1 $disk2 $disk3 $disk4
30
31
32
33rm -rf $disk1/* $disk2/* $disk3/* $disk4/*
34
35mkdir $disk1/a $disk1/b $disk1/c
36mkdir $disk2/d $disk2/e $disk2/f
37mkdir $disk3/g $disk3/h $disk3/i
38mkdir $disk4/j $disk4/k $disk4/l
39
40lockfile="/.nslock"
41otherpid=
42startparent()
43{
44        rm -f $lockfile
45        echo $$ >| ${lockfile}parent
46        while [ 1 ]
47        do
48                otherpid="$(cat ${lockfile}child 2> /dev/null)"
49                if [ -n "$otherpid" -a -d /proc/$otherpid ]
50                then
51                        return
52                fi
53        done
54}
55
56
57startchild()
58{
59        rm -f $lockfile
60        echo $$ >| ${lockfile}child
61        while [ 1 ]
62        do
63                otherpid="$(cat ${lockfile}parent 2> /dev/null)"
64                if [ -n "$otherpid" -a -d /proc/$otherpid ]
65                then
66                        return
67                fi
68        done
69}
70
71iamgoingahead()
72{
73        while [ 1 ]
74        do
75                pid=`cat $lockfile 2> /dev/null`
76                if [ "$pid" == "$$" ]
77                then
78                        return
79                fi
80                sleep 1
81        done
82}
83
84
85goahead()
86{
87        set -x
88        echo $otherpid > $lockfile
89        set +x
90}
91
92
93check(){
94	"${FS_BIND_ROOT}/bin/check_prop" $*
95	ret=$?
96	if [ $ret -ne 0 ]; then
97		result=$ret
98	fi
99}
100export result=0
101
102cleanup(){
103	rm -rf "disk"*
104}
105