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 # a: Test for umount of fs on NFS client after named attr
29 # creation/access/remove of file object, expect OK
30 #
31
32 funcs="./attrcmds_funcs"
33 [ ! -r $funcs ] && echo "$0 ERROR: cannot source $funcs" && exit $UNINITIATED
34 . $funcs
35
36 setup
37
38 # Assume that xattr mount option is set by default on UFS filesystems
39 # Use pre-mounted filesystem previously setup by nfs4_gen framework
40
41 # Start test
42 # --------------------------------------------------------------------
43 # a: Test for umount of fs on NFS client after named attr \
44 # creation/access/remove of file object, expect OK
45 ASSERTION="Test for umount of fs on NFS client after named attr \
46 creation/access/remove of file object, expect OK"
47 ASSERTION="$ASSERTION, expect successful"
48 echo "$NAME{a}: $ASSERTION"
49
50 mkdir -m 0777 -p $TMPmnt 2> $TMPDIR/$NAME.out.$$
51 ret=$?
52 ckreturn $ret "cannot create mount point $TMPmnt, returned $ret" \
53 $TMPDIR/$NAME.out.$$ UNINITIATED
54 [ $? -ne 0 ] && cleanup $UNINITIATED
55
56 sleep 1
57 # Do the V4 mount on the new mount pointer for testing purposes
58 mount -o vers=4,rw $SERVER:$BASEDIR $TMPmnt > $TMPDIR/$NAME.out.$$ 2>&1
59 ret=$?
60 ckreturn $ret "mount did not succeed, returned $ret" $TMPDIR/$NAME.out.$$
61 [ $? -ne 0 ] && cleanup $FAIL
62
63 sleep 1
64 #Ensure that test file doesn't already exist
65 rm -f $TMPmnt/$TESTFILE
66
67 #Check mount TMPmnt point works
68 ls $TMPmnt > /dev/null 2> $TMPDIR/$NAME.out.$$
69 ret=$?
70 ckreturn $ret "mount point $TMPmnt not accessible (ret=$ret)" \
71 $TMPDIR/$NAME.out.$$ UNINITIATED
72 [ $? -ne 0 ] && cleanup $UNINITIATED
73
74 sleep 1
75 # Create a test directory
76 echo "This is a file" > $TMPmnt/$TESTFILE 2> $TMPDIR/$NAME.out.$$
77 ret=$?
78 ckreturn $ret "Cannot create [$TESTFILE], returned $ret." $TMPDIR/$NAME.out.$$ \
79 UNINITIATED
80 [ $? -ne 0 ] && cleanup $UNINITIATED
81
82 sleep 1
83 # Verify test file was created with extended attribute dir
84 $LSAT $TMPmnt/$TESTFILE > $TMPDIR/$NAME.out.$$ 2>&1
85 ret=$?
86 ckreturn $ret "$LSAT cannot access $TESTFILE, returned $ret." \
87 $TMPDIR/$NAME.out.$$
88 [ $? -ne 0 ] && cleanup $FAIL
89
90 # Now Create named attribute for file object
91 echo "This is an attribute" | runat $TMPmnt/$TESTFILE \
92 "cat > attr" > $TMPDIR/$NAME.out.$$ 2>&1
93 ret=$?
94 ckreturn $ret "Cannot create attr dir, returned $ret." $TMPDIR/$NAME.out.$$
95 [ $? -ne 0 ] && cleanup $FAIL
96
97 # Verify test file still accessible
98 RESULT=$($LSAT $TMPmnt/$TESTFILE | awk '{print $1}' | cut -c11 \
99 2> $TMPDIR/$NAME.out.$$)
100 ret=0 && [ "$RESULT" != "@" ] && ret=1
101 ckreturn $ret "'$LSAT $TMPmnt/$TESTFILE' failed (res=$RESULT)" \
102 $TMPDIR/$NAME.out.$$
103 [ $? -ne 0 ] && cleanup $FAIL
104
105 sleep 1
106 # Verify attr dir accessible by runat command
107 runat $TMPmnt/$TESTFILE ls -l > $TMPDIR/$NAME.out.$$ 2>&1
108 ret=$?
109 ckreturn $ret "cannot access $TESTFILE attr using runat, returned $ret." \
110 $TMPDIR/$NAME.out.$$
111 [ $? -ne 0 ] && cleanup $FAIL
112
113 sleep 1
114 # Verify can view an attribute created in file's attribute directory
115 runat $TMPmnt/$TESTFILE cat attr > $TMPDIR/$NAME.out.$$ 2>&1
116 ret=$?
117 ckreturn $ret "Cannot view [$TESTFILE attr], returned $ret." $TMPDIR/$NAME.out.$$
118 [ $? -ne 0 ] && cleanup $FAIL
119
120 echo "\tTest PASS"
121
122 # cleanup here
123 cleanup $PASS
124
125 exit $PASS