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 for NFS urls
  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 name space tests with URLs."
  41 
  42 TMPmnt=$ZONE_PATH/$NAME.$$
  43 mkdir -m 0777 -p $TMPmnt
  44 
  45 # in case user wants to run IPv6
  46 [[ $TRANSPORT == *6 ]] && tTCP=tcp6 || tTCP=tcp
  47 
  48 # check for cipso connection
  49 # note that the cases in this test only verify the mount point is accessible or
  50 # not, so it only check READ ops, there's no WRITE ops. Due to the NFSv4 url
  51 # mount does not work well at present (please see CR 6450723), your WRITE ops
  52 # will probably fail if you doing mount with TX+webnfs
  53 allunsupp=0
  54 is_cipso "vers=4" $SERVER
  55 if [ $? -eq $CIPSO_NFSV4 ]; then
  56         cipso_check_mntpaths $BASEDIR $TMPmnt
  57         if [ $? -ne 0 ]; then
  58                 allunsupp=1
  59                 echo "$NAME: UNSUPPORTED"
  60                 echo "$NAME: CIPSO NFSv4 requires non-global zone mount dirs."
  61                 echo "$NSPC  The server's BASEDIR and client's MNTPTR"
  62                 echo "$NSPC  must contain path legs with matching"
  63                 echo "$NSPC  non-global zone paths."
  64                 echo "$NSPC: Please try again ..."
  65         fi
  66 fi
  67 
  68 # Start test assertions here
  69 # ----------------------------------------------------------------------
  70 # a: Verify v4 NFS url mount of server's exported FS, expect successful
  71 function assertion_a
  72 {
  73     [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  74     ASSERTION="Verify v4 NFS url mount of server's exported FS, \
  75                 expect successful"
  76     echo "$NAME{a}: $ASSERTION"
  77 
  78     if [ $allunsupp -eq 1 ]; then
  79         echo "\t Test UNSUPPORTED"
  80         return $FAIL
  81     fi
  82 
  83     # Do the NFS url mount on the $SERVER public dir
  84     mount -o vers=4 nfs://$SERVER/ $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
  85     ckreturn $? "mount did not succeed" $TMPDIR/$NAME.mnt.$$
  86     [ $? -ne 0 ] && return $FAIL
  87 
  88     # verify the mount point is accessible
  89     ls $TMPmnt/$LARGEDIR > $TMPDIR/$NAME.ck.$$ 2>&1
  90     ckreturn $? "unable to access ($TMPmnt/$LARGEDIR)" $TMPDIR/$NAME.ck.$$
  91     [ $? -ne 0 ] && return $FAIL
  92 
  93     # finally umount it
  94     umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
  95     ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
  96     [ $? -ne 0 ] && return $FAIL
  97 
  98     echo "\t Test PASS"
  99 }
 100 
 101 
 102 # b: Verify v4 NFS url mount of a file below server's exported FS,
 103 #    expect successful
 104 function assertion_b
 105 {
 106     [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
 107     ASSERTION="Verify v4 NFS url mount of a file below exported FS, \
 108                 expect successful"
 109     echo "$NAME{b}: $ASSERTION"
 110 
 111     if [ $allunsupp -eq 1 ]; then
 112         echo "\t Test UNSUPPORTED"
 113         return $FAIL
 114     fi
 115 
 116     # Do the NFS url mount on the $SRVPATH
 117     mount -o vers=4,proto=$tTCP,public nfs://$SERVER/$ATTRFILE $TMPmnt \
 118         > $TMPDIR/$NAME.mnt.$$ 2>&1
 119     ckreturn $? "mount did not succeed" $TMPDIR/$NAME.mnt.$$
 120     [ $? -ne 0 ] && return $FAIL
 121 
 122     # verify the mount point is access'ble
 123     head $TMPmnt > $TMPDIR/$NAME.ck.$$ 2>&1
 124     ckreturn $? "failed to open attrfile" $TMPDIR/$NAME.ck.$$
 125     [ $? -ne 0 ] && return $FAIL
 126 
 127     # finally umount it
 128     umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
 129     ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
 130     [ $? -ne 0 ] && return $FAIL
 131 
 132     echo "\t Test PASS"
 133 }
 134 
 135 
 136 # c: Verify v4 NFS url mount of .., expect successful
 137 function assertion_c
 138 {
 139     [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
 140     ASSERTION="Verify v4 NFS url mount of .., expect successful"
 141     echo "$NAME{c}: $ASSERTION"
 142 
 143     if [ $allunsupp -eq 1 ]; then
 144         echo "\t Test UNSUPPORTED"
 145         return $FAIL
 146     fi
 147 
 148     # Do the mount on the $SRVPATH
 149     mount -o vers=4,proto=$tTCP,ro nfs://$SERVER/$DIR0777/../$ATTRDIR \
 150         $TMPmnt > $TMPDIR/$NAME.mnt.$$ 2>&1
 151     ckreturn $? "mount did not succeed" $TMPDIR/$NAME.mnt.$$
 152     [ $? -ne 0 ] && return $FAIL
 153 
 154     # verify the mount FS is access'ble
 155     ls -d@ $TMPmnt | grep '\@' > $TMPDIR/$NAME.ck.$$ 2>&1
 156     ckreturn $? "$TMPmnt did not come back w/attr" $TMPDIR/$NAME.ck.$$
 157     [ $? -ne 0 ] && return $FAIL
 158 
 159     # finally umount it
 160     umount $TMPmnt > $TMPDIR/$NAME.umnt.$$ 2>&1
 161     ckreturn $? "umount failed" $TMPDIR/$NAME.umnt.$$
 162     [ $? -ne 0 ] && return $FAIL
 163 
 164     echo "\t Test PASS"
 165 }
 166 
 167 
 168 # Start main program here:
 169 # ----------------------------------------------------------------------
 170 
 171 assertion_a
 172 [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
 173 assertion_b
 174 [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
 175 assertion_c
 176 [ $? -ne 0 ] && umount -f $TMPmnt > /dev/null 2>&1
 177 
 178 # cleanup here
 179 rmdir $TMPmnt
 180 rm -f $TMPDIR/$NAME.*.$$
 181 
 182 exit 0