15331Samw /*
25331Samw * CDDL HEADER START
35331Samw *
45331Samw * The contents of this file are subject to the terms of the
55331Samw * Common Development and Distribution License (the "License").
65331Samw * You may not use this file except in compliance with the License.
75331Samw *
85331Samw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95331Samw * or http://www.opensolaris.org/os/licensing.
105331Samw * See the License for the specific language governing permissions
115331Samw * and limitations under the License.
125331Samw *
135331Samw * When distributing Covered Code, include this CDDL HEADER in each
145331Samw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155331Samw * If applicable, add the following below this CDDL HEADER, with the
165331Samw * fields enclosed by brackets "[]" replaced with your own identifying
175331Samw * information: Portions Copyright [yyyy] [name of copyright owner]
185331Samw *
195331Samw * CDDL HEADER END
205331Samw */
21*12508Samw@Sun.COM
225331Samw /*
23*12508Samw@Sun.COM * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
245331Samw */
255331Samw
265331Samw /*
275331Samw * SMB: unlock_byte_range
285331Samw *
295331Samw * This message is sent to unlock the given byte range. Offset, Count, and
305331Samw * Pid must be identical to that specified in a prior successful lock. If
315331Samw *
325331Samw * an unlock references an address range that is not locked, no error is
335331Samw * generated.
345331Samw *
355331Samw * Since Offset is a 32 bit quantity, this request is inappropriate for
365331Samw * general locking within a very large file.
375331Samw *
385331Samw * Client Request Description
395331Samw * ================================== =================================
405331Samw *
415331Samw * UCHAR WordCount; Count of parameter words = 5
425331Samw * USHORT Fid; File handle
435331Samw * ULONG Count; Count of bytes to unlock
445331Samw * ULONG Offset; Offset from start of file
455331Samw * USHORT ByteCount; Count of data bytes = 0
465331Samw *
475331Samw * Server Response Description
485331Samw * ================================== =================================
495331Samw *
505331Samw * UCHAR WordCount; Count of parameter words = 0
515331Samw * USHORT ByteCount; Count of data bytes = 0
525331Samw */
535331Samw
5410966SJordan.Brown@Sun.COM #include <smbsrv/smb_kproto.h>
555331Samw
566030Sjb150015 smb_sdrc_t
smb_pre_unlock_byte_range(smb_request_t * sr)576139Sjb150015 smb_pre_unlock_byte_range(smb_request_t *sr)
586139Sjb150015 {
596139Sjb150015 DTRACE_SMB_1(op__UnlockByteRange__start, smb_request_t *, sr);
606139Sjb150015 return (SDRC_SUCCESS);
616139Sjb150015 }
626139Sjb150015
636139Sjb150015 void
smb_post_unlock_byte_range(smb_request_t * sr)646139Sjb150015 smb_post_unlock_byte_range(smb_request_t *sr)
656139Sjb150015 {
666139Sjb150015 DTRACE_SMB_1(op__UnlockByteRange__done, smb_request_t *, sr);
676139Sjb150015 }
686139Sjb150015
696139Sjb150015 smb_sdrc_t
smb_com_unlock_byte_range(smb_request_t * sr)706139Sjb150015 smb_com_unlock_byte_range(smb_request_t *sr)
715331Samw {
725331Samw uint32_t Length;
735331Samw uint32_t Offset;
745331Samw DWORD result;
755331Samw
766030Sjb150015 if (smbsr_decode_vwv(sr, "wll", &sr->smb_fid, &Length, &Offset) != 0)
776139Sjb150015 return (SDRC_ERROR);
785331Samw
798934SJose.Borrego@Sun.COM smbsr_lookup_file(sr);
805331Samw if (sr->fid_ofile == NULL) {
815772Sas200622 smbsr_error(sr, NT_STATUS_INVALID_HANDLE, ERRDOS, ERRbadfid);
826139Sjb150015 return (SDRC_ERROR);
835331Samw }
845331Samw
855331Samw result = smb_unlock_range(sr, sr->fid_ofile->f_node,
865521Sas200622 (u_offset_t)Offset, (uint64_t)Length);
875331Samw if (result != NT_STATUS_SUCCESS) {
885772Sas200622 smbsr_error(sr, NT_STATUS_RANGE_NOT_LOCKED,
89*12508Samw@Sun.COM ERRDOS, ERROR_NOT_LOCKED);
906139Sjb150015 return (SDRC_ERROR);
915331Samw }
925331Samw
936030Sjb150015 if (smbsr_encode_empty_result(sr))
946139Sjb150015 return (SDRC_ERROR);
955331Samw
966139Sjb150015 return (SDRC_SUCCESS);
975331Samw }
98