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 2008 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 server name space (path) tests."
41
42 TMPmnt=$ZONE_PATH/$NAME.$$
43 mkdir -m 0777 -p $TMPmnt
44
45
46 # Start test assertions here
47 # ----------------------------------------------------------------------
48 # a: Verify pseudo path still work if mid-node is unshared, expect successful
49 function assertion_a
50 {
51 [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
52 ASSERTION="Verify pseudo path still work if mid-node is unshared"
53 ASSERTION="$ASSERTION, expect successful"
54 echo "$NAME{a}: $ASSERTION"
55 # The SRVPATH should couple mounted-on exported point
56 SRVPATH=$SSPCDIR3
57
58 is_cipso "vers=4" $SERVER
59 if [ $? -eq $CIPSO_NFSV4 ]; then
60 cipso_check_mntpaths $BASEDIR $TMPmnt
61 if [ $? -ne 0 ]; then
62 allunsupp=1
63 echo "$NAME: CIPSO NFSv4 requires non-global zone mount dirs."
64 echo "$NSPC The server's BASEDIR and client's MNTPTR"
65 echo "$NSPC must contain path legs with matching"
66 echo "$NSPC non-global zone paths."
67 echo "$NSPC: Please try again ..."
68 echo "\t Test UNSUPPORTED"
69 return $FAIL
70 fi
71 fi
72
73 # Do the mount on the $SRVPATH
74 mount -o vers=4,rw $SERVER:$SRVPATH $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
75 ckreturn $? "first mount did not succeed" $TMPDIR/$NAME.mnt.$$
76 [ $? -ne 0 ] && return $FAIL
77
78 # verify the mount point is access'ble
79 ls -lt $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
80 ckreturn $? "unable to access the mnt-point" $TMPDIR/$NAME.ck.$$
81 [ $? -ne 0 ] && return $FAIL
82
83 # Then go to server to unshare a mid-node of the SRVPATH
84 rsh -n $SERVER "$CONFIGDIR/operate_dir unshare $SSPCDIR; \
85 /usr/sbin/share" > $TMPDIR/$NAME.ushr.$$ 2>&1
86 egrep -w "$SSPCDIR" $TMPDIR/$NAME.ushr.$$ > /dev/null 2>&1
87 if [ $? -eq 0 ]; then
88 echo "\tTest FAIL: unshare failed"
89 cat $TMPDIR/$NAME.ushr.$$
90 return $FAIL
91 fi
92
93 # now umount path and try again
94 umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
95 ckreturn $? "first umount failed" $TMPDIR/$NAME.umnt.$$
96 [ $? -ne 0 ] && return $FAIL
97 mount -o vers=4,ro $SERVER:$SRVPATH $TMPmnt \
98 > $TMPDIR/$NAME.mnt.$$ 2>&1
99 ckreturn $? "2nd mount again did not succeed" $TMPDIR/$NAME.mnt.$$
100 [ $? -ne 0 ] && return $FAIL
101 # verify the mount point is access'ble
102 ls -lta $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
103 ckreturn $? "unable to access the mnt-point after unshare" $TMPDIR/$NAME.ck.$$
104 [ $? -ne 0 ] && return $FAIL
105
106 # Finally umount and done
107 umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
108 ckreturn $? "second umount failed" $TMPDIR/$NAME.umnt.$$
109 [ $? -ne 0 ] && return $FAIL
110
111 echo "\t Test PASS"
112 }
113
114
115 # Start main program here:
116 # ----------------------------------------------------------------------
117
118 assertion_a
119 [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
120
121 log=$TMPDIR/rsh.out.$$
122 # cleanup here and reset server's share pathes
123 rsh -n $SERVER "$CONFIGDIR/operate_dir share $SSPCDIR" > $log
124
125 # Record share information in journal file for debugging.
126 grep "^SHARE" $log | grep "$SSPCDIR"
127
128 rm -rf $log
129 rmdir $TMPmnt
130 rm -f $TMPDIR/$NAME.*.$$
131
132 exit 0