1 #! /usr/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27 # NFSv4 client name space test - positive tests
28 #
29
30 [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
31
32 NAME=`basename $0`
33 CDIR=`pwd`
34 NSPC=`echo $NAME | sed 's/./ /g'`
35
36 # Source for common functions
37 . $TESTROOT/testsh
38
39 # check for root to run
40 is_root $NAME "NFSv4 basic server name space tests."
41
42 TMPmnt=$ZONE_PATH/$NAME.$$
43 mkdir -m 0777 -p $TMPmnt
44
45 allunsupp=0
46 is_cipso "vers=4" $SERVER
47 if [ $? -eq $CIPSO_NFSV4 ]; then
48 cipso_check_mntpaths $BASEDIR $TMPmnt
49 if [ $? -ne 0 ]; then
50 allunsupp=1
51 echo "$NAME: UNSUPPORTED"
52 echo "$NAME: CIPSO NFSv4 requires non-global zone mount dirs."
53 echo "$NSPC The server's BASEDIR and client's MNTPTR"
54 echo "$NSPC must contain path legs with matching"
55 echo "$NSPC non-global zone paths."
56 echo "$NSPC: Please try again ..."
57 fi
58 fi
59
60 # Start test assertions here
61 # ----------------------------------------------------------------------
62 # a: Verify v4 mount of server's exported point, expect successful
63 function assertion_a
64 {
65 [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
66 ASSERTION="Verify v4 mount of server's exported point, expect successful"
67 echo "$NAME{a}: $ASSERTION"
68 SRVPATH=$BASEDIR
69
70 if [ $allunsupp -eq 1 ]; then
71 echo "\t Test UNSUPPORTED"
72 return $FAIL
73 fi
74
75 # Do the mount on the $SRVPATH
76 mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
77 ckreturn $? "mount did not succeed" $TMPDIR/$NAME.mnt.$$
78 [ $? -ne 0 ] && return $FAIL
79
80 # verify the mount point is accessible
81 ls $TMPmnt/$LARGEDIR > $TMPDIR/$NAME.ck.$$ 2>&1
82 ckreturn $? "unable to access ($TMPmnt/$LARGEDIR)" $TMPDIR/$NAME.ck.$$
83 [ $? -ne 0 ] && return $FAIL
84
85 # finally umount it
86 umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
87 ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
88 [ $? -ne 0 ] && return $FAIL
89
90 echo "\t Test PASS"
91 }
92
93
94 # b: Verify v4 mount of dir below server's exported point, expect successful
95 function assertion_b
96 {
97 [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
98 ASSERTION="Verify v4 mount of dir below exported point, expect successful"
99 echo "$NAME{b}: $ASSERTION"
100 SRVPATH=$BASEDIR/$DIR0777
101
102 if [ $allunsupp -eq 1 ]; then
103 echo "\t Test UNSUPPORTED"
104 return $FAIL
105 fi
106
107 # Do the mount on the $SRVPATH
108 mount -o vers=4,forcedirectio $SERVER:$SRVPATH $TMPmnt \
109 > $TMPDIR/$NAME.mnt.$$ 2>&1
110 ckreturn $? "mount did not succeed" $TMPDIR/$NAME.mnt.$$
111 [ $? -ne 0 ] && return $FAIL
112
113 # verify the mount point is accessible
114 cat $TMPmnt/$RWFILE > $TMPDIR/$NAME.ck.$$ 2>&1
115 ckreturn $? "unable to access ($TMPmnt/$RWFILE)" $TMPDIR/$NAME.ck.$$
116 [ $? -ne 0 ] && return $FAIL
117
118 # finally umount it
119 umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
120 ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
121 [ $? -ne 0 ] && return $FAIL
122
123 echo "\t Test PASS"
124 }
125
126
127 # c: Verify v4 mount of dir above server's exported point, expect successful
128 function assertion_c
129 {
130 [[ -n "$DEBUG" ]] && [[ "$DEBUG" != "0" ]] && set -x
131 ASSERTION="Verify v4 mount of dir above exported point, expect successful"
132 echo "$NAME{c}: $ASSERTION"
133 MNTPATH=$(dirname $BASEDIR)
134 SRVPATH=$TMPmnt/$(basename $BASEDIR)
135
136 if [ $allunsupp -eq 1 ]; then
137 echo "\t Test UNSUPPORTED"
138 return $FAIL
139 fi
140
141 # Do the mount on the $MNTPATH
142 mount -o vers=4,noac,rw $SERVER:$MNTPATH/ $TMPmnt \
143 > $TMPDIR/$NAME.mnt.$$ 2>&1
144 ckreturn $? "mount did not succeed" $TMPDIR/$NAME.mnt.$$
145 (( $? != 0 )) && return $FAIL
146
147 # verify the mount point is accessible
148 ls -al $TMPmnt |grep $(basename $BASEDIR) > $TMPDIR/$NAME.ls.$$ 2>&1
149 ckreturn $? \
150 "unable to list the content of the mount point ($TMPmnt)" \
151 $TMPDIR/$NAME.ls.$$
152 (( $? != 0 )) && return $FAIL
153
154 if (( TestZFS == 0 )); then
155 # verify the shared dir on server is writable
156 touch $SRVPATH/file > $TMPDIR/$NAME.touch.$$ 2>&1
157 ckreturn $? \
158 "unable to create file on child dir of mounted filesystem ($SRVPATH)" \
159 $TMPDIR/$NAME.touch.$$
160 (( $? != 0 )) && return $FAIL
161
162 # verify the shared dir on server is access'ble
163 ls -al $SRVPATH |grep file > $TMPDIR/$NAME.ls.$$ 2>&1
164 ckreturn $? \
165 "unable to list the content of child dir of mounted filesystem \
166 ($SRVPATH)" \
167 $TMPDIR/$NAME.ls.$$
168 (( $? != 0 )) && return $FAIL
169 fi
170
171 # finally umount it
172 umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
173 ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
174 (( $? != 0 )) && return $FAIL
175
176 echo "\t Test PASS"
177 }
178
179
180 # Start main program here:
181 # ----------------------------------------------------------------------
182
183 assertion_a
184 [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
185 assertion_b
186 [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
187 assertion_c
188 [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
189
190 # cleanup here
191 rmdir $TMPmnt
192 rm -f $TMPDIR/$NAME.*.$$
193
194 exit 0