smb_close.c revision c8ec8eea9849cac239663c46be8a7f5d2ba7ca00
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER START
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The contents of this file are subject to the terms of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Common Development and Distribution License (the "License").
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You may not use this file except in compliance with the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See the License for the specific language governing permissions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and limitations under the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * When distributing Covered Code, include this CDDL HEADER in each
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If applicable, add the following below this CDDL HEADER, with the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * fields enclosed by brackets "[]" replaced with your own identifying
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * information: Portions Copyright [yyyy] [name of copyright owner]
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER END
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Use is subject to license terms.
c8ec8eea9849cac239663c46be8a7f5d2ba7ca00jose borrego#pragma ident "@(#)smb_close.c 1.6 08/08/08 SMI"
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Close a file by fid. All locks or other resources held by the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * requesting process on the file should be released by the server.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The requesting process can no longer use the fid for further
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * file access requests.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If LastWriteTime is non-zero, it should be used to set the file
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * timestamp. Otherwise, file system should set the timestamp.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Failure to set the timestamp, even if requested by the client,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * should not result in an error response from the server.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb rc = smbsr_decode_vwv(sr, "wl", &sr->smb_fid, &sr->arg.timestamp);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->fid_ofile = smb_ofile_lookup_by_fid(sr->tid_tree, sr->smb_fid);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, NT_STATUS_INVALID_HANDLE, ERRDOS, ERRbadfid);
c8ec8eea9849cac239663c46be8a7f5d2ba7ca00jose borrego smb_ofile_close(sr->fid_ofile, sr->arg.timestamp);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Close the file represented by fid and then disconnect the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * associated tree.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb rc = smbsr_decode_vwv(sr, "wl", &sr->smb_fid, &sr->arg.timestamp);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__CloseAndTreeDisconnect__start, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__CloseAndTreeDisconnect__done, smb_request_t *, sr);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->fid_ofile = smb_ofile_lookup_by_fid(sr->tid_tree, sr->smb_fid);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, NT_STATUS_INVALID_HANDLE, ERRDOS, ERRbadfid);
c8ec8eea9849cac239663c46be8a7f5d2ba7ca00jose borrego smb_ofile_close(sr->fid_ofile, sr->arg.timestamp);
c8ec8eea9849cac239663c46be8a7f5d2ba7ca00jose borrego smb_session_cancel_requests(sr->session, sr->tid_tree, sr);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * smb_commit_delete_on_close()
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Check for the DeleteOnClose flag on the smb file and set it on the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * smb node if it is not already set. This will inhibit subsequent
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * open requests. The delete-on-close credentials should be set to the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * user credentials of the current open file instance.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * When DeleteOnClose is set on an smb_node, the common open code will
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * reject subsequent open requests for the file. Observation of Windows
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 2000 indicates that subsequent opens should be allowed (assuming
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * there would be no sharing violation) until the file is closed using
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the fid on which the DeleteOnClose was requested.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If there are multiple opens with delete-on-close create options,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * whichever the first file handle is closed will trigger the node to be
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * marked as delete-on-close. The credentials of that ofile will be used
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * as the delete-on-close credentials of the node.