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 hardlinks must not reference objects outside of
29 # the attrdir. expect FAIL
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 hardlinks must not reference objects outside of the attrdir, \
44 # expect FAIL
45 ASSERTION="Test hardlinks must not reference objects outside of the attrdir"
46 ASSERTION="$ASSERTION, expect FAIL"
47 echo "$NAME{a}: $ASSERTION"
48
49 #Check mount point works
50 ls $MNTPTR > /dev/null 2> $TMPDIR/$NAME.out.$$
51 ret=$?
52 ckreturn $ret "mount point $MNTPTR not accessible (ret=$ret)" \
53 $TMPDIR/$NAME.out.$$ UNINITIATED
54 [ $? -ne 0 ] && cleanup $UNINITIATED
55
56 #Ensure that test file doesn't already exist
57 rm -f $MNTPTR/$TESTFILE $MNTPTR/$TESTFILE2 > /dev/null 2>&1
58
59 sleep 1
60 # Create a test file
61 echo "This is a testfile" > $MNTPTR/$TESTFILE 2> $TMPDIR/$NAME.out.$$
62 ret=$?
63 ckreturn $ret "Cannot create test file $TESTFILE (ret=$ret)" $TMPDIR/$NAME.out.$$ \
64 UNINITIATED
65 [ $? -ne 0 ] && cleanup $UNINITIATED
66
67 sleep 1
68 # Create a test file
69 echo "This is a textfile" > $MNTPTR/$TESTFILE2 2> $TMPDIR/$NAME.out.$$
70 ret=$?
71 ckreturn $ret "Cannot create test file $TESTFILE2 (ret=$ret)" $TMPDIR/$NAME.out.$$\
72 UNINITIATED
73 [ $? -ne 0 ] && cleanup $UNINITIATED
74
75 sleep 1
76 # Verify test file created is accessible
77 $LSAT $MNTPTR/$TESTFILE > $TMPDIR/$NAME.out.$$ 2>&1
78 ret=$?
79 ckreturn $ret "Cannot create [$TESTFILE], returned $ret." $TMPDIR/$NAME.out.$$
80 [ $? -ne 0 ] && cleanup $FAIL
81
82 sleep 1
83 # Now Create named attribute for file object
84 echo "This is an attribute" | runat $MNTPTR/$TESTFILE "cat > attr" \
85 > $TMPDIR/$NAME.out.$$ 2>&1
86 ret=$?
87 ckreturn $ret "Cannot create attr dir, returned $ret ." $TMPDIR/$NAME.out.$$
88 [ $? -ne 0 ] && cleanup $FAIL
89
90 sleep 1
91 # Try to create a hardlink referencing test file outside of attrdir
92 runat $MNTPTR/$TESTFILE ln $MNTPTR/$TESTFILE2 $HLNK1 > \
93 $TMPDIR/$NAME.out.$$ 2>&1
94 ret=$?
95 ckreturn -r $ret "Link unexpectedly created on object outside of attrdir,\
96 returned $ret." $TMPDIR/$NAME.out.$$
97 [ $? -eq 0 ] && cleanup $FAIL
98
99 sleep 1
100 # Verify hardlink not accessible
101 runat $MNTPTR/$TESTFILE ls $HLNK1 > $TMPDIR/$NAME.out.$$ 2>&1
102 ret=$?
103 ckreturn -r $ret "Link unexpectedly created on object outside of attrdir,\
104 returned $ret." $TMPDIR/$NAME.out.$$
105 [ $? -eq 0 ] && cleanup $FAIL
106
107 echo "\tTest PASS"
108
109 # cleanup test files
110 cleanup $PASS
111
112 exit $PASS