Print this page
Build provider 3rd arg from smb_request_t
hacking...
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/fs/smbsrv/smb_rename.c
+++ new/usr/src/uts/common/fs/smbsrv/smb_rename.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25
26 26 #include <sys/synch.h>
27 27 #include <smbsrv/smb_kproto.h>
28 28 #include <smbsrv/smb_fsops.h>
29 29 #include <sys/nbmlock.h>
30 30
31 31 /*
32 32 * NT_RENAME InformationLevels:
33 33 *
34 34 * SMB_NT_RENAME_MOVE_CLUSTER_INFO Server returns invalid parameter.
35 35 * SMB_NT_RENAME_SET_LINK_INFO Create a hard link to a file.
36 36 * SMB_NT_RENAME_RENAME_FILE In-place rename of a file.
37 37 * SMB_NT_RENAME_MOVE_FILE Move (rename) a file.
38 38 */
39 39 #define SMB_NT_RENAME_MOVE_CLUSTER_INFO 0x0102
40 40 #define SMB_NT_RENAME_SET_LINK_INFO 0x0103
41 41 #define SMB_NT_RENAME_RENAME_FILE 0x0104
42 42 #define SMB_NT_RENAME_MOVE_FILE 0x0105
43 43
44 44 /*
45 45 * smb_com_rename
46 46 *
47 47 * Rename a file. Files OldFileName must exist and NewFileName must not.
48 48 * Both pathnames must be relative to the Tid specified in the request.
49 49 * Open files may be renamed.
50 50 *
51 51 * Multiple files may be renamed in response to a single request as Rename
52 52 * File supports wildcards in the file name (last component of the path).
53 53 * NOTE: we don't support rename with wildcards.
54 54 *
55 55 * SearchAttributes indicates the attributes that the target file(s) must
56 56 * have. If SearchAttributes is zero then only normal files are renamed.
57 57 * If the system file or hidden attributes are specified then the rename
58 58 * is inclusive - both the specified type(s) of files and normal files are
59 59 * renamed.
60 60 */
61 61 smb_sdrc_t
62 62 smb_pre_rename(smb_request_t *sr)
63 63 {
64 64 smb_fqi_t *src_fqi = &sr->arg.dirop.fqi;
↓ open down ↓ |
64 lines elided |
↑ open up ↑ |
65 65 smb_fqi_t *dst_fqi = &sr->arg.dirop.dst_fqi;
66 66 int rc;
67 67
68 68 if ((rc = smbsr_decode_vwv(sr, "w", &src_fqi->fq_sattr)) == 0) {
69 69 rc = smbsr_decode_data(sr, "%SS", sr, &src_fqi->fq_path.pn_path,
70 70 &dst_fqi->fq_path.pn_path);
71 71
72 72 dst_fqi->fq_sattr = 0;
73 73 }
74 74
75 - DTRACE_SMB_2(op__Rename__start, smb_request_t *, sr,
76 - struct dirop *, &sr->arg.dirop);
75 + DTRACE_SMB_1(op__Rename__start, smb_request_t *, sr); /* arg.dirop */
77 76
78 77 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
79 78 }
80 79
81 80 void
82 81 smb_post_rename(smb_request_t *sr)
83 82 {
84 83 DTRACE_SMB_1(op__Rename__done, smb_request_t *, sr);
85 84 }
86 85
87 86 smb_sdrc_t
88 87 smb_com_rename(smb_request_t *sr)
89 88 {
90 89 smb_fqi_t *src_fqi = &sr->arg.dirop.fqi;
91 90 smb_fqi_t *dst_fqi = &sr->arg.dirop.dst_fqi;
92 91 smb_pathname_t *src_pn = &src_fqi->fq_path;
93 92 smb_pathname_t *dst_pn = &dst_fqi->fq_path;
94 93 uint32_t status;
95 94
96 95 if (!STYPE_ISDSK(sr->tid_tree->t_res_type)) {
97 96 smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
98 97 ERRDOS, ERROR_ACCESS_DENIED);
99 98 return (SDRC_ERROR);
100 99 }
101 100
102 101 smb_pathname_init(sr, src_pn, src_pn->pn_path);
103 102 smb_pathname_init(sr, dst_pn, dst_pn->pn_path);
104 103 if (!smb_pathname_validate(sr, src_pn) ||
105 104 !smb_pathname_validate(sr, dst_pn)) {
106 105 return (SDRC_ERROR);
107 106 }
108 107
109 108 status = smb_common_rename(sr, src_fqi, dst_fqi);
110 109 if (status != 0) {
111 110 smbsr_error(sr, status, 0, 0);
112 111 return (SDRC_ERROR);
113 112 }
114 113
115 114 (void) smbsr_encode_empty_result(sr);
116 115 return (SDRC_SUCCESS);
117 116 }
118 117
119 118 /*
120 119 * smb_com_nt_rename
121 120 *
122 121 * Rename a file. Files OldFileName must exist and NewFileName must not.
123 122 * Both pathnames must be relative to the Tid specified in the request.
124 123 * Open files may be renamed.
125 124 *
126 125 * SearchAttributes indicates the attributes that the target file(s) must
127 126 * have. If SearchAttributes is zero then only normal files are renamed.
128 127 * If the system file or hidden attributes are specified then the rename
129 128 * is inclusive - both the specified type(s) of files and normal files are
130 129 * renamed.
131 130 */
132 131 smb_sdrc_t
133 132 smb_pre_nt_rename(smb_request_t *sr)
134 133 {
135 134 smb_fqi_t *src_fqi = &sr->arg.dirop.fqi;
136 135 smb_fqi_t *dst_fqi = &sr->arg.dirop.dst_fqi;
137 136 uint32_t clusters;
138 137 int rc;
↓ open down ↓ |
52 lines elided |
↑ open up ↑ |
139 138
140 139 rc = smbsr_decode_vwv(sr, "wwl", &src_fqi->fq_sattr,
141 140 &sr->arg.dirop.info_level, &clusters);
142 141 if (rc == 0) {
143 142 rc = smbsr_decode_data(sr, "%SS", sr,
144 143 &src_fqi->fq_path.pn_path, &dst_fqi->fq_path.pn_path);
145 144
146 145 dst_fqi->fq_sattr = 0;
147 146 }
148 147
149 - DTRACE_SMB_2(op__NtRename__start, smb_request_t *, sr,
150 - struct dirop *, &sr->arg.dirop);
148 + DTRACE_SMB_1(op__NtRename__start, smb_request_t *, sr); /* arg.dirop */
151 149
152 150 return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
153 151 }
154 152
155 153 void
156 154 smb_post_nt_rename(smb_request_t *sr)
157 155 {
158 156 DTRACE_SMB_1(op__NtRename__done, smb_request_t *, sr);
159 157 }
160 158
161 159 smb_sdrc_t
162 160 smb_com_nt_rename(smb_request_t *sr)
163 161 {
164 162 smb_fqi_t *src_fqi = &sr->arg.dirop.fqi;
165 163 smb_fqi_t *dst_fqi = &sr->arg.dirop.dst_fqi;
166 164 smb_pathname_t *src_pn = &src_fqi->fq_path;
167 165 smb_pathname_t *dst_pn = &dst_fqi->fq_path;
168 166 uint32_t status;
169 167
170 168 if (!STYPE_ISDSK(sr->tid_tree->t_res_type)) {
171 169 smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
172 170 ERRDOS, ERROR_ACCESS_DENIED);
173 171 return (SDRC_ERROR);
174 172 }
175 173
176 174 smb_pathname_init(sr, src_pn, src_pn->pn_path);
177 175 smb_pathname_init(sr, dst_pn, dst_pn->pn_path);
178 176 if (!smb_pathname_validate(sr, src_pn) ||
179 177 !smb_pathname_validate(sr, dst_pn)) {
180 178 return (SDRC_ERROR);
181 179 }
182 180
183 181 if (smb_contains_wildcards(src_pn->pn_path)) {
184 182 smbsr_error(sr, NT_STATUS_OBJECT_PATH_SYNTAX_BAD,
185 183 ERRDOS, ERROR_BAD_PATHNAME);
186 184 return (SDRC_ERROR);
187 185 }
188 186
189 187 switch (sr->arg.dirop.info_level) {
190 188 case SMB_NT_RENAME_SET_LINK_INFO:
191 189 status = smb_make_link(sr, src_fqi, dst_fqi);
192 190 break;
193 191 case SMB_NT_RENAME_RENAME_FILE:
194 192 case SMB_NT_RENAME_MOVE_FILE:
195 193 status = smb_common_rename(sr, src_fqi, dst_fqi);
196 194 break;
197 195 case SMB_NT_RENAME_MOVE_CLUSTER_INFO:
198 196 status = NT_STATUS_INVALID_PARAMETER;
199 197 break;
200 198 default:
201 199 status = NT_STATUS_ACCESS_DENIED;
202 200 break;
203 201 }
204 202
205 203 if (status != 0) {
206 204 smbsr_error(sr, status, 0, 0);
207 205 return (SDRC_ERROR);
208 206 }
209 207
210 208 (void) smbsr_encode_empty_result(sr);
211 209 return (SDRC_SUCCESS);
212 210 }
213 211
214 212 /*
215 213 * smb_nt_transact_rename
216 214 *
217 215 * Windows servers return SUCCESS without renaming file.
218 216 * The only check required is to check that the handle (fid) is valid.
219 217 */
220 218 smb_sdrc_t
221 219 smb_nt_transact_rename(smb_request_t *sr, smb_xa_t *xa)
222 220 {
223 221 if (smb_mbc_decodef(&xa->req_param_mb, "w", &sr->smb_fid) != 0)
224 222 return (SDRC_ERROR);
225 223
226 224 smbsr_lookup_file(sr);
227 225 if (sr->fid_ofile == NULL) {
228 226 smbsr_error(sr, NT_STATUS_INVALID_HANDLE, ERRDOS, ERRbadfid);
229 227 return (SDRC_ERROR);
230 228 }
231 229 smbsr_release_file(sr);
232 230
233 231 return (SDRC_SUCCESS);
234 232 }
↓ open down ↓ |
74 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX