xref: /onnv-gate/usr/src/uts/common/fs/smbsrv/smb_nt_transact_ioctl.c (revision 13082:81ec56bf6147)
15331Samw /*
25331Samw  * CDDL HEADER START
35331Samw  *
45331Samw  * The contents of this file are subject to the terms of the
55331Samw  * Common Development and Distribution License (the "License").
65331Samw  * You may not use this file except in compliance with the License.
75331Samw  *
85331Samw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95331Samw  * or http://www.opensolaris.org/os/licensing.
105331Samw  * See the License for the specific language governing permissions
115331Samw  * and limitations under the License.
125331Samw  *
135331Samw  * When distributing Covered Code, include this CDDL HEADER in each
145331Samw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155331Samw  * If applicable, add the following below this CDDL HEADER, with the
165331Samw  * fields enclosed by brackets "[]" replaced with your own identifying
175331Samw  * information: Portions Copyright [yyyy] [name of copyright owner]
185331Samw  *
195331Samw  * CDDL HEADER END
205331Samw  */
215331Samw /*
2212890SJoyce.McIntosh@Sun.COM  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
235331Samw  */
245331Samw 
2510966SJordan.Brown@Sun.COM #include <smbsrv/smb_kproto.h>
265331Samw #include <smbsrv/winioctl.h>
275331Samw 
2810504SKeyur.Desai@Sun.COM 
2910504SKeyur.Desai@Sun.COM static uint32_t smb_nt_trans_ioctl_noop(smb_request_t *, smb_xa_t *);
30*13082SJoyce.McIntosh@Sun.COM static uint32_t smb_nt_trans_ioctl_invalid_parm(smb_request_t *, smb_xa_t *);
31*13082SJoyce.McIntosh@Sun.COM static uint32_t smb_nt_trans_ioctl_set_sparse(smb_request_t *, smb_xa_t *);
32*13082SJoyce.McIntosh@Sun.COM static uint32_t smb_nt_trans_ioctl_query_alloc_ranges(smb_request_t *,
338474SJose.Borrego@Sun.COM     smb_xa_t *);
34*13082SJoyce.McIntosh@Sun.COM static uint32_t smb_nt_trans_ioctl_set_zero_data(smb_request_t *, smb_xa_t *);
355331Samw 
365331Samw /*
3710504SKeyur.Desai@Sun.COM  * This table defines the list of FSCTL values for which we'll
3810504SKeyur.Desai@Sun.COM  * call a funtion to perform specific processing.
3912890SJoyce.McIntosh@Sun.COM  *
4012890SJoyce.McIntosh@Sun.COM  * Note: If support is added for FSCTL_SET_ZERO_DATA, it must break
4112890SJoyce.McIntosh@Sun.COM  * any oplocks on the file to none:
4212890SJoyce.McIntosh@Sun.COM  *   smb_oplock_break(sr, node, SMB_OPLOCK_BREAK_TO_NONE);
435331Samw  */
445331Samw static struct {
455331Samw 	uint32_t fcode;
468474SJose.Borrego@Sun.COM 	uint32_t (*ioctl_func)(smb_request_t *sr, smb_xa_t *xa);
475331Samw } ioctl_ret_tbl[] = {
4810504SKeyur.Desai@Sun.COM 	{ FSCTL_GET_OBJECT_ID, smb_nt_trans_ioctl_invalid_parm },
49*13082SJoyce.McIntosh@Sun.COM 	{ FSCTL_QUERY_ALLOCATED_RANGES, smb_nt_trans_ioctl_query_alloc_ranges },
50*13082SJoyce.McIntosh@Sun.COM 	{ FSCTL_SET_ZERO_DATA, smb_nt_trans_ioctl_set_zero_data },
5110504SKeyur.Desai@Sun.COM 	{ FSCTL_SRV_ENUMERATE_SNAPSHOTS, smb_vss_ioctl_enumerate_snaps },
52*13082SJoyce.McIntosh@Sun.COM 	{ FSCTL_SET_SPARSE, smb_nt_trans_ioctl_set_sparse },
5311963SAfshin.Ardakani@Sun.COM 	{ FSCTL_FIND_FILES_BY_SID, smb_nt_trans_ioctl_noop }
545331Samw };
555331Samw 
565331Samw /*
575331Samw  * smb_nt_transact_ioctl
585331Samw  *
595331Samw  * This command allows device and file system control functions to be
6010504SKeyur.Desai@Sun.COM  * transferred transparently from client to server.
615331Samw  *
625331Samw  * Setup Words Encoding        Description
635331Samw  * =========================== =========================================
645331Samw  * ULONG FunctionCode;         NT device or file system control code
655331Samw  * USHORT Fid;                 Handle for io or fs control. Unless BIT0
665331Samw  *                             of ISFLAGS is set.
675331Samw  * BOOLEAN IsFsctl;            Indicates whether the command is a device
685331Samw  *                             control (FALSE) or a file system control
695331Samw  *                             (TRUE).
705331Samw  * UCHAR   IsFlags;            BIT0 - command is to be applied to share
715331Samw  *                             root handle. Share must be a DFS share.
725331Samw  *
735331Samw  * Data Block Encoding         Description
745331Samw  * =========================== =========================================
755331Samw  * Data[ TotalDataCount ]      Passed to the Fsctl or Ioctl
765331Samw  *
775331Samw  * Server Response             Description
785331Samw  * =========================== ==================================
795331Samw  * SetupCount                  1
805331Samw  * Setup[0]                    Length of information returned by
815331Samw  *                             io or fs control.
825331Samw  * DataCount                   Length of information returned by
835331Samw  *                             io or fs control.
845331Samw  * Data[ DataCount ]           The results of the io or fs control.
855331Samw  */
866030Sjb150015 smb_sdrc_t
smb_nt_transact_ioctl(smb_request_t * sr,smb_xa_t * xa)878474SJose.Borrego@Sun.COM smb_nt_transact_ioctl(smb_request_t *sr, smb_xa_t *xa)
885331Samw {
8910504SKeyur.Desai@Sun.COM 	uint32_t status = NT_STATUS_NOT_SUPPORTED;
905331Samw 	uint32_t fcode;
915331Samw 	unsigned char is_fsctl;
925331Samw 	unsigned char is_flags;
935331Samw 	int i;
945331Samw 
957052Samw 	if (smb_mbc_decodef(&xa->req_setup_mb, "lwbb",
96*13082SJoyce.McIntosh@Sun.COM 	    &fcode, &sr->smb_fid, &is_fsctl, &is_flags) != 0) {
975772Sas200622 		smbsr_error(sr, NT_STATUS_INVALID_PARAMETER, 0, 0);
986139Sjb150015 		return (SDRC_ERROR);
995331Samw 	}
1005331Samw 
10110504SKeyur.Desai@Sun.COM 	/*
10210504SKeyur.Desai@Sun.COM 	 * Invoke handler if specified, otherwise the default
10310504SKeyur.Desai@Sun.COM 	 * behavior is to return NT_STATUS_NOT_SUPPORTED
10410504SKeyur.Desai@Sun.COM 	 */
1056030Sjb150015 	for (i = 0; i < sizeof (ioctl_ret_tbl) / sizeof (ioctl_ret_tbl[0]);
1065331Samw 	    i++) {
1075331Samw 		if (ioctl_ret_tbl[i].fcode == fcode) {
1088474SJose.Borrego@Sun.COM 			status = ioctl_ret_tbl[i].ioctl_func(sr, xa);
1095331Samw 			break;
1105331Samw 		}
1115331Samw 	}
1125331Samw 
1136030Sjb150015 	if (status != NT_STATUS_SUCCESS) {
1145772Sas200622 		smbsr_error(sr, status, 0, 0);
1156139Sjb150015 		return (SDRC_ERROR);
1166030Sjb150015 	}
1175331Samw 
1187052Samw 	(void) smb_mbc_encodef(&xa->rep_param_mb, "l", 0);
1196139Sjb150015 	return (SDRC_SUCCESS);
1205331Samw }
1218474SJose.Borrego@Sun.COM 
1228474SJose.Borrego@Sun.COM /* ARGSUSED */
1238474SJose.Borrego@Sun.COM static uint32_t
smb_nt_trans_ioctl_noop(smb_request_t * sr,smb_xa_t * xa)12410504SKeyur.Desai@Sun.COM smb_nt_trans_ioctl_noop(smb_request_t *sr, smb_xa_t *xa)
12510504SKeyur.Desai@Sun.COM {
12610504SKeyur.Desai@Sun.COM 	return (NT_STATUS_SUCCESS);
12710504SKeyur.Desai@Sun.COM }
12810504SKeyur.Desai@Sun.COM 
12910504SKeyur.Desai@Sun.COM /* ARGSUSED */
13010504SKeyur.Desai@Sun.COM static uint32_t
smb_nt_trans_ioctl_invalid_parm(smb_request_t * sr,smb_xa_t * xa)1318474SJose.Borrego@Sun.COM smb_nt_trans_ioctl_invalid_parm(smb_request_t *sr, smb_xa_t *xa)
1328474SJose.Borrego@Sun.COM {
1338474SJose.Borrego@Sun.COM 	return (NT_STATUS_INVALID_PARAMETER);
1348474SJose.Borrego@Sun.COM }
135*13082SJoyce.McIntosh@Sun.COM 
136*13082SJoyce.McIntosh@Sun.COM /*
137*13082SJoyce.McIntosh@Sun.COM  * smb_nt_trans_ioctl_set_sparse
138*13082SJoyce.McIntosh@Sun.COM  *
139*13082SJoyce.McIntosh@Sun.COM  * There may, or may not be a data block in this request.
140*13082SJoyce.McIntosh@Sun.COM  * If there IS a data block, the first byte is a boolean
141*13082SJoyce.McIntosh@Sun.COM  * specifying whether to set (non zero) or clear (zero)
142*13082SJoyce.McIntosh@Sun.COM  * the sparse attribute of the file.
143*13082SJoyce.McIntosh@Sun.COM  * If there is no data block, this indicates a request to
144*13082SJoyce.McIntosh@Sun.COM  * set the sparse attribute.
145*13082SJoyce.McIntosh@Sun.COM  */
146*13082SJoyce.McIntosh@Sun.COM static uint32_t
smb_nt_trans_ioctl_set_sparse(smb_request_t * sr,smb_xa_t * xa)147*13082SJoyce.McIntosh@Sun.COM smb_nt_trans_ioctl_set_sparse(smb_request_t *sr, smb_xa_t *xa)
148*13082SJoyce.McIntosh@Sun.COM {
149*13082SJoyce.McIntosh@Sun.COM 	int		rc = 0;
150*13082SJoyce.McIntosh@Sun.COM 	uint8_t		set = 1;
151*13082SJoyce.McIntosh@Sun.COM 	smb_node_t	*node;
152*13082SJoyce.McIntosh@Sun.COM 	smb_attr_t	attr;
153*13082SJoyce.McIntosh@Sun.COM 
154*13082SJoyce.McIntosh@Sun.COM 	if (SMB_TREE_IS_READONLY(sr))
155*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_ACCESS_DENIED);
156*13082SJoyce.McIntosh@Sun.COM 
157*13082SJoyce.McIntosh@Sun.COM 	if (STYPE_ISIPC(sr->tid_tree->t_res_type))
158*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_INVALID_PARAMETER);
159*13082SJoyce.McIntosh@Sun.COM 
160*13082SJoyce.McIntosh@Sun.COM 	smbsr_lookup_file(sr);
161*13082SJoyce.McIntosh@Sun.COM 	if (sr->fid_ofile == NULL)
162*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_INVALID_HANDLE);
163*13082SJoyce.McIntosh@Sun.COM 
164*13082SJoyce.McIntosh@Sun.COM 	if (!SMB_FTYPE_IS_DISK(sr->fid_ofile->f_ftype)) {
165*13082SJoyce.McIntosh@Sun.COM 		smbsr_release_file(sr);
166*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_INVALID_PARAMETER);
167*13082SJoyce.McIntosh@Sun.COM 	}
168*13082SJoyce.McIntosh@Sun.COM 
169*13082SJoyce.McIntosh@Sun.COM 	node = sr->fid_ofile->f_node;
170*13082SJoyce.McIntosh@Sun.COM 	if (smb_node_is_dir(node)) {
171*13082SJoyce.McIntosh@Sun.COM 		smbsr_release_file(sr);
172*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_INVALID_PARAMETER);
173*13082SJoyce.McIntosh@Sun.COM 	}
174*13082SJoyce.McIntosh@Sun.COM 
175*13082SJoyce.McIntosh@Sun.COM 	if (smbsr_decode_data_avail(sr)) {
176*13082SJoyce.McIntosh@Sun.COM 		if (smb_mbc_decodef(&xa->req_data_mb, "b", &set) != 0) {
177*13082SJoyce.McIntosh@Sun.COM 			smbsr_release_file(sr);
178*13082SJoyce.McIntosh@Sun.COM 			return (sr->smb_error.status);
179*13082SJoyce.McIntosh@Sun.COM 		}
180*13082SJoyce.McIntosh@Sun.COM 	}
181*13082SJoyce.McIntosh@Sun.COM 
182*13082SJoyce.McIntosh@Sun.COM 	bzero(&attr, sizeof (smb_attr_t));
183*13082SJoyce.McIntosh@Sun.COM 	attr.sa_mask = SMB_AT_DOSATTR;
184*13082SJoyce.McIntosh@Sun.COM 	if ((rc = smb_node_getattr(sr, node, &attr)) != 0) {
185*13082SJoyce.McIntosh@Sun.COM 		smbsr_errno(sr, rc);
186*13082SJoyce.McIntosh@Sun.COM 		smbsr_release_file(sr);
187*13082SJoyce.McIntosh@Sun.COM 		return (sr->smb_error.status);
188*13082SJoyce.McIntosh@Sun.COM 	}
189*13082SJoyce.McIntosh@Sun.COM 
190*13082SJoyce.McIntosh@Sun.COM 	attr.sa_mask = 0;
191*13082SJoyce.McIntosh@Sun.COM 	if ((set == 0) &&
192*13082SJoyce.McIntosh@Sun.COM 	    (attr.sa_dosattr & FILE_ATTRIBUTE_SPARSE_FILE)) {
193*13082SJoyce.McIntosh@Sun.COM 		attr.sa_dosattr &= ~FILE_ATTRIBUTE_SPARSE_FILE;
194*13082SJoyce.McIntosh@Sun.COM 		attr.sa_mask = SMB_AT_DOSATTR;
195*13082SJoyce.McIntosh@Sun.COM 	} else if ((set != 0) &&
196*13082SJoyce.McIntosh@Sun.COM 	    !(attr.sa_dosattr & FILE_ATTRIBUTE_SPARSE_FILE)) {
197*13082SJoyce.McIntosh@Sun.COM 		attr.sa_dosattr |= FILE_ATTRIBUTE_SPARSE_FILE;
198*13082SJoyce.McIntosh@Sun.COM 		attr.sa_mask = SMB_AT_DOSATTR;
199*13082SJoyce.McIntosh@Sun.COM 	}
200*13082SJoyce.McIntosh@Sun.COM 
201*13082SJoyce.McIntosh@Sun.COM 	if (attr.sa_mask != 0) {
202*13082SJoyce.McIntosh@Sun.COM 		rc = smb_node_setattr(sr, node, sr->user_cr, NULL, &attr);
203*13082SJoyce.McIntosh@Sun.COM 		if (rc != 0) {
204*13082SJoyce.McIntosh@Sun.COM 			smbsr_errno(sr, rc);
205*13082SJoyce.McIntosh@Sun.COM 			smbsr_release_file(sr);
206*13082SJoyce.McIntosh@Sun.COM 			return (sr->smb_error.status);
207*13082SJoyce.McIntosh@Sun.COM 		}
208*13082SJoyce.McIntosh@Sun.COM 	}
209*13082SJoyce.McIntosh@Sun.COM 
210*13082SJoyce.McIntosh@Sun.COM 	smbsr_release_file(sr);
211*13082SJoyce.McIntosh@Sun.COM 	return (NT_STATUS_SUCCESS);
212*13082SJoyce.McIntosh@Sun.COM }
213*13082SJoyce.McIntosh@Sun.COM 
214*13082SJoyce.McIntosh@Sun.COM /*
215*13082SJoyce.McIntosh@Sun.COM  * smb_nt_trans_ioctl_set_zero_data
216*13082SJoyce.McIntosh@Sun.COM  *
217*13082SJoyce.McIntosh@Sun.COM  * Check that the request is valid on the specified file.
218*13082SJoyce.McIntosh@Sun.COM  * The implementation is a noop.
219*13082SJoyce.McIntosh@Sun.COM  */
220*13082SJoyce.McIntosh@Sun.COM /* ARGSUSED */
221*13082SJoyce.McIntosh@Sun.COM static uint32_t
smb_nt_trans_ioctl_set_zero_data(smb_request_t * sr,smb_xa_t * xa)222*13082SJoyce.McIntosh@Sun.COM smb_nt_trans_ioctl_set_zero_data(smb_request_t *sr, smb_xa_t *xa)
223*13082SJoyce.McIntosh@Sun.COM {
224*13082SJoyce.McIntosh@Sun.COM 	smb_node_t *node;
225*13082SJoyce.McIntosh@Sun.COM 
226*13082SJoyce.McIntosh@Sun.COM 	if (SMB_TREE_IS_READONLY(sr))
227*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_ACCESS_DENIED);
228*13082SJoyce.McIntosh@Sun.COM 
229*13082SJoyce.McIntosh@Sun.COM 	if (STYPE_ISIPC(sr->tid_tree->t_res_type))
230*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_INVALID_PARAMETER);
231*13082SJoyce.McIntosh@Sun.COM 
232*13082SJoyce.McIntosh@Sun.COM 	smbsr_lookup_file(sr);
233*13082SJoyce.McIntosh@Sun.COM 	if (sr->fid_ofile == NULL)
234*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_INVALID_HANDLE);
235*13082SJoyce.McIntosh@Sun.COM 
236*13082SJoyce.McIntosh@Sun.COM 	if (!SMB_FTYPE_IS_DISK(sr->fid_ofile->f_ftype)) {
237*13082SJoyce.McIntosh@Sun.COM 		smbsr_release_file(sr);
238*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_INVALID_PARAMETER);
239*13082SJoyce.McIntosh@Sun.COM 	}
240*13082SJoyce.McIntosh@Sun.COM 
241*13082SJoyce.McIntosh@Sun.COM 	node = sr->fid_ofile->f_node;
242*13082SJoyce.McIntosh@Sun.COM 	if (smb_node_is_dir(node)) {
243*13082SJoyce.McIntosh@Sun.COM 		smbsr_release_file(sr);
244*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_INVALID_PARAMETER);
245*13082SJoyce.McIntosh@Sun.COM 	}
246*13082SJoyce.McIntosh@Sun.COM 
247*13082SJoyce.McIntosh@Sun.COM 	smbsr_release_file(sr);
248*13082SJoyce.McIntosh@Sun.COM 	return (NT_STATUS_SUCCESS);
249*13082SJoyce.McIntosh@Sun.COM }
250*13082SJoyce.McIntosh@Sun.COM 
251*13082SJoyce.McIntosh@Sun.COM /*
252*13082SJoyce.McIntosh@Sun.COM  * smb_nt_trans_ioctl_query_alloc_ranges
253*13082SJoyce.McIntosh@Sun.COM  *
254*13082SJoyce.McIntosh@Sun.COM  * Responds with either:
255*13082SJoyce.McIntosh@Sun.COM  * - no data if the file is zero size
256*13082SJoyce.McIntosh@Sun.COM  * - a single range containing the starting point and length requested
257*13082SJoyce.McIntosh@Sun.COM  */
258*13082SJoyce.McIntosh@Sun.COM static uint32_t
smb_nt_trans_ioctl_query_alloc_ranges(smb_request_t * sr,smb_xa_t * xa)259*13082SJoyce.McIntosh@Sun.COM smb_nt_trans_ioctl_query_alloc_ranges(smb_request_t *sr, smb_xa_t *xa)
260*13082SJoyce.McIntosh@Sun.COM {
261*13082SJoyce.McIntosh@Sun.COM 	int		rc;
262*13082SJoyce.McIntosh@Sun.COM 	uint64_t	offset, len;
263*13082SJoyce.McIntosh@Sun.COM 	smb_node_t	*node;
264*13082SJoyce.McIntosh@Sun.COM 	smb_attr_t	attr;
265*13082SJoyce.McIntosh@Sun.COM 
266*13082SJoyce.McIntosh@Sun.COM 	if (STYPE_ISIPC(sr->tid_tree->t_res_type))
267*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_INVALID_PARAMETER);
268*13082SJoyce.McIntosh@Sun.COM 
269*13082SJoyce.McIntosh@Sun.COM 	smbsr_lookup_file(sr);
270*13082SJoyce.McIntosh@Sun.COM 	if (sr->fid_ofile == NULL)
271*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_INVALID_HANDLE);
272*13082SJoyce.McIntosh@Sun.COM 
273*13082SJoyce.McIntosh@Sun.COM 	if (!SMB_FTYPE_IS_DISK(sr->fid_ofile->f_ftype)) {
274*13082SJoyce.McIntosh@Sun.COM 		smbsr_release_file(sr);
275*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_INVALID_PARAMETER);
276*13082SJoyce.McIntosh@Sun.COM 	}
277*13082SJoyce.McIntosh@Sun.COM 
278*13082SJoyce.McIntosh@Sun.COM 	node = sr->fid_ofile->f_node;
279*13082SJoyce.McIntosh@Sun.COM 	if (smb_node_is_dir(node)) {
280*13082SJoyce.McIntosh@Sun.COM 		smbsr_release_file(sr);
281*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_INVALID_PARAMETER);
282*13082SJoyce.McIntosh@Sun.COM 	}
283*13082SJoyce.McIntosh@Sun.COM 
284*13082SJoyce.McIntosh@Sun.COM 	/* If zero size file don't return any data */
285*13082SJoyce.McIntosh@Sun.COM 	bzero(&attr, sizeof (smb_attr_t));
286*13082SJoyce.McIntosh@Sun.COM 	attr.sa_mask = SMB_AT_SIZE;
287*13082SJoyce.McIntosh@Sun.COM 	if ((rc = smb_node_getattr(sr, node, &attr)) != 0) {
288*13082SJoyce.McIntosh@Sun.COM 		smbsr_errno(sr, rc);
289*13082SJoyce.McIntosh@Sun.COM 		smbsr_release_file(sr);
290*13082SJoyce.McIntosh@Sun.COM 		return (sr->smb_error.status);
291*13082SJoyce.McIntosh@Sun.COM 	}
292*13082SJoyce.McIntosh@Sun.COM 
293*13082SJoyce.McIntosh@Sun.COM 	if (attr.sa_vattr.va_size == 0) {
294*13082SJoyce.McIntosh@Sun.COM 		smbsr_release_file(sr);
295*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_SUCCESS);
296*13082SJoyce.McIntosh@Sun.COM 	}
297*13082SJoyce.McIntosh@Sun.COM 
298*13082SJoyce.McIntosh@Sun.COM 	if (smb_mbc_decodef(&xa->req_data_mb, "qq", &offset, &len) != 0) {
299*13082SJoyce.McIntosh@Sun.COM 		smbsr_release_file(sr);
300*13082SJoyce.McIntosh@Sun.COM 		return (sr->smb_error.status);
301*13082SJoyce.McIntosh@Sun.COM 	}
302*13082SJoyce.McIntosh@Sun.COM 
303*13082SJoyce.McIntosh@Sun.COM 	/*
304*13082SJoyce.McIntosh@Sun.COM 	 * Return a single range regardless of whether the file
305*13082SJoyce.McIntosh@Sun.COM 	 * is sparse or not.
306*13082SJoyce.McIntosh@Sun.COM 	 */
307*13082SJoyce.McIntosh@Sun.COM 	if (MBC_ROOM_FOR(&xa->rep_data_mb, 16) == 0) {
308*13082SJoyce.McIntosh@Sun.COM 		smbsr_release_file(sr);
309*13082SJoyce.McIntosh@Sun.COM 		return (NT_STATUS_BUFFER_TOO_SMALL);
310*13082SJoyce.McIntosh@Sun.COM 	}
311*13082SJoyce.McIntosh@Sun.COM 
312*13082SJoyce.McIntosh@Sun.COM 	if (smb_mbc_encodef(&xa->rep_data_mb, "qq", offset, len) != 0) {
313*13082SJoyce.McIntosh@Sun.COM 		smbsr_release_file(sr);
314*13082SJoyce.McIntosh@Sun.COM 		return (sr->smb_error.status);
315*13082SJoyce.McIntosh@Sun.COM 	}
316*13082SJoyce.McIntosh@Sun.COM 
317*13082SJoyce.McIntosh@Sun.COM 	smbsr_release_file(sr);
318*13082SJoyce.McIntosh@Sun.COM 	return (NT_STATUS_SUCCESS);
319*13082SJoyce.McIntosh@Sun.COM }
320