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 2007 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26 # NFSv4 OPEN operation test - more of negative tests
27 # Test DQUOT/NOSPC/ROFS, need special FSs setup/support
28
29 # include all test enironment
30 source OPEN.env
31
32 # connect to the test server
33 Connect
34
35 # setting local variables
36 set TNAME $argv0
37 set bfh [get_fh "$BASEDIRS"]
38 set cid [getclientid $TNAME.[pid]]
39 if {$cid == -1} {
40 putmsg stdout 0 "$TNAME: test setup - getclientid"
41 putmsg stderr 0 "\t Test UNRESOLVED: unable to get clientid"
42 exit $UNRESOLVED
43 }
44 set seqid 1
45 set owner "$TNAME-OpenOwner"
46
47
48 # Start testing
49 # --------------------------------------------------------------
50 # a: Open(CREATE) with user has no more quota, expect DQUOT
51 set expcode "DQUOT"
52 set ASSERTION "Open(CREATE) with user has no more quota, expect $expcode"
53 set tag "$TNAME{a}"
54 putmsg stdout 0 "$tag: $ASSERTION"
55 set qpath [path2comp $env(QUOTADIR) $DELM]
56 set res [compound {Putrootfh; foreach c $qpath {Lookup $c};
57 Getfh; Lookup "quotas"}]
58 # add check of quota setup for Solaris:
59 if {($env(SRVOS) == "Solaris") && ($status == "NOENT")} {
60 putmsg stdout 0 "\t Test NOTINUSE: QUOTA is not setup in server."
61 } else {
62 set qfh [lindex [lindex $res end-1] 2]
63 set tf "file_$env(TUSER2).a"
64 if {[is_cipso $env(SERVER)]} {
65 # Under cipso in Trusted Extension, we do "Open" operation
66 # for QUOTA in non-global zone
67 set res [exec zlogin $env(ZONENAME) \
68 "su $env(TUSER2) -c \"qfh=$qfh; seqid=$seqid; \
69 cid=$cid; owner=$owner; tf=$tf; \
70 export qfh seqid cid owner tf; \
71 /nfsh /$TNAME\""]
72 set status [lindex $res 0]
73 } else {
74 set res [compound {Putfh $qfh;
75 Open $seqid 3 0 "$cid $owner-a" \
76 {1 0 {{mode 0644}}} {0 "$tf"}; Getfh}]
77 }
78 ckres "Open" $status $expcode $res $PASS
79 }
80
81
82 # c: Open(CREATE/UNCHECKED) w/FS has no more inode, expect NOSPC
83 set expcode "NOSPC"
84 set ASSERTION "Open(CREATE/UNCHECKED) w/FS has no more inode, expect $expcode"
85 set tag "$TNAME{c}"
86 putmsg stdout 0 "$tag: $ASSERTION"
87 set nspcdir [path2comp $env(NSPCDIR) $DELM]
88 set nsfh [get_fh $nspcdir]
89 if {$nsfh == ""} {
90 putmsg stdout 0 "\t Test NOTINUSE: NOSPC-FS is not setup in server."
91 } else {
92 set res [compound {Putrootfh; foreach c $nspcdir {Lookup $c};
93 Open $seqid 3 0 "$cid $owner-c" \
94 {1 0 {{mode 0644}}} {0 "$TNAME-c"}; Getfh}]
95 ckres "Open" $status $expcode $res $PASS
96 }
97
98
99 # d: Open(CREATE/GUARDED) w/FS has no more disk, expect NOSPC
100 set expcode "NOSPC"
101 set ASSERTION "Open(CREATE/GUARDED) w/FS has no more disk, expect $expcode"
102 set tag "$TNAME{d}"
103 putmsg stdout 0 "$tag: $ASSERTION"
104 set nsfh [get_fh $nspcdir]
105 if {$nsfh == ""} {
106 putmsg stdout 0 "\t Test NOTINUSE: NOSPC-FS is not setup in server."
107 } else {
108 set res [compound {Putrootfh; foreach c $nspcdir {Lookup $c};
109 Open $seqid 3 0 "$cid $owner-d" \
110 {1 1 {{mode 0666} {size 0}}} {0 "$TNAME-d"}; Getfh}]
111 ckres "Open" $status $expcode $res $PASS
112 }
113
114
115 # e: Open(CREATE/GUARDED) w/FS is Read-Only, expect ROFS
116 set expcode "ROFS"
117 set ASSERTION "Open(CREATE/GUARDED) w/FS is Read-Only, expect $expcode"
118 set tag "$TNAME{e}"
119 putmsg stdout 0 "$tag: $ASSERTION"
120 set rofsdir [path2comp $env(ROFSDIR) $DELM]
121 set nsfh [get_fh $rofsdir]
122 if {$nsfh == ""} {
123 putmsg stdout 0 "\t Test NOTINUSE: ROFS is not setup in server."
124 } else {
125 set res [compound {Putrootfh; foreach c $rofsdir {Lookup $c};
126 Open $seqid 3 0 "$cid $owner-e" \
127 {1 1 {{mode 0666} {size 10}}} {0 "$TNAME-e"}; Getfh}]
128 ckres "Open" $status $expcode $res $PASS
129 }
130
131 # g: Open(non-CREATE/access=W) in the Read-Only filesystem, expect ROFS
132 set expcode "ROFS"
133 set ASSERTION "Open(non-CREATE/acces=W) w/FS is Read-Only, expect $expcode"
134 set tag "$TNAME{g}"
135 putmsg stdout 0 "$tag: $ASSERTION"
136 set nsfh [get_fh $rofsdir]
137 if {$nsfh == ""} {
138 putmsg stdout 0 "\t Test NOTINUSE: ROFS is not setup in server."
139 } else {
140 set res [compound {Putrootfh; foreach c $rofsdir {Lookup $c};
141 Open $seqid 2 0 "$cid $owner-g" \
142 {0 0 {{mode 0666}}} {0 "$env(RWFILE)"}; Getfh}]
143 ckres "Open" $status $expcode $res $PASS
144 }
145
146 # h: Open(non-CREATE/access=RW) in the Read-Only filesystem, expect ROFS
147 set expcode "ROFS"
148 set ASSERTION "Open(non-CREATE/acces=RW) w/FS is Read-Only, expect $expcode"
149 set tag "$TNAME{h}"
150 putmsg stdout 0 "$tag: $ASSERTION"
151 set nsfh [get_fh $rofsdir]
152 if {$nsfh == ""} {
153 putmsg stdout 0 "\t Test NOTINUSE: ROFS is not setup in server."
154 } else {
155 set res [compound {Putrootfh; foreach c $rofsdir {Lookup $c};
156 Open $seqid 3 0 "$cid $owner-h" \
157 {0 0 {{mode 0666}}} {0 "$env(ROFILE)"}; Getfh}]
158 ckres "Open" $status $expcode $res $PASS
159 }
160
161 # --------------------------------------------------------------
162 # disconnect and exit
163 Disconnect
164 exit $PASS