3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
24 */
25
26 #include <smbsrv/smb_kproto.h>
27 #include <smbsrv/winioctl.h>
28
29
30 static uint32_t smb_nt_trans_ioctl_noop(smb_request_t *, smb_xa_t *);
31 static uint32_t smb_nt_trans_ioctl_invalid_parm(smb_request_t *, smb_xa_t *);
32 static uint32_t smb_nt_trans_ioctl_set_sparse(smb_request_t *, smb_xa_t *);
33 static uint32_t smb_nt_trans_ioctl_query_alloc_ranges(smb_request_t *,
34 smb_xa_t *);
35 static uint32_t smb_nt_trans_ioctl_set_zero_data(smb_request_t *, smb_xa_t *);
36 static uint32_t smb_nt_trans_ioctl_enum_snaps(smb_request_t *, smb_xa_t *);
37
38 /*
39 * This table defines the list of FSCTL values for which we'll
40 * call a funtion to perform specific processing.
41 *
42 * Note: If support is added for FSCTL_SET_ZERO_DATA, it must break
43 * any oplocks on the file to none:
44 * smb_oplock_break(sr, node, SMB_OPLOCK_BREAK_TO_NONE);
45 */
46 static const struct {
47 uint32_t fcode;
48 uint32_t (*ioctl_func)(smb_request_t *sr, smb_xa_t *xa);
49 } ioctl_ret_tbl[] = {
50 { FSCTL_GET_OBJECT_ID, smb_nt_trans_ioctl_invalid_parm },
51 { FSCTL_QUERY_ALLOCATED_RANGES, smb_nt_trans_ioctl_query_alloc_ranges },
52 { FSCTL_SET_ZERO_DATA, smb_nt_trans_ioctl_set_zero_data },
53 { FSCTL_SRV_ENUMERATE_SNAPSHOTS, smb_nt_trans_ioctl_enum_snaps },
54 { FSCTL_SET_SPARSE, smb_nt_trans_ioctl_set_sparse },
55 { FSCTL_FIND_FILES_BY_SID, smb_nt_trans_ioctl_noop }
56 };
57
58 /*
59 * smb_nt_transact_ioctl
60 *
61 * This command allows device and file system control functions to be
62 * transferred transparently from client to server.
63 *
64 * Setup Words Encoding Description
205 attr.sa_mask = SMB_AT_DOSATTR;
206 }
207
208 if (attr.sa_mask != 0) {
209 rc = smb_node_setattr(sr, of->f_node, of->f_cr, of, &attr);
210 if (rc != 0) {
211 smbsr_errno(sr, rc);
212 smbsr_release_file(sr);
213 return (sr->smb_error.status);
214 }
215 }
216
217 smbsr_release_file(sr);
218 return (NT_STATUS_SUCCESS);
219 }
220
221 /*
222 * smb_nt_trans_ioctl_set_zero_data
223 *
224 * Check that the request is valid on the specified file.
225 * The implementation is a noop.
226 */
227 /* ARGSUSED */
228 static uint32_t
229 smb_nt_trans_ioctl_set_zero_data(smb_request_t *sr, smb_xa_t *xa)
230 {
231 smb_node_t *node;
232
233 if (SMB_TREE_IS_READONLY(sr))
234 return (NT_STATUS_ACCESS_DENIED);
235
236 if (STYPE_ISIPC(sr->tid_tree->t_res_type))
237 return (NT_STATUS_INVALID_PARAMETER);
238
239 smbsr_lookup_file(sr);
240 if (sr->fid_ofile == NULL)
241 return (NT_STATUS_INVALID_HANDLE);
242
243 if (!SMB_FTYPE_IS_DISK(sr->fid_ofile->f_ftype)) {
244 smbsr_release_file(sr);
245 return (NT_STATUS_INVALID_PARAMETER);
|
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
24 */
25
26 #include <smbsrv/smb_kproto.h>
27 #include <smb/winioctl.h>
28
29
30 static uint32_t smb_nt_trans_ioctl_noop(smb_request_t *, smb_xa_t *);
31 static uint32_t smb_nt_trans_ioctl_invalid_parm(smb_request_t *, smb_xa_t *);
32 static uint32_t smb_nt_trans_ioctl_set_sparse(smb_request_t *, smb_xa_t *);
33 static uint32_t smb_nt_trans_ioctl_query_alloc_ranges(smb_request_t *,
34 smb_xa_t *);
35 static uint32_t smb_nt_trans_ioctl_set_zero_data(smb_request_t *, smb_xa_t *);
36 static uint32_t smb_nt_trans_ioctl_enum_snaps(smb_request_t *, smb_xa_t *);
37
38 /*
39 * This table defines the list of FSCTL values for which we'll
40 * call a funtion to perform specific processing.
41 */
42 static const struct {
43 uint32_t fcode;
44 uint32_t (*ioctl_func)(smb_request_t *sr, smb_xa_t *xa);
45 } ioctl_ret_tbl[] = {
46 { FSCTL_GET_OBJECT_ID, smb_nt_trans_ioctl_invalid_parm },
47 { FSCTL_QUERY_ALLOCATED_RANGES, smb_nt_trans_ioctl_query_alloc_ranges },
48 { FSCTL_SET_ZERO_DATA, smb_nt_trans_ioctl_set_zero_data },
49 { FSCTL_SRV_ENUMERATE_SNAPSHOTS, smb_nt_trans_ioctl_enum_snaps },
50 { FSCTL_SET_SPARSE, smb_nt_trans_ioctl_set_sparse },
51 { FSCTL_FIND_FILES_BY_SID, smb_nt_trans_ioctl_noop }
52 };
53
54 /*
55 * smb_nt_transact_ioctl
56 *
57 * This command allows device and file system control functions to be
58 * transferred transparently from client to server.
59 *
60 * Setup Words Encoding Description
201 attr.sa_mask = SMB_AT_DOSATTR;
202 }
203
204 if (attr.sa_mask != 0) {
205 rc = smb_node_setattr(sr, of->f_node, of->f_cr, of, &attr);
206 if (rc != 0) {
207 smbsr_errno(sr, rc);
208 smbsr_release_file(sr);
209 return (sr->smb_error.status);
210 }
211 }
212
213 smbsr_release_file(sr);
214 return (NT_STATUS_SUCCESS);
215 }
216
217 /*
218 * smb_nt_trans_ioctl_set_zero_data
219 *
220 * Check that the request is valid on the specified file.
221 * The implementation is a noop. XXX - bug!
222 * XXX: We have this in the fsclt module now. Call that.
223 *
224 * Note: When support is added for FSCTL_SET_ZERO_DATA, it must
225 * break any oplocks on the file to none:
226 * (void) smb_oplock_break_WRITE(node, ofile);
227 */
228 /* ARGSUSED */
229 static uint32_t
230 smb_nt_trans_ioctl_set_zero_data(smb_request_t *sr, smb_xa_t *xa)
231 {
232 smb_node_t *node;
233
234 if (SMB_TREE_IS_READONLY(sr))
235 return (NT_STATUS_ACCESS_DENIED);
236
237 if (STYPE_ISIPC(sr->tid_tree->t_res_type))
238 return (NT_STATUS_INVALID_PARAMETER);
239
240 smbsr_lookup_file(sr);
241 if (sr->fid_ofile == NULL)
242 return (NT_STATUS_INVALID_HANDLE);
243
244 if (!SMB_FTYPE_IS_DISK(sr->fid_ofile->f_ftype)) {
245 smbsr_release_file(sr);
246 return (NT_STATUS_INVALID_PARAMETER);
|