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 2006 Sun Microsystems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 # NFSv4 named attributes: 
  28 #
  29 # a: Verify runat will fail when the underlying server doesn't
  30 #        support named attributes, expect FAIL
  31 #
  32 
  33 funcs="./attrcmds_funcs"
  34 [ ! -r $funcs ] && echo "$0 ERROR: cannot source $funcs" && exit $UNINITIATED
  35 . $funcs
  36 
  37 setup
  38 
  39 # Use pre-mounted filesystem previously setup by nfs4_gen framework
  40 
  41 # Start test
  42 # ---------------------------------------------------------------------
  43 # a: Verify runat will fail when the underlying server doesn't
  44 #        support named attributes, expect FAIL
  45 ASSERTION="Verify runat will fail when the underlying server doesn't \
  46 support named attributes"
  47 ASSERTION="$ASSERTION, expect FAIL"
  48 echo "$NAME{a}: $ASSERTION"
  49 
  50 mkdir -m 0777 -p $TMPmnt 2>&1 > $TMPDIR/mount.out.$$
  51 ret=$?
  52 ckreturn $ret "cannot create dir $TMPmnt" $TMPDIR/mount.out.$$ UNINITIATED
  53 [ $? -ne 0 ] && cleanup $UNINITIATED
  54 
  55 sleep 1
  56 # mount WITHOUT using -o noxattr option
  57 # onto TMPFS filesystem mounted WITH noxattr option
  58 mount -F nfs -o vers=4 $SERVER:$SSPCDIR3 $TMPmnt > $TMPDIR/mount.out.$$ 2>&1
  59 ret=$?
  60 ckreturn $ret "mount -F nfs -o vers=4 failed, returned $ret." \
  61         $TMPDIR/mount.out.$$ UNINITIATED
  62 [ $? -ne 0 ] && cleanup $UNINITIATED
  63 
  64 #Check mount TMPmnt point works
  65 ls $TMPmnt > /dev/null 2> $TMPDIR/$NAME.out.$$
  66 ret=$?
  67 ckreturn $ret "mount point $TMPmnt not accessible (ret=$ret)" \
  68         $TMPDIR/$NAME.out.$$ UNINITIATED
  69 [ $? -ne 0 ] && cleanup $UNINITIATED
  70 
  71 sleep 3 
  72 #Ensure that test file doesn't already exist
  73 rm -f $TMPmnt/$TESTFILE 2>&1 > /dev/null
  74 
  75 sleep 1
  76 # Create a test directory 
  77 echo "This is a file" > $TMPmnt/$TESTFILE 2> $TMPDIR/$NAME.out.$$
  78 ret=$?
  79 ckreturn $ret "Cannot create [$TESTFILE], returned $ret." \
  80         $TMPDIR/$NAME.out.$$ UNINITIATED
  81 [ $? -ne 0 ] && cleanup $UNINITIATED
  82 
  83 # Now try to Create named attribute on exported noxattr mounted filesystem 
  84 echo "This is an attribute" | runat $TMPmnt/$TESTFILE "cat > attr" \
  85         > $TMPDIR/$NAME.out.$$ 2>&1
  86 ret=$?
  87 ckreturn -r $ret "named attr creation not disabled, returned $ret." \
  88         $TMPDIR/$NAME.out.$$
  89 # May want to check snoop traffic here
  90 [ $? -eq 0 ] && cleanup $FAIL
  91 
  92 # Verify named attribute was not created
  93 runat $TMPmnt/$TESTFILE ls attr > $TMPDIR/$NAME.out.$$ 2>&1
  94 ret=$?
  95 ckreturn -r $ret "named attr was unexpectedly created, returned $ret." \
  96         $TMPDIR/$NAME.out.$$
  97 [ $? -eq 0 ] && cleanup $FAIL
  98 
  99 echo "\tTest PASS"
 100 cleanup $PASS
 101 
 102 exit $PASS