2 Unix SMB/CIFS implementation.
5 Copyright (C) Stefan Metzmacher 2009
6 Copyright (C) David Disseldorp 2013-2015
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "smbd/smbd.h"
24 #include "smbd/globals.h"
25 #include "../libcli/smb/smb_common.h"
26 #include "../libcli/security/security.h"
27 #include "../lib/util/tevent_ntstatus.h"
28 #include "rpc_server/srv_pipe_hnd.h"
29 #include "include/ntioctl.h"
30 #include "../librpc/ndr/libndr.h"
31 #include "librpc/gen_ndr/ndr_ioctl.h"
32 #include "smb2_ioctl_private.h"
35 * XXX this may reduce dup_extents->byte_count so that it's less than the
38 static NTSTATUS fsctl_dup_extents_check_lengths(struct files_struct *src_fsp,
39 struct files_struct *dst_fsp,
40 struct fsctl_dup_extents_to_file *dup_extents)
44 if ((dup_extents->source_off + dup_extents->byte_count
45 < dup_extents->source_off)
46 || (dup_extents->target_off + dup_extents->byte_count
47 < dup_extents->target_off)) {
48 return NT_STATUS_INVALID_PARAMETER; /* wrap */
51 status = vfs_stat_fsp(src_fsp);
52 if (!NT_STATUS_IS_OK(status)) {
57 * XXX vfs_btrfs and vfs_default have size checks in the copychunk
58 * handler, as this needs to be rechecked after the src has potentially
59 * been extended by a previous chunk in the compound copychunk req.
61 if (src_fsp->fsp_name->st.st_ex_size
62 < dup_extents->source_off + dup_extents->byte_count) {
63 DEBUG(2, ("dup_extents req exceeds src size\n"));
64 return NT_STATUS_NOT_SUPPORTED;
67 status = vfs_stat_fsp(dst_fsp);
68 if (!NT_STATUS_IS_OK(status)) {
72 if (dst_fsp->fsp_name->st.st_ex_size
73 < dup_extents->target_off + dup_extents->byte_count) {
75 if (dst_fsp->fsp_name->st.st_ex_size - dup_extents->target_off
76 > dst_fsp->fsp_name->st.st_ex_size) {
77 return NT_STATUS_INVALID_PARAMETER; /* wrap */
81 * this server behaviour is pretty hairy, but we need to match
84 DEBUG(2, ("dup_extents req exceeds target size, capping\n"));
85 dup_extents->byte_count = dst_fsp->fsp_name->st.st_ex_size
86 - dup_extents->target_off;
92 static NTSTATUS fsctl_dup_extents_check_overlap(struct files_struct *src_fsp,
93 struct files_struct *dst_fsp,
94 struct fsctl_dup_extents_to_file *dup_extents)
96 uint64_t src_off_last;
97 uint64_t tgt_off_last;
99 if (!file_id_equal(&src_fsp->file_id, &dst_fsp->file_id)) {
100 /* src and dest refer to different files */
104 if (dup_extents->byte_count == 0) {
105 /* no range to overlap */
110 * [MS-FSCC] 2.3.8 FSCTL_DUPLICATE_EXTENTS_TO_FILE Reply
111 * STATUS_NOT_SUPPORTED:
112 * The source and target destination ranges overlap on the same file.
115 src_off_last = dup_extents->source_off + dup_extents->byte_count - 1;
116 if ((dup_extents->target_off >= dup_extents->source_off)
117 && (dup_extents->target_off <= src_off_last)) {
122 return NT_STATUS_NOT_SUPPORTED;
126 tgt_off_last = dup_extents->target_off + dup_extents->byte_count - 1;
127 if ((tgt_off_last >= dup_extents->source_off)
128 && (tgt_off_last <= src_off_last)) {
133 return NT_STATUS_NOT_SUPPORTED;
139 static NTSTATUS fsctl_dup_extents_check_sparse(struct files_struct *src_fsp,
140 struct files_struct *dst_fsp)
143 * 2.3.8 FSCTL_DUPLICATE_EXTENTS_TO_FILE Reply...
144 * STATUS_NOT_SUPPORTED: Target file is sparse, while source
145 * is a non-sparse file.
147 * WS2016 has the following behaviour (MS are in the process of fixing
149 * STATUS_NOT_SUPPORTED is returned if the source is sparse, while the
150 * target is non-sparse. However, if target is sparse while the source
151 * is non-sparse, then FSCTL_DUPLICATE_EXTENTS_TO_FILE completes
154 if ((src_fsp->is_sparse) && (!dst_fsp->is_sparse)) {
155 return NT_STATUS_NOT_SUPPORTED;
161 struct fsctl_dup_extents_state {
162 struct tevent_context *ev;
163 struct connection_struct *conn;
164 struct fsctl_dup_extents_to_file dup_extents;
167 static void fsctl_dup_extents_vfs_done(struct tevent_req *subreq);
169 static struct tevent_req *fsctl_dup_extents_send(TALLOC_CTX *mem_ctx,
170 struct tevent_context *ev,
171 struct files_struct *dst_fsp,
173 struct smbd_smb2_request *smb2req)
175 struct tevent_req *req = NULL;
176 struct tevent_req *subreq = NULL;
177 struct fsctl_dup_extents_state *state = NULL;
178 uint64_t src_fid_persistent = 0;
179 uint64_t src_fid_volatile = 0;
180 struct files_struct *src_fsp = NULL;
184 req = tevent_req_create(mem_ctx, &state,
185 struct fsctl_dup_extents_state);
189 *state = (struct fsctl_dup_extents_state) {
190 .conn = dst_fsp->conn,
194 if (dst_fsp == NULL) {
195 tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
196 return tevent_req_post(req, ev);
199 if ((dst_fsp->conn->fs_capabilities
200 & FILE_SUPPORTS_BLOCK_REFCOUNTING) == 0) {
201 DBG_INFO("FS does not advertise block refcounting support\n");
202 tevent_req_nterror(req, NT_STATUS_INVALID_DEVICE_REQUEST);
203 return tevent_req_post(req, ev);
206 ndr_ret = ndr_pull_struct_blob(in_input, state, &state->dup_extents,
207 (ndr_pull_flags_fn_t)ndr_pull_fsctl_dup_extents_to_file);
208 if (ndr_ret != NDR_ERR_SUCCESS) {
209 DBG_ERR("failed to unmarshall dup extents to file req\n");
210 tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
211 return tevent_req_post(req, ev);
214 src_fid_persistent = BVAL(state->dup_extents.source_fid, 0);
215 src_fid_volatile = BVAL(state->dup_extents.source_fid, 8);
216 src_fsp = file_fsp_get(smb2req, src_fid_persistent, src_fid_volatile);
217 if ((src_fsp == NULL)
218 || (src_fsp->file_id.devid != dst_fsp->file_id.devid)) {
220 * [MS-FSCC] 2.3.8 FSCTL_DUPLICATE_EXTENTS_TO_FILE Reply
221 * STATUS_INVALID_PARAMETER:
222 * The FileHandle parameter is either invalid or does not
223 * represent a handle to an opened file on the same volume.
225 * Windows Server responds with NT_STATUS_INVALID_HANDLE instead
226 * of STATUS_INVALID_PARAMETER here, despite the above spec.
228 DBG_ERR("invalid src_fsp for dup_extents\n");
229 tevent_req_nterror(req, NT_STATUS_INVALID_HANDLE);
230 return tevent_req_post(req, ev);
233 status = fsctl_dup_extents_check_lengths(src_fsp, dst_fsp,
234 &state->dup_extents);
235 if (!NT_STATUS_IS_OK(status)) {
236 tevent_req_nterror(req, status);
237 return tevent_req_post(req, ev);
240 if (state->dup_extents.byte_count == 0) {
241 DBG_ERR("skipping zero length dup extents\n");
242 tevent_req_done(req);
243 return tevent_req_post(req, ev);
246 status = fsctl_dup_extents_check_overlap(src_fsp, dst_fsp,
247 &state->dup_extents);
248 if (!NT_STATUS_IS_OK(status)) {
249 tevent_req_nterror(req, status);
250 return tevent_req_post(req, ev);
253 status = fsctl_dup_extents_check_sparse(src_fsp, dst_fsp);
254 if (!NT_STATUS_IS_OK(status)) {
255 tevent_req_nterror(req, status);
256 return tevent_req_post(req, ev);
259 /* tell the VFS to ignore locks across the clone, matching ReFS */
260 subreq = SMB_VFS_COPY_CHUNK_SEND(dst_fsp->conn, state, ev,
261 src_fsp, state->dup_extents.source_off,
262 dst_fsp, state->dup_extents.target_off,
263 state->dup_extents.byte_count,
264 VFS_COPY_CHUNK_FL_MUST_CLONE
265 | VFS_COPY_CHUNK_FL_IGNORE_LOCKS);
266 if (tevent_req_nomem(subreq, req)) {
267 return tevent_req_post(req, ev);
270 tevent_req_set_callback(subreq, fsctl_dup_extents_vfs_done, req);
275 static void fsctl_dup_extents_vfs_done(struct tevent_req *subreq)
277 struct tevent_req *req = tevent_req_callback_data(
278 subreq, struct tevent_req);
279 struct fsctl_dup_extents_state *state = tevent_req_data(
280 req, struct fsctl_dup_extents_state);
284 status = SMB_VFS_COPY_CHUNK_RECV(state->conn, subreq, &nb_chunk);
286 if (tevent_req_nterror(req, status)) {
290 if (nb_chunk != state->dup_extents.byte_count) {
291 tevent_req_nterror(req, NT_STATUS_IO_DEVICE_ERROR);
295 tevent_req_done(req);
298 static NTSTATUS fsctl_dup_extents_recv(struct tevent_req *req)
300 return tevent_req_simple_recv_ntstatus(req);
303 static NTSTATUS fsctl_get_cmprn(TALLOC_CTX *mem_ctx,
304 struct tevent_context *ev,
305 struct files_struct *fsp,
306 size_t in_max_output,
307 DATA_BLOB *out_output)
309 struct compression_state cmpr_state;
310 enum ndr_err_code ndr_ret;
315 return NT_STATUS_FILE_CLOSED;
318 /* Windows doesn't check for SEC_FILE_READ_ATTRIBUTE permission here */
320 ZERO_STRUCT(cmpr_state);
321 if (fsp->conn->fs_capabilities & FILE_FILE_COMPRESSION) {
322 status = SMB_VFS_GET_COMPRESSION(fsp->conn,
327 if (!NT_STATUS_IS_OK(status)) {
332 * bso#12144: The underlying filesystem doesn't support
333 * compression, so we should respond with "not-compressed"
334 * (like WS2016 ReFS) instead of STATUS_NOT_SUPPORTED or
335 * NT_STATUS_INVALID_DEVICE_REQUEST.
337 cmpr_state.format = COMPRESSION_FORMAT_NONE;
340 ndr_ret = ndr_push_struct_blob(&output, mem_ctx,
342 (ndr_push_flags_fn_t)ndr_push_compression_state);
343 if (ndr_ret != NDR_ERR_SUCCESS) {
344 return NT_STATUS_INTERNAL_ERROR;
347 if (in_max_output < output.length) {
348 DEBUG(1, ("max output %u too small for compression state %ld\n",
349 (unsigned int)in_max_output, (long int)output.length));
350 return NT_STATUS_INVALID_USER_BUFFER;
352 *out_output = output;
357 static NTSTATUS fsctl_set_cmprn(TALLOC_CTX *mem_ctx,
358 struct tevent_context *ev,
359 struct files_struct *fsp,
362 struct compression_state cmpr_state;
363 enum ndr_err_code ndr_ret;
367 return NT_STATUS_FILE_CLOSED;
370 /* WRITE_DATA permission is required, WRITE_ATTRIBUTES is not */
371 status = check_access_fsp(fsp, FILE_WRITE_DATA);
372 if (!NT_STATUS_IS_OK(status)) {
376 ndr_ret = ndr_pull_struct_blob(in_input, mem_ctx, &cmpr_state,
377 (ndr_pull_flags_fn_t)ndr_pull_compression_state);
378 if (ndr_ret != NDR_ERR_SUCCESS) {
379 DEBUG(0, ("failed to unmarshall set compression req\n"));
380 return NT_STATUS_INVALID_PARAMETER;
383 status = NT_STATUS_NOT_SUPPORTED;
384 if (fsp->conn->fs_capabilities & FILE_FILE_COMPRESSION) {
385 status = SMB_VFS_SET_COMPRESSION(fsp->conn,
389 } else if (cmpr_state.format == COMPRESSION_FORMAT_NONE) {
391 * bso#12144: The underlying filesystem doesn't support
392 * compression. We should still accept set(FORMAT_NONE) requests
393 * (like WS2016 ReFS).
395 status = NT_STATUS_OK;
401 static NTSTATUS fsctl_zero_data(TALLOC_CTX *mem_ctx,
402 struct tevent_context *ev,
403 struct files_struct *fsp,
406 struct file_zero_data_info zdata_info;
407 enum ndr_err_code ndr_ret;
408 struct lock_struct lck;
415 return NT_STATUS_FILE_CLOSED;
418 /* WRITE_DATA permission is required */
419 status = check_access_fsp(fsp, FILE_WRITE_DATA);
420 if (!NT_STATUS_IS_OK(status)) {
424 /* allow regardless of whether FS supports sparse or not */
426 ndr_ret = ndr_pull_struct_blob(in_input, mem_ctx, &zdata_info,
427 (ndr_pull_flags_fn_t)ndr_pull_file_zero_data_info);
428 if (ndr_ret != NDR_ERR_SUCCESS) {
429 DEBUG(0, ("failed to unmarshall zero data request\n"));
430 return NT_STATUS_INVALID_PARAMETER;
433 if (zdata_info.beyond_final_zero < zdata_info.file_off) {
434 DEBUG(0, ("invalid zero data params: off %lu, bfz, %lu\n",
435 (unsigned long)zdata_info.file_off,
436 (unsigned long)zdata_info.beyond_final_zero));
437 return NT_STATUS_INVALID_PARAMETER;
440 /* convert strange "beyond final zero" param into length */
441 len = zdata_info.beyond_final_zero - zdata_info.file_off;
444 DEBUG(2, ("zero data called with zero length range\n"));
448 init_strict_lock_struct(fsp,
449 fsp->op->global->open_persistent_id,
455 if (!SMB_VFS_STRICT_LOCK(fsp->conn, fsp, &lck)) {
456 DEBUG(2, ("failed to lock range for zero-data\n"));
457 return NT_STATUS_FILE_LOCK_CONFLICT;
461 * MS-FSCC <58> Section 2.3.67
462 * This FSCTL sets the range of bytes to zero (0) without extending the
465 * The VFS_FALLOCATE_FL_KEEP_SIZE flag is used to satisfy this
469 mode = VFS_FALLOCATE_FL_PUNCH_HOLE | VFS_FALLOCATE_FL_KEEP_SIZE;
470 ret = SMB_VFS_FALLOCATE(fsp, mode, zdata_info.file_off, len);
472 status = map_nt_error_from_unix_common(errno);
473 DEBUG(2, ("zero-data fallocate(0x%x) failed: %s\n", mode,
475 SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &lck);
479 if (!fsp->is_sparse && lp_strict_allocate(SNUM(fsp->conn))) {
481 * File marked non-sparse and "strict allocate" is enabled -
482 * allocate the range that we just punched out.
483 * In future FALLOC_FL_ZERO_RANGE could be used exclusively for
484 * this, but it's currently only supported on XFS and ext4.
486 * The newly allocated range still won't be found by SEEK_DATA
487 * for QAR, but stat.st_blocks will reflect it.
489 ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_FL_KEEP_SIZE,
490 zdata_info.file_off, len);
492 status = map_nt_error_from_unix_common(errno);
493 DEBUG(0, ("fallocate failed: %s\n", strerror(errno)));
494 SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &lck);
499 SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &lck);
503 static NTSTATUS fsctl_qar_buf_push(TALLOC_CTX *mem_ctx,
504 struct file_alloced_range_buf *qar_buf,
505 DATA_BLOB *qar_array_blob)
508 enum ndr_err_code ndr_ret;
511 ndr_ret = ndr_push_struct_blob(&new_slot, mem_ctx, qar_buf,
512 (ndr_push_flags_fn_t)ndr_push_file_alloced_range_buf);
513 if (ndr_ret != NDR_ERR_SUCCESS) {
514 DEBUG(0, ("failed to marshall QAR buf\n"));
515 return NT_STATUS_INVALID_PARAMETER;
518 /* TODO should be able to avoid copy by pushing into prealloced buf */
519 ok = data_blob_append(mem_ctx, qar_array_blob, new_slot.data,
521 data_blob_free(&new_slot);
523 return NT_STATUS_NO_MEMORY;
529 static NTSTATUS fsctl_qar_seek_fill(TALLOC_CTX *mem_ctx,
530 struct files_struct *fsp,
533 DATA_BLOB *qar_array_blob)
535 NTSTATUS status = NT_STATUS_NOT_SUPPORTED;
537 #ifdef HAVE_LSEEK_HOLE_DATA
538 while (curr_off <= max_off) {
541 struct file_alloced_range_buf qar_buf;
544 data_off = SMB_VFS_LSEEK(fsp, curr_off, SEEK_DATA);
545 if ((data_off == -1) && (errno == ENXIO)) {
546 /* no data from curr_off to EOF */
548 } else if (data_off == -1) {
549 status = map_nt_error_from_unix_common(errno);
550 DEBUG(1, ("lseek data failed: %s\n", strerror(errno)));
554 if (data_off > max_off) {
555 /* found something, but passed range of interest */
559 hole_off = SMB_VFS_LSEEK(fsp, data_off, SEEK_HOLE);
560 if (hole_off == -1) {
561 status = map_nt_error_from_unix_common(errno);
562 DEBUG(1, ("lseek hole failed: %s\n", strerror(errno)));
566 if (hole_off <= data_off) {
567 DEBUG(1, ("lseek inconsistent: hole %lu at or before "
568 "data %lu\n", (unsigned long)hole_off,
569 (unsigned long)data_off));
570 return NT_STATUS_INTERNAL_ERROR;
573 qar_buf.file_off = data_off;
574 /* + 1 to convert maximum offset to length */
575 qar_buf.len = MIN(hole_off, max_off + 1) - data_off;
577 status = fsctl_qar_buf_push(mem_ctx, &qar_buf, qar_array_blob);
578 if (!NT_STATUS_IS_OK(status)) {
579 return NT_STATUS_NO_MEMORY;
584 status = NT_STATUS_OK;
590 static NTSTATUS fsctl_qar(TALLOC_CTX *mem_ctx,
591 struct tevent_context *ev,
592 struct files_struct *fsp,
594 size_t in_max_output,
595 DATA_BLOB *out_output)
597 struct fsctl_query_alloced_ranges_req qar_req;
598 struct fsctl_query_alloced_ranges_rsp qar_rsp;
599 DATA_BLOB qar_array_blob = data_blob_null;
601 enum ndr_err_code ndr_ret;
604 SMB_STRUCT_STAT sbuf;
607 return NT_STATUS_FILE_CLOSED;
610 /* READ_DATA permission is required */
611 status = check_access_fsp(fsp, FILE_READ_DATA);
612 if (!NT_STATUS_IS_OK(status)) {
616 ndr_ret = ndr_pull_struct_blob(in_input, mem_ctx, &qar_req,
617 (ndr_pull_flags_fn_t)ndr_pull_fsctl_query_alloced_ranges_req);
618 if (ndr_ret != NDR_ERR_SUCCESS) {
619 DEBUG(0, ("failed to unmarshall QAR req\n"));
620 return NT_STATUS_INVALID_PARAMETER;
624 * XXX Windows Server 2008 & 2012 servers don't return lock-conflict
625 * for QAR requests over an exclusively locked range!
628 ret = SMB_VFS_FSTAT(fsp, &sbuf);
630 status = map_nt_error_from_unix_common(errno);
631 DEBUG(2, ("fstat failed: %s\n", strerror(errno)));
635 if ((qar_req.buf.len == 0)
636 || (sbuf.st_ex_size == 0)
637 || (qar_req.buf.file_off >= sbuf.st_ex_size)) {
638 /* zero length range or after EOF, no ranges to return */
642 /* check for integer overflow */
643 if (qar_req.buf.file_off + qar_req.buf.len < qar_req.buf.file_off) {
644 return NT_STATUS_INVALID_PARAMETER;
648 * Maximum offset is either the last valid offset _before_ EOF, or the
649 * last byte offset within the requested range. -1 converts length to
650 * offset, which is easier to work with for SEEK_DATA/SEEK_HOLE, E.g.:
652 * /off=0 /off=512K /st_ex_size=1M
653 * |-------------------------------------|
655 * |-------------------------------------|
657 * |=====================================|
658 * | QAR off=512K, len=1M |
659 * |=================^===================|
662 * |==================|
663 * |QAR off=0 len=512K|
664 * |==================|
668 max_off = MIN(sbuf.st_ex_size,
669 qar_req.buf.file_off + qar_req.buf.len) - 1;
671 if (!fsp->is_sparse) {
672 struct file_alloced_range_buf qar_buf;
674 /* file is non-sparse, claim file_off->max_off is allocated */
675 qar_buf.file_off = qar_req.buf.file_off;
676 /* + 1 to convert maximum offset back to length */
677 qar_buf.len = max_off - qar_req.buf.file_off + 1;
679 status = fsctl_qar_buf_push(mem_ctx, &qar_buf, &qar_array_blob);
681 status = fsctl_qar_seek_fill(mem_ctx, fsp, qar_req.buf.file_off,
682 max_off, &qar_array_blob);
684 if (!NT_STATUS_IS_OK(status)) {
688 /* marshall response buffer. */
689 qar_rsp.far_buf_array = qar_array_blob;
691 ndr_ret = ndr_push_struct_blob(out_output, mem_ctx, &qar_rsp,
692 (ndr_push_flags_fn_t)ndr_push_fsctl_query_alloced_ranges_rsp);
693 if (ndr_ret != NDR_ERR_SUCCESS) {
694 DEBUG(0, ("failed to marshall QAR rsp\n"));
695 return NT_STATUS_INVALID_PARAMETER;
698 if (out_output->length > in_max_output) {
699 DEBUG(2, ("QAR output len %lu exceeds max %lu\n",
700 (unsigned long)out_output->length,
701 (unsigned long)in_max_output));
702 data_blob_free(out_output);
703 return NT_STATUS_BUFFER_TOO_SMALL;
709 static void smb2_ioctl_filesys_dup_extents_done(struct tevent_req *subreq);
711 struct tevent_req *smb2_ioctl_filesys(uint32_t ctl_code,
712 struct tevent_context *ev,
713 struct tevent_req *req,
714 struct smbd_smb2_ioctl_state *state)
719 case FSCTL_GET_COMPRESSION:
720 status = fsctl_get_cmprn(state, ev, state->fsp,
721 state->in_max_output,
723 if (!tevent_req_nterror(req, status)) {
724 tevent_req_done(req);
726 return tevent_req_post(req, ev);
728 case FSCTL_SET_COMPRESSION:
729 status = fsctl_set_cmprn(state, ev, state->fsp,
731 if (!tevent_req_nterror(req, status)) {
732 tevent_req_done(req);
734 return tevent_req_post(req, ev);
736 case FSCTL_SET_ZERO_DATA:
737 status = fsctl_zero_data(state, ev, state->fsp,
739 if (!tevent_req_nterror(req, status)) {
740 tevent_req_done(req);
742 return tevent_req_post(req, ev);
744 case FSCTL_QUERY_ALLOCATED_RANGES:
745 status = fsctl_qar(state, ev, state->fsp,
747 state->in_max_output,
749 if (!tevent_req_nterror(req, status)) {
750 tevent_req_done(req);
752 return tevent_req_post(req, ev);
754 case FSCTL_DUP_EXTENTS_TO_FILE: {
755 struct tevent_req *subreq = NULL;
757 subreq = fsctl_dup_extents_send(state, ev,
761 if (tevent_req_nomem(subreq, req)) {
762 return tevent_req_post(req, ev);
764 tevent_req_set_callback(subreq,
765 smb2_ioctl_filesys_dup_extents_done,
771 uint8_t *out_data = NULL;
772 uint32_t out_data_len = 0;
774 if (state->fsp == NULL) {
775 status = NT_STATUS_NOT_SUPPORTED;
777 status = SMB_VFS_FSCTL(state->fsp,
780 state->smbreq->flags2,
781 state->in_input.data,
782 state->in_input.length,
784 state->in_max_output,
786 state->out_output = data_blob_const(out_data, out_data_len);
787 if (NT_STATUS_IS_OK(status)) {
788 tevent_req_done(req);
789 return tevent_req_post(req, ev);
793 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
794 if (IS_IPC(state->smbreq->conn)) {
795 status = NT_STATUS_FS_DRIVER_REQUIRED;
797 status = NT_STATUS_INVALID_DEVICE_REQUEST;
801 tevent_req_nterror(req, status);
802 return tevent_req_post(req, ev);
807 tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
808 return tevent_req_post(req, ev);
811 static void smb2_ioctl_filesys_dup_extents_done(struct tevent_req *subreq)
813 struct tevent_req *req = tevent_req_callback_data(subreq,
817 status = fsctl_dup_extents_recv(subreq);
819 if (!tevent_req_nterror(req, status)) {
820 tevent_req_done(req);