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 server name space test - positive tests
27 #
28
29 # include all test enironment
30 source SNSPC.env
31
32 set TNAME $argv0
33
34 # Start the assertion proc's here
35 # --------------------------------------------------------------
36 # a: Verify LOOKUPP across mount point, expect OK
37 proc assertion_a {bdir} {
38 global TNAME
39 set expcode "OK"
40 set ASSERTION "Verify LOOKUPP across mount point, expect $expcode"
41 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
42 set tag "$TNAME{a}"
43
44 # First Readdir on the mount point
45 set mfh [get_fh $bdir]
46 set res [compound {Putfh $mfh; Readdir 0 0 1024 8192 {type rdattr_error}}]
47 if {$status != "$expcode"} {
48 putmsg stderr 0 "\t Test UNRESOLVED: 1st Readdir got status=($status)"
49 putmsg stderr 0 "\t expected=($expcode)"
50 putmsg stderr 1 "\t res=($res)"
51 return (-1)
52 }
53 # Save the readdir list
54 set rdres1 [lindex [lindex $res 1] 3]
55
56 # Try Readdir again with LOOKUPP the node
57 set mnode [lrange $bdir [expr [llength $bdir] - 1] end]
58 set res [compound {Putfh $mfh; Lookupp;
59 Lookup $mnode; Readdir 0 0 1024 8192 {type rdattr_error}}]
60 if {$status != "$expcode"} {
61 putmsg stderr 0 "\t Test UNRESOLVED: 2nd Readdir got status=($status)"
62 putmsg stderr 0 "\t expected=($expcode)"
63 putmsg stderr 1 "\t res=($res)"
64 return (-1)
65 }
66 # Save the readdir list
67 set rdres2 [lindex [lindex $res 3] 3]
68
69 # now check the results, both rdres should be the same
70 if {"$rdres1" != "$rdres2"} {
71 putmsg stderr 0 \
72 "\t Test FAIL: 2 Readdir's of same node got different results"
73 putmsg stderr 1 "\t rdres1=($rdres1)"
74 putmsg stderr 1 "\t rdres2=($rdres2)"
75 return (-1)
76 }
77
78 logres PASS
79 return (0)
80 }
81
82
83 # b: Verify walk backward with LOOKUPP, thru mnt/export/pseudo nodes, expect OK
84 proc assertion_b {bdir nodename} {
85 global TNAME
86 set expcode "OK"
87 set ASSERTION "LOOKUPP backward thru mnt/export/pseudo nodes"
88 set ASSERTION "$ASSERTION, expect $expcode"
89 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
90 set tag "$TNAME{b}"
91
92 if {[is_cipso $nodename]} {
93 putmsg stderr 0 \
94 "\t Test UNSUPPORTED: Not supported for Trusted Extensions CIPSO"
95 putmsg stderr 1 "\t nodename=($nodename)"
96 return (-1)
97 }
98
99 # First walk up the path (which has exported/mounted/pseudo) with LOOKUPP
100 set efh [get_fh $bdir]
101 set ncomp [llength $bdir]
102 set res [compound {Putfh $efh;
103 foreach c $bdir {Lookupp; Readdir 0 0 1024 8192 {type rdattr_error}};
104 Getfh}]
105 if {$status != "$expcode"} {
106 putmsg stderr 0 "\t Test FAIL: LOOKUPP got status=($status)"
107 putmsg stderr 0 "\t expected=($expcode)"
108 putmsg stderr 1 "\t res=($res)"
109 return (-1)
110 }
111 set newfh [lindex [lindex $res end] 2]
112 set rootfh [get_fh {}]
113 if {$newfh != "$rootfh"} {
114 putmsg stderr 0 "\t Test FAIL: LOOKUPP to top, filehandle is different"
115 putmsg stderr 1 "\t rootfh=($rootfh)"
116 putmsg stderr 1 "\t newfh=($newfh)"
117 return (-1)
118 }
119
120 logres PASS
121 return (0)
122 }
123
124
125 # c: Verify LOOKUP of FS unshared sees underlying dir, expect OK
126 proc assertion_c {bdir nsnode} {
127 global TNAME
128 global env
129 set expcode "OK"
130 set ASSERTION "LOOKUP of FS unshared sees underlying dir, expect $expcode"
131 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
132 set tag "$TNAME{c}"
133
134 # Lookup the unshared filesystem to see the underlying directory
135 set bfh [get_fh $bdir]
136 set res [compound {Putfh $bfh; Lookup $nsnode; Getattr type; Getfh}]
137 if {$status != "$expcode"} {
138 putmsg stderr 0 "\t Test FAIL: LOOKUP ($nsnode) got status=($status)"
139 putmsg stderr 0 "\t expected=($expcode)"
140 putmsg stderr 1 "\t res=($res)"
141 return (-1)
142 }
143 set dtype [lindex [lindex [lindex [lindex $res 2] 2] 0] 1]
144 if {$dtype != "dir"} {
145 putmsg stderr 0 "\t Test FAIL: GETATTR type of $nsnode is not dir"
146 putmsg stderr 0 "\t got dtype=($dtype)"
147 putmsg stderr 1 "\t res=($res)"
148 return (-1)
149 }
150
151 # For Solaris, client is now allowed to access this directory
152 # regardless its (mode) permission
153 if {$env(SRVOS) == "Solaris"} {
154 set nfh [lindex [lindex $res 3] 2]
155 set res [compound {Putfh $nfh; Readdir 0 0 256 256 {size rdattr_error}}]
156 if {$status != "ACCESS"} {
157 putmsg stderr 0 "\t Test FAIL: READDIR did not fail with ACCESS"
158 putmsg stderr 0 "\t got status=($status)"
159 putmsg stderr 1 "\t res=($res)"
160 return (-1)
161 }
162 set res [compound {Putfh $nfh; Create ${TNAME}_c {{mode 0777}} d}]
163 if {$status != "ACCESS"} {
164 putmsg stderr 0 "\t Test FAIL: Create/dir did not fail with ACCESS"
165 putmsg stderr 0 "\t got status=($status)"
166 putmsg stderr 1 "\t res=($res)"
167 return (-1)
168 }
169 }
170
171 logres PASS
172 return (0)
173 }
174
175
176 # d: Verify SECINFO of FS unshared OK with underlying dir, expect OK
177 proc assertion_d {bdir nsnode} {
178 global TNAME
179 global env
180 set expcode "OK"
181 set ASSERTION "SECINFO of FS unshared OK with underlying dir"
182 set ASSERTION "$ASSERTION, expect $expcode"
183 putmsg stdout 0 "$TNAME{d}: $ASSERTION"
184 set tag "$TNAME{d}"
185
186 # Secinfo the unshared filesystem and the underlying directory
187 set bfh [get_fh $bdir]
188 set res [compound {Putfh $bfh; Secinfo $nsnode; Getfh}]
189 if {$status != "$expcode"} {
190 putmsg stderr 0 "\t Test FAIL: Secinfo got status=($status)"
191 putmsg stderr 0 "\t expected=($expcode)"
192 putmsg stderr 1 "\t res=($res)"
193 return (-1)
194 }
195 set newfh [lindex [lindex $res 2] 2]
196 if {$newfh != "$bfh"} {
197 putmsg stderr 0 "\t Test FAIL: after SECINFO filehandles are different"
198 putmsg stderr 1 "\t newfh=($newfh)"
199 putmsg stderr 1 "\t bfh=($bfh)"
200 return (-1)
201 }
202
203 logres PASS
204 return (0)
205 }
206
207
208 # Start the main program here
209 # --------------------------------------------------------------
210 # connect to the test server
211 if {[catch {connect -p ${PORT} -t ${TRANSPORT} ${SERVER}} msg]} {
212 putmsg stderr 0 "Test UNINITIATED: unable to connect to $SERVER"
213 putmsg stderr 1 $msg
214 exit $UNINITIATED
215 }
216
217 set nspath "[path2comp $env(NOTSHDIR) $DELM]"
218 set nsnode [lrange $nspath [expr [llength $nspath] - 1] end]
219
220 assertion_a "[path2comp $env(SSPCDIR2) $DELM]"
221 assertion_b "[path2comp $env(SSPCDIR3) $DELM]" $env(SERVER)
222 assertion_c "$BASEDIRS" $nsnode
223 assertion_d "$BASEDIRS" $nsnode
224
225
226 # --------------------------------------------------------------
227 # disconnect and exit
228 set tag ""
229 disconnect
230 exit $PASS