Print this page
NEX-6096 Enable compile warnings re. parentheses in smbsrv
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Jean McCormack <jean.mccormack@nexenta.com>
NEX-2442 regression with smbtorture test raw.sfileinfo.rename
SMB-11 SMB2 message parse & dispatch
SMB-12 SMB2 Negotiate Protocol
SMB-13 SMB2 Session Setup
SMB-14 SMB2 Logoff
SMB-15 SMB2 Tree Connect
SMB-16 SMB2 Tree Disconnect
SMB-17 SMB2 Create
SMB-18 SMB2 Close
SMB-19 SMB2 Flush
SMB-20 SMB2 Read
SMB-21 SMB2 Write
SMB-22 SMB2 Lock/Unlock
SMB-23 SMB2 Ioctl
SMB-24 SMB2 Cancel
SMB-25 SMB2 Echo
SMB-26 SMB2 Query Dir
SMB-27 SMB2 Change Notify
SMB-28 SMB2 Query Info
SMB-29 SMB2 Set Info
SMB-30 SMB2 Oplocks
SMB-53 SMB2 Create Context options
(SMB2 code review cleanup 1, 2, 3)
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/lib/smbsrv/libfksmbsrv/common/fake_xattr.c
+++ new/usr/src/lib/smbsrv/libfksmbsrv/common/fake_xattr.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25
26 26 #include <sys/types.h>
27 27 #include <sys/vnode.h>
28 28 #include <sys/debug.h>
29 29
30 30 #include <attr.h>
31 31 #include <libnvpair.h>
32 32
33 33 static uint64_t zero_times[2];
34 34
35 35 static int
36 36 getxva_parse_nvl(xvattr_t *xvap,
37 37 xoptattr_t *xoap, nvlist_t *nvl);
38 38
39 39 /*
40 40 * See similar code to parse the nvlist in:
41 41 * uts/common/fs/xattr.c : xattr_file_write()
42 42 */
43 43 int
44 44 fop__getxvattr(vnode_t *vp, xvattr_t *xvap)
45 45 {
46 46 nvlist_t *nvl = NULL;
47 47 xoptattr_t *xoap = NULL;
48 48 int error;
49 49
50 50 if ((xoap = xva_getxoptattr(xvap)) == NULL) {
51 51 return (EINVAL);
52 52 }
53 53
54 54 error = fgetattr(vp->v_fd, XATTR_VIEW_READWRITE, &nvl);
55 55 if (error == 0) {
56 56 error = getxva_parse_nvl(xvap, xoap, nvl);
57 57 nvlist_free(nvl);
58 58 nvl = NULL;
59 59 }
60 60
61 61 /*
62 62 * Also get the readonly attrs, but don't fail.
63 63 */
64 64 if (fgetattr(vp->v_fd, XATTR_VIEW_READONLY, &nvl) == 0) {
65 65 (void) getxva_parse_nvl(xvap, xoap, nvl);
66 66 nvlist_free(nvl);
67 67 }
68 68
|
↓ open down ↓ |
68 lines elided |
↑ open up ↑ |
69 69 return (error);
70 70 }
71 71
72 72 static int
73 73 getxva_parse_nvl(xvattr_t *xvap,
74 74 xoptattr_t *xoap, nvlist_t *nvl)
75 75 {
76 76 nvpair_t *pair = NULL;
77 77 int error;
78 78
79 - while (pair = nvlist_next_nvpair(nvl, pair)) {
79 + while ((pair = nvlist_next_nvpair(nvl, pair)) != NULL) {
80 80 data_type_t type;
81 81 f_attr_t attr;
82 82 boolean_t value = B_FALSE;
83 83 uint64_t *times = zero_times;
84 84 uint_t nelems = 2;
85 85
86 86 /*
87 87 * Validate the name and type of each attribute.
88 88 * Log any unknown names and continue. This will
89 89 * help if additional attributes are added later.
90 90 */
91 91 type = nvpair_type(pair);
92 92 attr = name_to_attr(nvpair_name(pair));
93 93 if (attr == F_ATTR_INVAL)
94 94 continue;
95 95
96 96 /*
97 97 * Verify nvlist type matches required type and view is OK
98 98 */
99 99
100 100 if (type != attr_to_data_type(attr) ||
101 101 (attr_to_xattr_view(attr) == XATTR_VIEW_READONLY))
102 102 continue;
103 103
104 104 /*
105 105 * For OWNERSID/GROUPSID, just skip.
106 106 */
107 107 if ((attr == F_OWNERSID || attr == F_GROUPSID))
108 108 continue;
109 109
110 110 /*
111 111 * Retrieve data from nvpair
112 112 */
113 113 switch (type) {
114 114 case DATA_TYPE_BOOLEAN_VALUE:
115 115 if (nvpair_value_boolean_value(pair, &value)) {
116 116 error = EINVAL;
117 117 goto out;
118 118 }
119 119 break;
120 120
121 121 case DATA_TYPE_UINT64_ARRAY:
122 122 if (nvpair_value_uint64_array(pair, ×, &nelems)) {
123 123 error = EINVAL;
124 124 goto out;
125 125 }
126 126 if (nelems < 2)
127 127 continue;
128 128 break;
129 129
130 130 case DATA_TYPE_NVLIST:
131 131 continue;
132 132
133 133 case DATA_TYPE_UINT8_ARRAY:
134 134 continue;
135 135
136 136 default:
137 137 error = EINVAL;
138 138 goto out;
139 139 }
140 140
141 141 switch (attr) {
142 142 /*
143 143 * If we have several similar optional attributes to
144 144 * process then we should do it all together here so that
145 145 * xoap and the requested bitmap can be set in one place.
146 146 */
147 147 case F_READONLY:
148 148 XVA_SET_RTN(xvap, XAT_READONLY);
149 149 xoap->xoa_readonly = value;
150 150 break;
151 151
152 152 case F_HIDDEN:
153 153 XVA_SET_RTN(xvap, XAT_HIDDEN);
154 154 xoap->xoa_hidden = value;
155 155 break;
156 156
157 157 case F_SYSTEM:
158 158 XVA_SET_RTN(xvap, XAT_SYSTEM);
159 159 xoap->xoa_system = value;
160 160 break;
161 161
162 162 case F_ARCHIVE:
163 163 XVA_SET_RTN(xvap, XAT_ARCHIVE);
164 164 xoap->xoa_archive = value;
165 165 break;
166 166
167 167 case F_CRTIME:
168 168 XVA_SET_RTN(xvap, XAT_CREATETIME);
169 169 xoap->xoa_createtime.tv_sec = times[0];
170 170 xoap->xoa_createtime.tv_nsec = times[1];
171 171 break;
172 172
173 173 case F_REPARSE:
174 174 XVA_SET_RTN(xvap, XAT_REPARSE);
175 175 xoap->xoa_reparse = value;
176 176 break;
177 177
178 178 case F_OFFLINE:
179 179 XVA_SET_RTN(xvap, XAT_OFFLINE);
180 180 xoap->xoa_offline = value;
181 181 break;
182 182
183 183 case F_SPARSE:
184 184 XVA_SET_RTN(xvap, XAT_SPARSE);
185 185 xoap->xoa_sparse = value;
186 186 break;
187 187
188 188 default:
189 189 break;
190 190 }
191 191 }
192 192 error = 0;
193 193
194 194 out:
195 195 return (error);
196 196 }
197 197
198 198 /*
199 199 * See similar code to build the nvlist in:
200 200 * uts/common/fs/xattr.c : xattr_fill_nvlist()
201 201 */
202 202 int
203 203 fop__setxvattr(vnode_t *vp, xvattr_t *xvap)
204 204 {
205 205 uint64_t times[2];
206 206 nvlist_t *nvl;
207 207 int error;
208 208 xoptattr_t *xoap; /* Pointer to optional attributes */
209 209
210 210 if ((xoap = xva_getxoptattr(xvap)) == NULL)
211 211 return (EINVAL);
212 212
213 213 if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_SLEEP))
214 214 return (ENOMEM);
215 215
216 216 if (XVA_ISSET_REQ(xvap, XAT_READONLY)) {
217 217 VERIFY(nvlist_add_boolean_value(nvl,
218 218 attr_to_name(F_READONLY),
219 219 xoap->xoa_readonly) == 0);
220 220 }
221 221
222 222 if (XVA_ISSET_REQ(xvap, XAT_HIDDEN)) {
223 223 VERIFY(nvlist_add_boolean_value(nvl,
224 224 attr_to_name(F_HIDDEN),
225 225 xoap->xoa_hidden) == 0);
226 226 }
227 227
228 228 if (XVA_ISSET_REQ(xvap, XAT_SYSTEM)) {
229 229 VERIFY(nvlist_add_boolean_value(nvl,
230 230 attr_to_name(F_SYSTEM),
231 231 xoap->xoa_system) == 0);
232 232 }
233 233
234 234 if (XVA_ISSET_REQ(xvap, XAT_ARCHIVE)) {
235 235 VERIFY(nvlist_add_boolean_value(nvl,
236 236 attr_to_name(F_ARCHIVE),
237 237 xoap->xoa_archive) == 0);
238 238 }
239 239
240 240 if (XVA_ISSET_REQ(xvap, XAT_CREATETIME)) {
241 241 times[0] = xoap->xoa_createtime.tv_sec;
242 242 times[1] = xoap->xoa_createtime.tv_nsec;
243 243 VERIFY(nvlist_add_uint64_array(nvl,
244 244 attr_to_name(F_CRTIME),
245 245 times, 2) == 0);
246 246 }
247 247
248 248 if (XVA_ISSET_REQ(xvap, XAT_REPARSE)) {
249 249 VERIFY(nvlist_add_boolean_value(nvl,
250 250 attr_to_name(F_REPARSE),
251 251 xoap->xoa_reparse) == 0);
252 252 }
253 253
254 254 if (XVA_ISSET_REQ(xvap, XAT_OFFLINE)) {
255 255 VERIFY(nvlist_add_boolean_value(nvl,
256 256 attr_to_name(F_OFFLINE),
257 257 xoap->xoa_offline) == 0);
258 258 }
259 259
260 260 if (XVA_ISSET_REQ(xvap, XAT_SPARSE)) {
261 261 VERIFY(nvlist_add_boolean_value(nvl,
262 262 attr_to_name(F_SPARSE),
263 263 xoap->xoa_sparse) == 0);
264 264 }
265 265
266 266 error = fsetattr(vp->v_fd, XATTR_VIEW_READWRITE, nvl);
267 267
268 268 nvlist_free(nvl);
269 269
270 270 return (error);
271 271 }
|
↓ open down ↓ |
182 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX