smb_rename.c revision 2c2961f8403049d948b9f3e6c35d6488b6b7e1aa
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <smbsrv/smb_incl.h>
#include <smbsrv/smb_fsops.h>
/*
* smb_com_rename
*
* Rename a file. Files OldFileName must exist and NewFileName must not.
* Both pathnames must be relative to the Tid specified in the request.
* Open files may be renamed.
*
* Multiple files may be renamed in response to a single request as Rename
* File supports wildcards in the file name (last component of the path).
* NOTE: we don't support rename with wildcards.
*
* SearchAttributes indicates the attributes that the target file(s) must
* have. If SearchAttributes is zero then only normal files are renamed.
* If the system file or hidden attributes are specified then the rename
* is inclusive - both the specified type(s) of files and normal files are
* renamed. The encoding of SearchAttributes is described in section 3.10
* - File Attribute Encoding.
*/
{
int rc;
}
}
void
{
}
{
int rc;
return (SDRC_ERROR);
}
mutex_enter(&mutex);
mutex_exit(&mutex);
if (rc != 0) {
/*
* The following values are based on observed WFWG,
* Windows 9x, NT and Windows 2000 behaviour.
* ERROR_FILE_EXISTS doesn't work for Windows 98 clients.
* Windows 95 clients don't see the problem because the
* target is deleted before the rename request.
*/
switch (rc) {
case EEXIST:
break;
case EPIPE:
break;
case ENOENT:
break;
default:
break;
}
return (SDRC_ERROR);
}
if (dst_node) {
}
}
}
/*
* smb_do_rename
*
* Backend to smb_com_rename to ensure that the rename operation is atomic.
* This function should be called within a mutual exclusion region. If the
* source and destination are identical, we don't actually do a rename, we
* just check that the conditions are right. If the source and destination
* files differ only in case, we a case-sensitive rename. Otherwise, we do
* a full case-insensitive rename.
*
* This function should always return errno values.
*
* Upon success, the last_snode's and dir_snode's of both src_fqi and dst_fqi
* are not released in this routine but in smb_com_rename().
*/
static int
{
char *dstname;
int rc;
int count;
return (rc);
}
/*
* Break the oplock before access checks. If a client
* has a file open, this will force a flush or close,
* which may affect the outcome of any share checking.
*/
B_FALSE);
if (count) {
}
if (status != NT_STATUS_SHARING_VIOLATION)
break;
}
if (status == NT_STATUS_SHARING_VIOLATION) {
return (EPIPE); /* = ERRbadshare */
}
if (status != NT_STATUS_SUCCESS) {
return (EACCES);
}
return (rc);
}
/*
* Because the fqm parameter to smbd_fs_query() was 0,
* a successful return value means that dst_fqi->last_snode
* may be NULL.
*/
if (dst_fqi->last_snode)
if (rc == 0) {
return (0);
}
if (rc != 0) {
}
return (rc);
}
if (rc != 0) {
return (rc);
}
/*
* Because of FQM_PATH_MUST_NOT_EXIST and the successful return
* value, only dst_fqi->dir_snode is valid (dst_fqi->last_snode
* is NULL).
*/
/*
* Use the unmangled form of the destination name if the
* source and destination names are the same and the source
* name is mangled. (We are taking a chance here, assuming
* that this is what the user wants.)
*/
} else {
}
dstname);
if (rc != 0) {
}
return (rc);
}