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 */ 215331Samw /* 228934SJose.Borrego@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 235331Samw * Use is subject to license terms. 245331Samw */ 255331Samw 265331Samw #include <smbsrv/smb_incl.h> 275331Samw 285331Samw 295331Samw /* 305331Samw * Close a file by fid. All locks or other resources held by the 315331Samw * requesting process on the file should be released by the server. 325331Samw * The requesting process can no longer use the fid for further 335331Samw * file access requests. 345331Samw * 355331Samw * If LastWriteTime is non-zero, it should be used to set the file 365331Samw * timestamp. Otherwise, file system should set the timestamp. 375331Samw * Failure to set the timestamp, even if requested by the client, 385331Samw * should not result in an error response from the server. 395331Samw */ 406030Sjb150015 smb_sdrc_t 416139Sjb150015 smb_pre_close(smb_request_t *sr) 425331Samw { 436139Sjb150015 int rc; 446139Sjb150015 456139Sjb150015 rc = smbsr_decode_vwv(sr, "wl", &sr->smb_fid, &sr->arg.timestamp); 466139Sjb150015 476139Sjb150015 DTRACE_SMB_1(op__Close__start, smb_request_t *, sr); 486139Sjb150015 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR); 496139Sjb150015 } 505331Samw 516139Sjb150015 void 526139Sjb150015 smb_post_close(smb_request_t *sr) 536139Sjb150015 { 546139Sjb150015 DTRACE_SMB_1(op__Close__done, smb_request_t *, sr); 556139Sjb150015 } 566139Sjb150015 576139Sjb150015 smb_sdrc_t 586139Sjb150015 smb_com_close(smb_request_t *sr) 596139Sjb150015 { 608934SJose.Borrego@Sun.COM smbsr_lookup_file(sr); 615331Samw if (sr->fid_ofile == NULL) { 625772Sas200622 smbsr_error(sr, NT_STATUS_INVALID_HANDLE, ERRDOS, ERRbadfid); 636139Sjb150015 return (SDRC_ERROR); 645331Samw } 655331Samw 667348SJose.Borrego@Sun.COM smb_ofile_close(sr->fid_ofile, sr->arg.timestamp); 677348SJose.Borrego@Sun.COM 687348SJose.Borrego@Sun.COM if (smbsr_encode_empty_result(sr) != 0) 696139Sjb150015 return (SDRC_ERROR); 705331Samw 717348SJose.Borrego@Sun.COM return (SDRC_SUCCESS); 725331Samw } 735331Samw 745331Samw /* 755331Samw * Close the file represented by fid and then disconnect the 765331Samw * associated tree. 775331Samw */ 786030Sjb150015 smb_sdrc_t 796139Sjb150015 smb_pre_close_and_tree_disconnect(smb_request_t *sr) 805331Samw { 816139Sjb150015 int rc; 826139Sjb150015 836139Sjb150015 rc = smbsr_decode_vwv(sr, "wl", &sr->smb_fid, &sr->arg.timestamp); 846139Sjb150015 856139Sjb150015 DTRACE_SMB_1(op__CloseAndTreeDisconnect__start, smb_request_t *, sr); 866139Sjb150015 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR); 876139Sjb150015 } 885331Samw 896139Sjb150015 void 906139Sjb150015 smb_post_close_and_tree_disconnect(smb_request_t *sr) 916139Sjb150015 { 926139Sjb150015 DTRACE_SMB_1(op__CloseAndTreeDisconnect__done, smb_request_t *, sr); 936139Sjb150015 } 946139Sjb150015 956139Sjb150015 smb_sdrc_t 966139Sjb150015 smb_com_close_and_tree_disconnect(smb_request_t *sr) 976139Sjb150015 { 988934SJose.Borrego@Sun.COM smbsr_lookup_file(sr); 995331Samw if (sr->fid_ofile == NULL) { 1005772Sas200622 smbsr_error(sr, NT_STATUS_INVALID_HANDLE, ERRDOS, ERRbadfid); 1016139Sjb150015 return (SDRC_ERROR); 1025331Samw } 1035331Samw 1047348SJose.Borrego@Sun.COM smb_ofile_close(sr->fid_ofile, sr->arg.timestamp); 1057348SJose.Borrego@Sun.COM smb_session_cancel_requests(sr->session, sr->tid_tree, sr); 106*9832Samw@Sun.COM smb_tree_disconnect(sr->tid_tree, B_TRUE); 1075331Samw 1087348SJose.Borrego@Sun.COM if (smbsr_encode_empty_result(sr) != 0) 1096139Sjb150015 return (SDRC_ERROR); 1105331Samw 1117348SJose.Borrego@Sun.COM return (SDRC_SUCCESS); 1125331Samw } 113