summaryrefslogtreecommitdiffstats
path: root/tests/nfs.rc
blob: 2e0241709d305969ca7b0cc349b0e64ee583cbf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash

# Due to portmap registration NFS takes some time to
# export all volumes. Therefore tests should start only
# after exports are visible by showmount command. This
# routine will check if showmount shows the exports or not
#
function is_nfs_export_available ()
{
        local vol=$1

        if [ "$vol" == "" ]; then
                vol=$V0
        fi

        exp=$(showmount -e localhost 2> /dev/null | grep $vol | wc -l)
        echo "$exp"
}

function mount_nfs ()
{
        local e=$1
        local m=$2
        local opt=$3
        if [ ! -z "$opt" ]; then opt=",$opt"; fi
        opt="soft,intr,vers=3$opt"

        nopt=""
        for o in ${opt//,/ }; do
                case $OSTYPE in
                NetBSD)
                        test "x${nopt}" = "x" && nopt="tcp,-R=2,"

                        case $o in
                        nolock|noac|actimeo=*|mountproto=udp)
                                continue
                                ;;
                        proto=tcp)
                                o="tcp"
                                ;;
                        vers=3)
                                o="nfsv3"
                                ;;
                        retry=*)
                                o=${o/retry=/-R}
                                ;;
                        timeo=*)
                                o=${o/timeo=/-t}
                                ;;
                        retrans=*)
                                o=${o/retrans=/-x}
                                ;;
                        *)
                                ;;
                        esac
                        ;;
                *)
                        ;;
                esac
                if [ ! -z "$nopt" ]; then nopt="${nopt},"; fi
                nopt="${nopt}$o"
        done

        mount -t nfs -o $nopt $e $m
}

function umount_nfs {
        umount -f $1
        if [ $? -eq 0 ]; then echo "Y"; else echo "N"; fi
}