Print this page
Build provider 3rd arg from smb_request_t
hacking...
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/fs/smbsrv/smb_open_andx.c
+++ new/usr/src/uts/common/fs/smbsrv/smb_open_andx.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 2016 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25
26 26 #include <smbsrv/smb_kproto.h>
27 27 #include <smbsrv/smb_fsops.h>
28 28 #include <smbsrv/smb_vops.h>
29 29
30 30 int smb_open_dsize_check = 0;
31 31
32 32 /*
33 33 * Client Request Description
34 34 * ================================== =================================
35 35 *
36 36 * UCHAR WordCount; Count of parameter words = 15
37 37 * UCHAR AndXCommand; Secondary (X) command; 0xFF =
38 38 * none
39 39 * UCHAR AndXReserved; Reserved (must be 0)
40 40 * USHORT AndXOffset; Offset to next command WordCount
41 41 * USHORT Flags; Additional information: bit set-
42 42 * 0 - return additional info
43 43 * 1 - exclusive oplock requested
44 44 * 2 - batch oplock requested
45 45 * USHORT DesiredAccess; File open mode
46 46 * USHORT SearchAttributes;
47 47 * USHORT FileAttributes;
48 48 * UTIME CreationTime; Creation timestamp for file if it
49 49 * gets created
50 50 * USHORT OpenFunction; Action to take if file exists
51 51 * ULONG AllocationSize; Bytes to reserve on create or
52 52 * truncate
53 53 * ULONG Reserved[2]; Must be 0
54 54 * USHORT ByteCount; Count of data bytes; min = 1
55 55 * UCHAR BufferFormat 0x04
56 56 * STRING FileName;
57 57 *
58 58 * Server Response Description
59 59 * ================================== =================================
60 60 *
61 61 * UCHAR WordCount; Count of parameter words = 15
62 62 * UCHAR AndXCommand; Secondary (X) command; 0xFF =
63 63 * none
64 64 * UCHAR AndXReserved; Reserved (must be 0)
65 65 * USHORT AndXOffset; Offset to next command WordCount
66 66 * USHORT Fid; File handle
67 67 * USHORT FileAttributes;
68 68 * UTIME LastWriteTime;
69 69 * ULONG DataSize; Current file size
70 70 * USHORT GrantedAccess; Access permissions actually
71 71 * allowed
72 72 * USHORT FileType; Type of file opened
73 73 * USHORT DeviceState; State of the named pipe
74 74 * USHORT Action; Action taken
75 75 * ULONG ServerFid; Server unique file id
76 76 * USHORT Reserved; Reserved (must be 0)
77 77 * USHORT ByteCount; Count of data bytes = 0
78 78 *
79 79 * DesiredAccess describes the access the client desires for the file (see
80 80 * section 3.6 - Access Mode Encoding).
81 81 *
82 82 * OpenFunction specifies the action to be taken depending on whether or
83 83 * not the file exists (see section 3.8 - Open Function Encoding). Action
84 84 *
85 85 * in the response specifies the action as a result of the Open request
86 86 * (see section 3.9 - Open Action Encoding).
87 87 *
88 88 * SearchAttributes indicates the attributes that the file must have to be
89 89 * found while searching to see if it exists. The encoding of this field
90 90 * is described in the "File Attribute Encoding" section elsewhere in this
91 91 * document. If SearchAttributes is zero then only normal files are
92 92 * returned. If the system file, hidden or directory attributes are
93 93 * specified then the search is inclusive -- both the specified type(s) of
94 94 * files and normal files are returned.
95 95 *
96 96 * FileType returns the kind of resource actually opened:
97 97 *
98 98 * Name Value Description
99 99 * ========================== ====== ==================================
100 100 *
101 101 * FileTypeDisk 0 Disk file or directory as defined
102 102 * in the attribute field
103 103 * FileTypeByteModePipe 1 Named pipe in byte mode
104 104 * FileTypeMessageModePipe 2 Named pipe in message mode
105 105 * FileTypePrinter 3 Spooled printer
106 106 * FileTypeUnknown 0xFFFF Unrecognized resource type
107 107 *
108 108 * If bit0 of Flags is clear, the FileAttributes, LastWriteTime, DataSize,
109 109 * FileType, and DeviceState have indeterminate values in the response.
110 110 *
111 111 * This SMB can request an oplock on the opened file. Oplocks are fully
112 112 * described in the "Oplocks" section elsewhere in this document, and there
113 113 * is also discussion of oplocks in the SMB_COM_LOCKING_ANDX SMB
114 114 * description. Bit1 and bit2 of the Flags field are used to request
115 115 * oplocks during open.
116 116 *
117 117 * The following SMBs may follow SMB_COM_OPEN_ANDX:
118 118 *
119 119 * SMB_COM_READ SMB_COM_READ_ANDX
120 120 * SMB_COM_IOCTL
121 121 */
122 122
123 123 /*
124 124 * This message is sent to obtain a file handle for a data file. This
125 125 * returned Fid is used in subsequent client requests such as read, write,
126 126 * close, etc.
127 127 *
128 128 * Client Request Description
129 129 * ================================== =================================
130 130 *
131 131 * UCHAR WordCount; Count of parameter words = 2
132 132 * USHORT DesiredAccess; Mode - read/write/share
133 133 * USHORT SearchAttributes;
134 134 * USHORT ByteCount; Count of data bytes; min = 2
135 135 * UCHAR BufferFormat; 0x04
136 136 * STRING FileName[]; File name
137 137 *
138 138 * FileName is the fully qualified file name, relative to the root of the
139 139 * share specified in the Tid field of the SMB header. If Tid in the SMB
140 140 * header refers to a print share, this SMB creates a new file which will
141 141 * be spooled to the printer when closed. In this case, FileName is
142 142 * ignored.
143 143 *
144 144 * SearchAttributes specifies the type of file desired. The encoding is
145 145 * described in the "File Attribute Encoding" section.
146 146 *
147 147 * DesiredAccess controls the mode under which the file is opened, and the
148 148 * file will be opened only if the client has the appropriate permissions.
149 149 * The encoding of DesiredAccess is discussed in the section entitled
150 150 * "Access Mode Encoding".
151 151 *
152 152 * Server Response Description
153 153 * ================================== =================================
154 154 *
155 155 * UCHAR WordCount; Count of parameter words = 7
156 156 * USHORT Fid; File handle
157 157 * USHORT FileAttributes; Attributes of opened file
158 158 * UTIME LastWriteTime; Time file was last written
159 159 * ULONG DataSize; File size
160 160 * USHORT GrantedAccess; Access allowed
161 161 * USHORT ByteCount; Count of data bytes = 0
162 162 *
163 163 * Fid is the handle value which should be used for subsequent file
164 164 * operations.
165 165 *
166 166 * FileAttributes specifies the type of file obtained. The encoding is
167 167 * described in the "File Attribute Encoding" section.
168 168 *
169 169 * GrantedAccess indicates the access permissions actually allowed, and may
170 170 * have one of the following values:
171 171 *
172 172 * 0 read-only
173 173 * 1 write-only
174 174 * 2 read/write
175 175 *
176 176 * File Handles (Fids) are scoped per client. A Pid may reference any Fid
177 177 * established by itself or any other Pid on the client (so far as the
178 178 * server is concerned). The actual accesses allowed through the Fid
179 179 * depends on the open and deny modes specified when the file was opened
180 180 * (see below).
181 181 *
182 182 * The MS-DOS compatibility mode of file open provides exclusion at the
183 183 * client level. A file open in compatibility mode may be opened (also in
184 184 * compatibility mode) any number of times for any combination of reading
185 185 * and writing (subject to the user's permissions) by any Pid on the same
186 186 * client. If the first client has the file open for writing, then the
187 187 * file may not be opened in any way by any other client. If the first
188 188 * client has the file open only for reading, then other clients may open
189 189 * the file, in compatibility mode, for reading.. The above
190 190 * notwithstanding, if the filename has an extension of .EXE, .DLL, .SYM,
191 191 * or .COM other clients are permitted to open the file regardless of
192 192 * read/write open modes of other compatibility mode opens. However, once
193 193 * multiple clients have the file open for reading, no client is permitted
194 194 * to open the file for writing and no other client may open the file in
195 195 * any mode other than compatibility mode.
196 196 *
197 197 * The other file exclusion modes (Deny read/write, Deny write, Deny read,
198 198 * Deny none) provide exclusion at the file level. A file opened in any
199 199 * "Deny" mode may be opened again only for the accesses allowed by the
200 200 * Deny mode (subject to the user's permissions). This is true regardless
201 201 * of the identity of the second opener -a different client, a Pid from the
202 202 * same client, or the Pid that already has the file open. For example, if
203 203 * a file is open in "Deny write" mode a second open may only obtain read
204 204 * permission to the file.
205 205 *
206 206 * Although Fids are available to all Pids on a client, Pids other than the
207 207 * owner may not have the full access rights specified in the open mode by
208 208 * the Fid's creator. If the open creating the Fid specified a deny mode,
209 209 * then any Pid using the Fid, other than the creating Pid, will have only
210 210 * those access rights determined by "anding" the open mode rights and the
211 211 * deny mode rights, i.e., the deny mode is checked on all file accesses.
212 212 * For example, if a file is opened for Read/Write in Deny write mode, then
213 213 * other clients may only read the file and cannot write; if a file is
214 214 * opened for Read in Deny read mode, then the other clients can neither
215 215 * read nor write the file.
216 216 */
217 217
218 218 smb_sdrc_t
219 219 smb_pre_open(smb_request_t *sr)
↓ open down ↓ |
219 lines elided |
↑ open up ↑ |
220 220 {
221 221 struct open_param *op = &sr->arg.open;
222 222 int rc;
223 223
224 224 bzero(op, sizeof (sr->arg.open));
225 225
226 226 rc = smbsr_decode_vwv(sr, "ww", &op->omode, &op->fqi.fq_sattr);
227 227 if (rc == 0)
228 228 rc = smbsr_decode_data(sr, "%S", sr, &op->fqi.fq_path.pn_path);
229 229
230 - DTRACE_SMB_2(op__Open__start, smb_request_t *, sr,
231 - struct open_param *, op);
230 + DTRACE_SMB_1(op__Open__start, smb_request_t *, sr); /* arg.open */
232 231
233 232 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
234 233 }
235 234
236 235 void
237 236 smb_post_open(smb_request_t *sr)
238 237 {
239 238 DTRACE_SMB_1(op__Open__done, smb_request_t *, sr);
240 239 }
241 240
242 241 smb_sdrc_t
243 242 smb_com_open(smb_request_t *sr)
244 243 {
245 244 struct open_param *op = &sr->arg.open;
246 245 smb_ofile_t *of;
247 246 smb_attr_t attr;
248 247 uint32_t status;
249 248 uint16_t file_attr;
250 249 int rc;
251 250
252 251 op->desired_access = smb_omode_to_amask(op->omode);
253 252 op->share_access = smb_denymode_to_sharemode(op->omode,
254 253 op->fqi.fq_path.pn_path);
255 254 op->crtime.tv_sec = op->crtime.tv_nsec = 0;
256 255 op->create_disposition = FILE_OPEN;
257 256 op->create_options = FILE_NON_DIRECTORY_FILE;
258 257 if (op->omode & SMB_DA_WRITE_THROUGH)
259 258 op->create_options |= FILE_WRITE_THROUGH;
260 259
261 260 if (sr->smb_flg & SMB_FLAGS_OPLOCK) {
262 261 if (sr->smb_flg & SMB_FLAGS_OPLOCK_NOTIFY_ANY)
263 262 op->op_oplock_level = SMB_OPLOCK_BATCH;
264 263 else
265 264 op->op_oplock_level = SMB_OPLOCK_EXCLUSIVE;
266 265 } else {
267 266 op->op_oplock_level = SMB_OPLOCK_NONE;
268 267 }
269 268 op->op_oplock_levelII = B_FALSE;
270 269
271 270 if (smb_open_dsize_check && op->dsize > UINT_MAX) {
272 271 smbsr_error(sr, 0, ERRDOS, ERRbadaccess);
273 272 return (SDRC_ERROR);
274 273 }
275 274
276 275 status = smb_common_open(sr);
277 276 if (status != NT_STATUS_SUCCESS) {
278 277 smbsr_status(sr, status, 0, 0);
279 278 return (SDRC_ERROR);
280 279 }
281 280
282 281 /*
283 282 * NB: after the above smb_common_open() success,
284 283 * we have a handle allocated (sr->fid_ofile).
285 284 * If we don't return success, we must close it.
286 285 */
287 286 of = sr->fid_ofile;
288 287
289 288 if (op->op_oplock_level == SMB_OPLOCK_NONE) {
290 289 sr->smb_flg &=
291 290 ~(SMB_FLAGS_OPLOCK | SMB_FLAGS_OPLOCK_NOTIFY_ANY);
292 291 }
293 292
294 293 file_attr = op->dattr & FILE_ATTRIBUTE_MASK;
295 294 bzero(&attr, sizeof (attr));
296 295 attr.sa_mask = SMB_AT_MTIME;
297 296 rc = smb_node_getattr(sr, of->f_node, of->f_cr, of, &attr);
298 297 if (rc != 0) {
299 298 smbsr_errno(sr, rc);
300 299 goto errout;
301 300 }
302 301
303 302 rc = smbsr_encode_result(sr, 7, 0, "bwwllww",
304 303 7,
305 304 sr->smb_fid,
306 305 file_attr,
307 306 smb_time_gmt_to_local(sr, attr.sa_vattr.va_mtime.tv_sec),
308 307 (uint32_t)op->dsize,
309 308 op->omode,
310 309 (uint16_t)0); /* bcc */
311 310
312 311 if (rc == 0)
313 312 return (SDRC_SUCCESS);
314 313
315 314 errout:
316 315 smb_ofile_close(of, 0);
317 316 return (SDRC_ERROR);
318 317 }
319 318
320 319 int smb_openx_enable_extended_response = 1;
321 320
322 321 /*
323 322 * smb_pre_open_andx
324 323 * For compatibility with windows servers, the search attributes
325 324 * specified in the request are ignored.
326 325 */
327 326 smb_sdrc_t
328 327 smb_pre_open_andx(smb_request_t *sr)
329 328 {
330 329 struct open_param *op = &sr->arg.open;
331 330 uint16_t openx_flags;
332 331 uint32_t alloc_size;
333 332 uint32_t creation_time;
334 333 uint16_t file_attr, sattr;
335 334 int rc;
336 335
337 336 bzero(op, sizeof (sr->arg.open));
338 337
339 338 rc = smbsr_decode_vwv(sr, "b.wwwwwlwll4.", &sr->andx_com,
340 339 &sr->andx_off, &openx_flags, &op->omode, &sattr,
341 340 &file_attr, &creation_time, &op->ofun, &alloc_size, &op->timeo);
342 341
343 342 if (rc == 0) {
344 343 rc = smbsr_decode_data(sr, "%u", sr, &op->fqi.fq_path.pn_path);
345 344
346 345 op->dattr = file_attr;
347 346 op->dsize = alloc_size;
348 347
349 348 /*
350 349 * The openx_flags use some "extended" flags that
351 350 * happen to match some of the NtCreateX flags.
352 351 */
353 352 if (openx_flags & NT_CREATE_FLAG_REQUEST_OPLOCK)
354 353 op->op_oplock_level = SMB_OPLOCK_EXCLUSIVE;
355 354 else if (openx_flags & NT_CREATE_FLAG_REQUEST_OPBATCH)
356 355 op->op_oplock_level = SMB_OPLOCK_BATCH;
357 356 else
358 357 op->op_oplock_level = SMB_OPLOCK_NONE;
359 358 if (openx_flags & NT_CREATE_FLAG_EXTENDED_RESPONSE)
↓ open down ↓ |
118 lines elided |
↑ open up ↑ |
360 359 op->nt_flags |= NT_CREATE_FLAG_EXTENDED_RESPONSE;
361 360
362 361 if ((creation_time != 0) && (creation_time != UINT_MAX))
363 362 op->crtime.tv_sec =
364 363 smb_time_local_to_gmt(sr, creation_time);
365 364 op->crtime.tv_nsec = 0;
366 365
367 366 op->create_disposition = smb_ofun_to_crdisposition(op->ofun);
368 367 }
369 368
370 - DTRACE_SMB_2(op__OpenX__start, smb_request_t *, sr,
371 - struct open_param *, op);
369 + DTRACE_SMB_1(op__OpenX__start, smb_request_t *, sr); /* arg.open */
372 370
373 371 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
374 372 }
375 373
376 374 void
377 375 smb_post_open_andx(smb_request_t *sr)
378 376 {
379 377 DTRACE_SMB_1(op__OpenX__done, smb_request_t *, sr);
380 378 }
381 379
382 380 smb_sdrc_t
383 381 smb_com_open_andx(smb_request_t *sr)
384 382 {
385 383 struct open_param *op = &sr->arg.open;
386 384 smb_attr_t *ap = &op->fqi.fq_fattr;
387 385 smb_ofile_t *of;
388 386 uint32_t status;
389 387 uint32_t mtime_sec;
390 388 uint16_t file_attr;
391 389 int rc;
392 390
393 391 op->desired_access = smb_omode_to_amask(op->omode);
394 392 op->share_access = smb_denymode_to_sharemode(op->omode,
395 393 op->fqi.fq_path.pn_path);
396 394
397 395 if (op->create_disposition > FILE_MAXIMUM_DISPOSITION) {
398 396 smbsr_error(sr, 0, ERRDOS, ERRbadaccess);
399 397 return (SDRC_ERROR);
400 398 }
401 399
402 400 op->create_options = FILE_NON_DIRECTORY_FILE;
403 401 if (op->omode & SMB_DA_WRITE_THROUGH)
404 402 op->create_options |= FILE_WRITE_THROUGH;
405 403
406 404 op->op_oplock_levelII = B_FALSE;
407 405
408 406 if (smb_open_dsize_check && op->dsize > UINT_MAX) {
409 407 smbsr_error(sr, 0, ERRDOS, ERRbadaccess);
410 408 return (SDRC_ERROR);
411 409 }
412 410
413 411 status = smb_common_open(sr);
414 412 if (status != NT_STATUS_SUCCESS) {
415 413 smbsr_status(sr, status, 0, 0);
416 414 return (SDRC_ERROR);
417 415 }
418 416
419 417 /*
420 418 * NB: after the above smb_common_open() success,
421 419 * we have a handle allocated (sr->fid_ofile).
422 420 * If we don't return success, we must close it.
423 421 */
424 422 of = sr->fid_ofile;
425 423
426 424 if (op->op_oplock_level != SMB_OPLOCK_NONE)
427 425 op->action_taken |= SMB_OACT_OPLOCK;
428 426 else
429 427 op->action_taken &= ~SMB_OACT_OPLOCK;
430 428
431 429 file_attr = op->dattr & FILE_ATTRIBUTE_MASK;
432 430 mtime_sec = smb_time_gmt_to_local(sr, ap->sa_vattr.va_mtime.tv_sec);
433 431
434 432 switch (sr->tid_tree->t_res_type & STYPE_MASK) {
435 433 case STYPE_DISKTREE:
436 434 case STYPE_PRINTQ:
437 435 break;
438 436
439 437 case STYPE_IPC:
440 438 mtime_sec = 0;
441 439 break;
442 440
443 441 default:
444 442 smbsr_error(sr, NT_STATUS_INVALID_DEVICE_REQUEST,
445 443 ERRDOS, ERROR_INVALID_FUNCTION);
446 444 goto errout;
447 445 }
448 446
449 447 if ((op->nt_flags & NT_CREATE_FLAG_EXTENDED_RESPONSE) != 0 &&
450 448 smb_openx_enable_extended_response != 0) {
451 449 uint32_t MaxAccess = 0;
452 450 if (of->f_node != NULL) {
453 451 smb_fsop_eaccess(sr, of->f_cr, of->f_node, &MaxAccess);
454 452 }
455 453 MaxAccess |= of->f_granted_access;
456 454
457 455 rc = smbsr_encode_result(
458 456 sr, 19, 0, "bb.wwwllwwwwl2.llw",
459 457 19, /* word count (b) */
460 458 sr->andx_com, /* (b.) */
461 459 VAR_BCC, /* andx offset (w) */
462 460 sr->smb_fid, /* (w) */
463 461 file_attr, /* (w) */
464 462 mtime_sec, /* (l) */
465 463 (uint32_t)op->dsize, /* (l) */
466 464 op->omode, /* (w) */
467 465 op->ftype, /* (w) */
468 466 op->devstate, /* (w) */
469 467 op->action_taken, /* (w) */
470 468 0, /* legacy fileid (l) */
471 469 /* reserved (2.) */
472 470 MaxAccess, /* (l) */
473 471 0, /* guest access (l) */
474 472 0); /* byte count (w) */
475 473
476 474 } else {
477 475 rc = smbsr_encode_result(
478 476 sr, 15, 0, "bb.wwwllwwwwl2.w",
479 477 15, /* word count (b) */
480 478 sr->andx_com, /* (b.) */
481 479 VAR_BCC, /* andx offset (w) */
482 480 sr->smb_fid, /* (w) */
483 481 file_attr, /* (w) */
484 482 mtime_sec, /* (l) */
485 483 (uint32_t)op->dsize, /* (l) */
486 484 op->omode, /* (w) */
487 485 op->ftype, /* (w) */
488 486 op->devstate, /* (w) */
489 487 op->action_taken, /* (w) */
490 488 0, /* legacy fileid (l) */
491 489 /* reserved (2.) */
492 490 0); /* byte count (w) */
493 491 }
494 492
495 493 if (rc == 0)
496 494 return (SDRC_SUCCESS);
497 495
498 496 errout:
499 497 smb_ofile_close(of, 0);
500 498 return (SDRC_ERROR);
501 499 }
502 500
503 501 smb_sdrc_t
504 502 smb_com_trans2_open2(smb_request_t *sr, smb_xa_t *xa)
505 503 {
506 504 struct open_param *op = &sr->arg.open;
507 505 uint32_t creation_time;
508 506 uint32_t alloc_size;
509 507 uint32_t ea_list_size;
510 508 uint16_t flags;
511 509 uint16_t file_attr;
512 510 uint32_t status;
513 511 int rc;
514 512
515 513 bzero(op, sizeof (sr->arg.open));
516 514
517 515 rc = smb_mbc_decodef(&xa->req_param_mb, "%wwwwlwl10.u",
518 516 sr, &flags, &op->omode, &op->fqi.fq_sattr, &file_attr,
519 517 &creation_time, &op->ofun, &alloc_size, &op->fqi.fq_path.pn_path);
520 518 if (rc != 0)
521 519 return (SDRC_ERROR);
522 520
523 521 /*
524 522 * The data part of this transaction may contain an EA list.
525 523 * See: SMB_FEA_LIST ExtendedAttributeList
526 524 *
527 525 * If we find a non-empty EA list payload, return the special
528 526 * error that tells the caller this FS does not suport EAs.
529 527 *
530 528 * Note: the first word is the size of the whole data segment,
531 529 * INCLUDING the size of that length word. That means if
532 530 * the length word specifies a size less than four, it's
533 531 * invalid (and probably a client trying something fishy).
534 532 */
535 533 rc = smb_mbc_decodef(&xa->req_data_mb, "l", &ea_list_size);
536 534 if (rc == 0 && ea_list_size > 4) {
537 535 smbsr_status(sr, NT_STATUS_EAS_NOT_SUPPORTED, 0, 0);
538 536 return (SDRC_ERROR);
539 537 }
540 538
541 539 if ((creation_time != 0) && (creation_time != UINT_MAX))
542 540 op->crtime.tv_sec = smb_time_local_to_gmt(sr, creation_time);
543 541 op->crtime.tv_nsec = 0;
544 542
545 543 op->dattr = file_attr;
546 544 op->dsize = alloc_size;
547 545 op->create_options = FILE_NON_DIRECTORY_FILE;
548 546
549 547 op->desired_access = smb_omode_to_amask(op->omode);
550 548 op->share_access = smb_denymode_to_sharemode(op->omode,
551 549 op->fqi.fq_path.pn_path);
552 550
553 551 op->create_disposition = smb_ofun_to_crdisposition(op->ofun);
554 552 if (op->create_disposition > FILE_MAXIMUM_DISPOSITION)
555 553 op->create_disposition = FILE_CREATE;
556 554
557 555 if (op->omode & SMB_DA_WRITE_THROUGH)
558 556 op->create_options |= FILE_WRITE_THROUGH;
559 557
560 558 if (sr->smb_flg & SMB_FLAGS_OPLOCK) {
561 559 if (sr->smb_flg & SMB_FLAGS_OPLOCK_NOTIFY_ANY)
562 560 op->op_oplock_level = SMB_OPLOCK_BATCH;
563 561 else
564 562 op->op_oplock_level = SMB_OPLOCK_EXCLUSIVE;
565 563 } else {
566 564 op->op_oplock_level = SMB_OPLOCK_NONE;
567 565 }
568 566 op->op_oplock_levelII = B_FALSE;
569 567
570 568 status = smb_common_open(sr);
571 569 if (status != NT_STATUS_SUCCESS) {
572 570 smbsr_status(sr, status, 0, 0);
573 571 return (SDRC_ERROR);
574 572 }
575 573
576 574 if (op->op_oplock_level != SMB_OPLOCK_NONE)
577 575 op->action_taken |= SMB_OACT_OPLOCK;
578 576 else
579 577 op->action_taken &= ~SMB_OACT_OPLOCK;
580 578
581 579 file_attr = op->dattr & FILE_ATTRIBUTE_MASK;
582 580
583 581 if (STYPE_ISIPC(sr->tid_tree->t_res_type))
584 582 op->dsize = 0;
585 583
586 584 (void) smb_mbc_encodef(&xa->rep_param_mb, "wwllwwwwlwl",
587 585 sr->smb_fid,
588 586 file_attr,
589 587 (uint32_t)0, /* creation time */
590 588 (uint32_t)op->dsize,
591 589 op->omode,
592 590 op->ftype,
593 591 op->devstate,
594 592 op->action_taken,
595 593 op->fileid,
596 594 (uint16_t)0, /* EA error offset */
597 595 (uint32_t)0); /* EA list length */
598 596
599 597 return (SDRC_SUCCESS);
600 598 }
↓ open down ↓ |
219 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX