smb_write.c (0897f7fbb62326e60e858c62a1654b2ca3e2667e) | smb_write.c (93bc28dbaee6387120d48b12b3dc1ba5f7418e6e) |
---|---|
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 --- 7 unchanged lines hidden (view full) --- 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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. | 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 --- 7 unchanged lines hidden (view full) --- 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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. |
24 * Copyright 2016 Nexenta Systems, Inc. All rights reserved. | 24 * Copyright 2017 Nexenta Systems, Inc. All rights reserved. |
25 */ 26 27#include <sys/sdt.h> 28#include <smbsrv/smb_kproto.h> 29#include <smbsrv/smb_fsops.h> 30#include <smbsrv/netbios.h> 31 32 --- 23 unchanged lines hidden (view full) --- 56 param->rw_magic = SMB_RW_MAGIC; 57 58 rc = smbsr_decode_vwv(sr, "wwl", &sr->smb_fid, &count, &off); 59 60 param->rw_count = (uint32_t)count; 61 param->rw_offset = (uint64_t)off; 62 param->rw_vdb.vdb_uio.uio_loffset = (offset_t)param->rw_offset; 63 | 25 */ 26 27#include <sys/sdt.h> 28#include <smbsrv/smb_kproto.h> 29#include <smbsrv/smb_fsops.h> 30#include <smbsrv/netbios.h> 31 32 --- 23 unchanged lines hidden (view full) --- 56 param->rw_magic = SMB_RW_MAGIC; 57 58 rc = smbsr_decode_vwv(sr, "wwl", &sr->smb_fid, &count, &off); 59 60 param->rw_count = (uint32_t)count; 61 param->rw_offset = (uint64_t)off; 62 param->rw_vdb.vdb_uio.uio_loffset = (offset_t)param->rw_offset; 63 |
64 DTRACE_SMB_2(op__Write__start, smb_request_t *, sr, 65 smb_rw_param_t *, param); | 64 DTRACE_SMB_START(op__Write, smb_request_t *, sr); /* arg.rw */ |
66 67 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR); 68} 69 70void 71smb_post_write(smb_request_t *sr) 72{ | 65 66 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR); 67} 68 69void 70smb_post_write(smb_request_t *sr) 71{ |
73 DTRACE_SMB_2(op__Write__done, smb_request_t *, sr, 74 smb_rw_param_t *, sr->arg.rw); | 72 DTRACE_SMB_DONE(op__Write, smb_request_t *, sr); /* arg.rw */ |
75 76 kmem_free(sr->arg.rw, sizeof (smb_rw_param_t)); 77} 78 79smb_sdrc_t 80smb_com_write(smb_request_t *sr) 81{ 82 smb_rw_param_t *param = sr->arg.rw; --- 63 unchanged lines hidden (view full) --- 146 } else { 147 rc = smbsr_decode_vwv(sr, "wwll", &sr->smb_fid, 148 &count, &off, ¶m->rw_last_write); 149 } 150 151 param->rw_count = (uint32_t)count; 152 param->rw_offset = (uint64_t)off; 153 | 73 74 kmem_free(sr->arg.rw, sizeof (smb_rw_param_t)); 75} 76 77smb_sdrc_t 78smb_com_write(smb_request_t *sr) 79{ 80 smb_rw_param_t *param = sr->arg.rw; --- 63 unchanged lines hidden (view full) --- 144 } else { 145 rc = smbsr_decode_vwv(sr, "wwll", &sr->smb_fid, 146 &count, &off, ¶m->rw_last_write); 147 } 148 149 param->rw_count = (uint32_t)count; 150 param->rw_offset = (uint64_t)off; 151 |
154 DTRACE_SMB_2(op__WriteAndClose__start, smb_request_t *, sr, 155 smb_rw_param_t *, param); | 152 DTRACE_SMB_START(op__WriteAndClose, smb_request_t *, sr); /* arg.rw */ |
156 157 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR); 158} 159 160void 161smb_post_write_and_close(smb_request_t *sr) 162{ | 153 154 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR); 155} 156 157void 158smb_post_write_and_close(smb_request_t *sr) 159{ |
163 DTRACE_SMB_2(op__WriteAndClose__done, smb_request_t *, sr, 164 smb_rw_param_t *, sr->arg.rw); | 160 DTRACE_SMB_DONE(op__WriteAndClose, smb_request_t *, sr); /* arg.rw */ |
165 166 kmem_free(sr->arg.rw, sizeof (smb_rw_param_t)); 167} 168 169smb_sdrc_t 170smb_com_write_and_close(smb_request_t *sr) 171{ 172 smb_rw_param_t *param = sr->arg.rw; --- 71 unchanged lines hidden (view full) --- 244 sr->arg.rw = param; 245 param->rw_magic = SMB_RW_MAGIC; 246 247 rc = smbsr_decode_vwv(sr, "wwlw", &sr->smb_fid, &count, &off, &remcnt); 248 249 param->rw_count = (uint32_t)count; 250 param->rw_offset = (uint64_t)off; 251 | 161 162 kmem_free(sr->arg.rw, sizeof (smb_rw_param_t)); 163} 164 165smb_sdrc_t 166smb_com_write_and_close(smb_request_t *sr) 167{ 168 smb_rw_param_t *param = sr->arg.rw; --- 71 unchanged lines hidden (view full) --- 240 sr->arg.rw = param; 241 param->rw_magic = SMB_RW_MAGIC; 242 243 rc = smbsr_decode_vwv(sr, "wwlw", &sr->smb_fid, &count, &off, &remcnt); 244 245 param->rw_count = (uint32_t)count; 246 param->rw_offset = (uint64_t)off; 247 |
252 DTRACE_SMB_2(op__WriteAndUnlock__start, smb_request_t *, sr, 253 smb_rw_param_t *, param); | 248 DTRACE_SMB_START(op__WriteAndUnlock, smb_request_t *, sr); /* arg.rw */ |
254 255 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR); 256} 257 258void 259smb_post_write_and_unlock(smb_request_t *sr) 260{ | 249 250 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR); 251} 252 253void 254smb_post_write_and_unlock(smb_request_t *sr) 255{ |
261 DTRACE_SMB_2(op__WriteAndUnlock__done, smb_request_t *, sr, 262 smb_rw_param_t *, sr->arg.rw); | 256 DTRACE_SMB_DONE(op__WriteAndUnlock, smb_request_t *, sr); /* arg.rw */ |
263 264 kmem_free(sr->arg.rw, sizeof (smb_rw_param_t)); 265} 266 267smb_sdrc_t 268smb_com_write_and_unlock(smb_request_t *sr) 269{ 270 smb_rw_param_t *param = sr->arg.rw; --- 49 unchanged lines hidden (view full) --- 320 } 321 322 rc = smbsr_encode_result(sr, 1, 0, "bww", 1, 323 (uint16_t)param->rw_count, 0); 324 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR); 325} 326 327/* | 257 258 kmem_free(sr->arg.rw, sizeof (smb_rw_param_t)); 259} 260 261smb_sdrc_t 262smb_com_write_and_unlock(smb_request_t *sr) 263{ 264 smb_rw_param_t *param = sr->arg.rw; --- 49 unchanged lines hidden (view full) --- 314 } 315 316 rc = smbsr_encode_result(sr, 1, 0, "bww", 1, 317 (uint16_t)param->rw_count, 0); 318 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR); 319} 320 321/* |
322 * The SMB_COM_WRITE_RAW protocol was a negotiated option introduced in 323 * SMB Core Plus to maximize performance when writing a large block 324 * of data to a server. It's obsolete and no longer supported. 325 * 326 * We keep a handler for it so the dtrace provider can see if 327 * the client tried to use this command. 328 */ 329smb_sdrc_t 330smb_pre_write_raw(smb_request_t *sr) 331{ 332 DTRACE_SMB_START(op__WriteRaw, smb_request_t *, sr); 333 return (SDRC_SUCCESS); 334} 335 336void 337smb_post_write_raw(smb_request_t *sr) 338{ 339 DTRACE_SMB_DONE(op__WriteRaw, smb_request_t *, sr); 340} 341 342smb_sdrc_t 343smb_com_write_raw(struct smb_request *sr) 344{ 345 smbsr_error(sr, NT_STATUS_NOT_SUPPORTED, ERRDOS, 346 ERROR_NOT_SUPPORTED); 347 return (SDRC_ERROR); 348} 349 350/* |
|
328 * Write bytes to a file (SMB Core). This request was extended in 329 * LM 0.12 to support 64-bit offsets, indicated by sending a wct of 330 * 14, instead of 12, and including additional offset information. 331 * 332 * A ByteCount of 0 does not truncate the file - use SMB_COM_WRITE 333 * to truncate a file. A zero length merely transfers zero bytes. 334 * 335 * If bit 0 of WriteMode is set, Fid must refer to a disk file and --- 46 unchanged lines hidden (view full) --- 382 * Work-around a Win7 bug, where it fails to set the 383 * CAP_LARGE_WRITEX flag during session setup. Assume 384 * a large write if the data remaining is >= 64k. 385 */ 386 if ((sr->session->capabilities & CAP_LARGE_WRITEX) != 0 || 387 (sr->smb_data.max_bytes > (sr->smb_data.chain_offset + 0xFFFF))) 388 param->rw_count |= ((uint32_t)datalen_high << 16); 389 | 351 * Write bytes to a file (SMB Core). This request was extended in 352 * LM 0.12 to support 64-bit offsets, indicated by sending a wct of 353 * 14, instead of 12, and including additional offset information. 354 * 355 * A ByteCount of 0 does not truncate the file - use SMB_COM_WRITE 356 * to truncate a file. A zero length merely transfers zero bytes. 357 * 358 * If bit 0 of WriteMode is set, Fid must refer to a disk file and --- 46 unchanged lines hidden (view full) --- 405 * Work-around a Win7 bug, where it fails to set the 406 * CAP_LARGE_WRITEX flag during session setup. Assume 407 * a large write if the data remaining is >= 64k. 408 */ 409 if ((sr->session->capabilities & CAP_LARGE_WRITEX) != 0 || 410 (sr->smb_data.max_bytes > (sr->smb_data.chain_offset + 0xFFFF))) 411 param->rw_count |= ((uint32_t)datalen_high << 16); 412 |
390 DTRACE_SMB_2(op__WriteX__start, smb_request_t *, sr, 391 smb_rw_param_t *, param); | 413 DTRACE_SMB_START(op__WriteX, smb_request_t *, sr); /* arg.rw */ |
392 393 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR); 394} 395 396void 397smb_post_write_andx(smb_request_t *sr) 398{ | 414 415 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR); 416} 417 418void 419smb_post_write_andx(smb_request_t *sr) 420{ |
399 DTRACE_SMB_2(op__WriteX__done, smb_request_t *, sr, 400 smb_rw_param_t *, sr->arg.rw); | 421 DTRACE_SMB_DONE(op__WriteX, smb_request_t *, sr); /* arg.rw */ |
401 402 kmem_free(sr->arg.rw, sizeof (smb_rw_param_t)); 403} 404 405smb_sdrc_t 406smb_com_write_andx(smb_request_t *sr) 407{ 408 smb_rw_param_t *param = sr->arg.rw; --- 176 unchanged lines hidden --- | 422 423 kmem_free(sr->arg.rw, sizeof (smb_rw_param_t)); 424} 425 426smb_sdrc_t 427smb_com_write_andx(smb_request_t *sr) 428{ 429 smb_rw_param_t *param = sr->arg.rw; --- 176 unchanged lines hidden --- |