1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26 # NFSv4 numbered attributes:
27 #
28 # a: Test get attr FATTR4_LINK_SUPPORT of hardlinks of a filesystem,
29 # expect OK
30 # b: Test get attr FATTR4_SYMLINK_SUPPORT of a filesystem, expect OK
31 #
32
33 # Get the TESTROOT directory; set to '.' if not defined
34 set TESTROOT $env(TESTROOT)
35 set delm $env(DELM)
36
37 # include common code and init section
38 source ${TESTROOT}${delm}tcl.init
39 source ${TESTROOT}${delm}testproc
40
41 # connect to the test server
42 Connect
43
44 # setting local variables
45 set TNAME $argv0
46 set bfh [get_fh "$BASEDIRS"]
47 set expcode "OK"
48
49 # Start testing
50 # -----------------------------------------------------------------
51 # a: Test get attr FATTR4_LINK_SUPPORT of hardlinks of a filesystem,
52 # expect OK
53
54 # Generate a compound request that
55 # obtains the attributes for the path.
56
57 set ASSERTION "Test get attr FATTR4_LINK_SUPPORT of hardlinks of a filesystem, expect $expcode"
58 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
59
60 # Get the expected value for link support on server filesystem
61 set errfile [file join $::env(TMPDIR) ck_fattr.err]
62 set expval [ exec ck_fattr $MNTPTR link 2> $errfile]
63 if {[file size $errfile] > 0} {
64 if {[catch {open $errfile r} fileid] != 0} {
65 putmsg stdout 0 "[read $fileid]"
66 close $fileid
67 }
68 }
69 catch {file delete $errfile} dummy
70
71 set attr1 {link_support}
72 set res [compound { Putfh $bfh; Lookup $env(TEXTFILE); Getfh; Getattr $attr1 }]
73 set cont [ckres "Getattr" $status $expcode $res $FAIL]
74 set fh [lindex [lindex $res 2] 2]
75 set attrval [ extract_attr [lindex [lindex $res 3] 2] "link_support" ]
76
77 if { ![string equal $cont "false"] } {
78 if {[string compare $attrval $expval] == 0} {
79 prn_attrs [lindex [lindex $res 3] 2]
80 putmsg stdout 0 "\t Test PASS"
81 } else {
82 putmsg stdout 0 "\t Test FAIL: hardlink_support attr returned, $attrval"
83 }
84 }
85 puts ""
86
87 #--------------------------------------------------------------------
88 # b: Test get attr FATTR4_SYMLINK_SUPPORT of a filesystem, expect OK
89
90 # Generate a compound request that
91 # obtains the attributes for the path.
92
93 set ASSERTION "Test get attr FATTR4_SYMLINK_SUPPORT of a filesystem, expect $expcode"
94 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
95
96 # Get the expected value for link support on server filesystem
97 set errfile [file join $::env(TMPDIR) ck_fattr.err]
98 set expval [ exec ck_fattr $MNTPTR symlink 2> $errfile]
99 if {[file size $errfile] > 0} {
100 if {[catch {open $errfile r} fileid] != 0} {
101 putmsg stdout 0 "[read $fileid]"
102 close $fileid
103 }
104 }
105 catch {file delete $errfile} dummy
106
107 set attr2 {symlink_support}
108 set res2 [compound { Putfh $bfh; Lookup $env(TEXTFILE); Getfh; Getattr $attr2 }]
109 set cont [ckres "Getattr" $status $expcode $res2 $FAIL]
110
111 if { ![string equal $cont "false"] } {
112 set fh [lindex [lindex $res2 2] 2]
113 set attrval [ extract_attr [lindex [lindex $res2 3] 2] "symlink_support" ]
114 if {[string compare $attrval $expval] == 0} {
115 prn_attrs [lindex [lindex $res2 3] 2]
116 putmsg stdout 0 "\t Test PASS"
117 } else {
118 putmsg stdout 0 "\t Test FAIL: symlink_support attr returned $attrval"
119 }
120 }
121
122 Disconnect
123 exit $PASS