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 
  28 #
  29 # Copyright 2016 Nexenta Systems, Inc. All rights reserved.
  30 #
  31 
  32 DIR=$(dirname $0)
  33 NAME=$(basename $0)
  34 
  35 . ${STF_SUITE}/include/nfsgen.kshlib
  36 
  37 # Turn on debug info, if requested
  38 export _NFS_STF_DEBUG=$_NFS_STF_DEBUG:$NFSGEN_DEBUG
  39 [[ :$NFSGEN_DEBUG: = *:${NAME}:* || :${NFSGEN_DEBUG}: = *:all:* ]] \
  40        && set -x
  41 
  42 # NFS version being tested
  43 export TESTVERS=4
  44 
  45 # Create temp dir on server
  46 RUN_CHECK RSH root $SERVER "mkdir -p $SRV_TMPDIR/$SETUP" \
  47     || exit $STF_UNINITIATED
  48 
  49 # Copy files
  50 cat > $STF_TMPDIR/srv_env.vars << EOF
  51 export SHRDIR="$SHRDIR"
  52 export SHROPT="$SHROPT"
  53 export SHRGRP="$SHRGRP"
  54 export _NFS_STF_DEBUG="$_NFS_STF_DEBUG"
  55 export PATH=$PATH:/opt/SUNWstc-genutils/bin
  56 EOF
  57 RUN_CHECK scp $DIR/srv_setup                    \
  58     $STF_TMPDIR/srv_env.vars                    \
  59     $STF_TOOLS/contrib/include/libsmf.shlib     \
  60     $STF_TOOLS/contrib/include/nfs-smf.kshlib   \
  61     $STF_SUITE/include/nfs-util.kshlib  \
  62     root@$SERVER:$SRV_TMPDIR/$SETUP || exit $STF_UNINITIATED
  63 
  64 # Call server script to share SHRDIR
  65 RUN_CHECK RSH root $SERVER "$SRV_TMPDIR/$SETUP/srv_setup -s" \
  66         > $STF_TMPDIR/setup.$$ || exit $STF_UNINITIATED
  67 
  68 grep "^OKAY " $STF_TMPDIR/setup.$$  > /dev/null 2>&1
  69 if (( $? != 0 )); then
  70         echo "ERROR: Check shared filesystem failed"
  71         cat $STF_TMPDIR/setup.$$
  72         rm -rf $STF_TMPDIR/setup.$$
  73         exit $UNTESTED
  74 fi
  75 
  76 strfs=$(grep OKAY $STF_TMPDIR/setup.$$)
  77 rm $STF_TMPDIR/setup.$$
  78 FS_TYPE=$(echo $strfs | awk '{print $2}')
  79 if [[ $FS_TYPE == "ufs" ]]; then
  80         TestZFS=0
  81 elif [[ $FS_TYPE == "zfs" ]]; then
  82         TestZFS=1
  83 else
  84         TestZFS=2
  85 fi
  86 if [[ $TestZFS == 2 ]]; then # fs is neither zfs nor ufs
  87         echo "$NAME: SHRDIR<$SHRDIR> on server<$SERVER> is based $FS_TYPE,"
  88         echo "\t this test suite only supports UFS and ZFS!"
  89         exit $UNSUPPORTED
  90 fi
  91 if [[ $TestZFS == 1 ]]; then # fs is zfs
  92         ZFSPOOL=$(echo $strfs | awk '{print $3}')
  93         zpool_stat=$(echo $strfs | awk '{print $4}')
  94         if [[ $zpool_stat != "ONLINE" ]]; then
  95                 echo "$NAME: SHRDIR<$SHRDIR> on server<$SERVER> is based ZFS,"
  96                 echo "\t but zpool<$ZFSPOOL> is not online: $zpool_stat"
  97                 exit $UNTESTED
  98         fi
  99 fi
 100 
 101 # Save the variables in config file
 102 cat >> $1 <<-EOF
 103 export FS_TYPE=$FS_TYPE
 104 export TestZFS=$TestZFS
 105 export ZFSPOOL=$ZFSPOOL
 106 export TESTVERS=$TESTVERS
 107 EOF
 108 
 109 # Mount it
 110 RUN_CHECK mkdir -p $MNTDIR || exit $STF_UNINITIATED
 111 RUN_CHECK mount -o $MNTOPT $SERVER:$SHRDIR $MNTDIR || exit $STF_UNINITIATED
 112 
 113 exit $STF_PASS