Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tests/sys/geom/class/mirror/conf.sh
39636 views
1
#!/bin/sh
2
3
name="$(mktemp -u mirror.XXXXXX)"
4
class="mirror"
5
base=`basename $0`
6
7
gmirror_test_cleanup()
8
{
9
[ -c /dev/$class/$name ] && gmirror destroy $name
10
geom_test_cleanup
11
}
12
trap gmirror_test_cleanup ABRT EXIT INT TERM
13
14
gmirror_worker_pid()
15
{
16
pgrep -S -n "g_mirror mirror\..*"
17
}
18
19
syncwait()
20
{
21
while $(gmirror status -s $name | grep -q SYNCHRONIZING); do
22
sleep 0.1;
23
done
24
}
25
26
consumerrefs()
27
{
28
gclass=$1
29
geom=$2
30
31
if [ $# -ne 2 ]; then
32
echo "Bad usage consumerrefs" >&2
33
exit 1
34
fi
35
36
geom "${gclass}" list "${geom}" | \
37
grep -A5 ^Consumers | \
38
grep Mode | \
39
cut -d: -f2
40
}
41
42
disconnectwait()
43
{
44
gclass=$1
45
geom=$2
46
47
if [ $# -ne 2 ]; then
48
echo "Bad usage disconnectwait" >&2
49
exit 1
50
fi
51
52
while [ $(consumerrefs "$gclass" "$geom") != r0w0e0 ]; do
53
sleep 0.05
54
done
55
}
56
57
. `dirname $0`/../geom_subr.sh
58
59