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 . ${STF_SUITE}/include/nfsgen.kshlib
29 . ${STF_SUITE}/tests/delegation/include/delegation.kshlib
30
31 NAME=$(basename $0)
32 typeset prog=$STF_SUITE/bin/file_operator
33
34 [[ :$NFSGEN_DEBUG: = *:${NAME}:* \
35 || :${NFSGEN_DEBUG}: = *:all:* ]] && set -x
36
37 function cleanup {
38 retcode=$1
39 rm -f $MNTDIR/testfile.$$ $STF_TMPDIR/file_operator.outW.$$
40 exit $retcode
41 }
42
43 echo "open a file RDWR, get write delegation"
44
45 # create test file
46 RUN_CHECK create_file_nodeleg $MNTDIR/testfile.$$ || cleanup $STF_UNRESOLVED
47
48 # write a test file over NFS, check delegation type
49 $prog -W -c -d -o 4 -B "1 1 -1" $MNTDIR/testfile.$$ \
50 > $STF_TMPDIR/file_operator.outW.$$ 2>&1
51 deleg_type=$(grep "return_delegation_type" $STF_TMPDIR/file_operator.outW.$$ \
52 | nawk -F\= '{print $2'})
53
54 if [[ $deleg_type -ne $WR ]]; then
55 print -u2 "unexpected delegation type($deleg_type) when writing file"
56 cleanup $STF_FAIL
57 fi
58
59 # clean up
60 cleanup $STF_PASS