smb_rename.c revision a90cf9f29973990687fa61de9f1f6ea22e924e40
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
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
5fd03bc0f2e00e7ba02316c2e08f45d52aab15dbGordon Ross * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
b1352070d318187b41b088da3533692976f3f225Alan Wright * NT_RENAME InformationLevels:
b1352070d318187b41b088da3533692976f3f225Alan Wright * SMB_NT_RENAME_MOVE_CLUSTER_INFO Server returns invalid parameter.
b1352070d318187b41b088da3533692976f3f225Alan Wright * SMB_NT_RENAME_SET_LINK_INFO Create a hard link to a file.
b1352070d318187b41b088da3533692976f3f225Alan Wright * SMB_NT_RENAME_RENAME_FILE In-place rename of a file.
b1352070d318187b41b088da3533692976f3f225Alan Wright * SMB_NT_RENAME_MOVE_FILE Move (rename) a file.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * smb_com_rename
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Rename a file. Files OldFileName must exist and NewFileName must not.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Both pathnames must be relative to the Tid specified in the request.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Open files may be renamed.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Multiple files may be renamed in response to a single request as Rename
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * File supports wildcards in the file name (last component of the path).
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * NOTE: we don't support rename with wildcards.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SearchAttributes indicates the attributes that the target file(s) must
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * have. If SearchAttributes is zero then only normal files are renamed.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If the system file or hidden attributes are specified then the rename
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * is inclusive - both the specified type(s) of files and normal files are
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States smb_fqi_t *src_fqi = &sr->arg.dirop.fqi;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States smb_fqi_t *dst_fqi = &sr->arg.dirop.dst_fqi;
eb1d736b1c19f6abeee90c921a9320b67fedd016afshin salek ardakani - Sun Microsystems - Irvine United States if ((rc = smbsr_decode_vwv(sr, "w", &src_fqi->fq_sattr)) == 0) {
eb1d736b1c19f6abeee90c921a9320b67fedd016afshin salek ardakani - Sun Microsystems - Irvine United States rc = smbsr_decode_data(sr, "%SS", sr, &src_fqi->fq_path.pn_path,
eb1d736b1c19f6abeee90c921a9320b67fedd016afshin salek ardakani - Sun Microsystems - Irvine United States &dst_fqi->fq_path.pn_path);
eb1d736b1c19f6abeee90c921a9320b67fedd016afshin salek ardakani - Sun Microsystems - Irvine United States dst_fqi->fq_sattr = 0;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_fqi_t *src_fqi = &sr->arg.dirop.fqi;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_fqi_t *dst_fqi = &sr->arg.dirop.dst_fqi;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_t *src_pn = &src_fqi->fq_path;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_t *dst_pn = &dst_fqi->fq_path;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_init(sr, src_pn, src_pn->pn_path);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_init(sr, dst_pn, dst_pn->pn_path);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_pathname_validate(sr, src_pn) ||
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States !smb_pathname_validate(sr, dst_pn)) {
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States }
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross status = smb_common_rename(sr, src_fqi, dst_fqi);
b1352070d318187b41b088da3533692976f3f225Alan Wright * smb_com_nt_rename
b1352070d318187b41b088da3533692976f3f225Alan Wright * Rename a file. Files OldFileName must exist and NewFileName must not.
b1352070d318187b41b088da3533692976f3f225Alan Wright * Both pathnames must be relative to the Tid specified in the request.
b1352070d318187b41b088da3533692976f3f225Alan Wright * Open files may be renamed.
b1352070d318187b41b088da3533692976f3f225Alan Wright * SearchAttributes indicates the attributes that the target file(s) must
b1352070d318187b41b088da3533692976f3f225Alan Wright * have. If SearchAttributes is zero then only normal files are renamed.
b1352070d318187b41b088da3533692976f3f225Alan Wright * If the system file or hidden attributes are specified then the rename
b1352070d318187b41b088da3533692976f3f225Alan Wright * is inclusive - both the specified type(s) of files and normal files are
b1352070d318187b41b088da3533692976f3f225Alan Wright rc = smbsr_decode_vwv(sr, "wwl", &src_fqi->fq_sattr,
b1352070d318187b41b088da3533692976f3f225Alan Wright &src_fqi->fq_path.pn_path, &dst_fqi->fq_path.pn_path);
b1352070d318187b41b088da3533692976f3f225Alan Wright DTRACE_SMB_2(op__NtRename__start, smb_request_t *, sr,
b1352070d318187b41b088da3533692976f3f225Alan Wright DTRACE_SMB_1(op__NtRename__done, smb_request_t *, sr);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_fqi_t *src_fqi = &sr->arg.dirop.fqi;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_fqi_t *dst_fqi = &sr->arg.dirop.dst_fqi;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_t *src_pn = &src_fqi->fq_path;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_t *dst_pn = &dst_fqi->fq_path;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_init(sr, src_pn, src_pn->pn_path);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_init(sr, dst_pn, dst_pn->pn_path);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_pathname_validate(sr, src_pn) ||
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States !smb_pathname_validate(sr, dst_pn)) {
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States }
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States if (smb_contains_wildcards(src_pn->pn_path)) {
b1352070d318187b41b088da3533692976f3f225Alan Wright smbsr_error(sr, NT_STATUS_OBJECT_PATH_SYNTAX_BAD,
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross status = smb_common_rename(sr, src_fqi, dst_fqi);
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * smb_nt_transact_rename
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * Windows servers return SUCCESS without renaming file.
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * The only check required is to check that the handle (fid) is valid.
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brownsmb_nt_transact_rename(smb_request_t *sr, smb_xa_t *xa)
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown if (smb_mbc_decodef(&xa->req_param_mb, "w", &sr->smb_fid) != 0)