FSCTL_DUPLICATE_EXTENTS_TO_FILE control code

Instructs the file system to copy a range of file bytes on behalf of an application. The destination file may be the same as, or different from, the source file. See Block Cloning for more information.

To perform this operation, call the DeviceIoControl function with the following parameters.


BOOL 
   WINAPI 
   DeviceIoControl( (HANDLE)       hDevice,          // handle to device
                    FSCTL_DUPLICATE_EXTENTS_TO_FILE, // dwIoControlCode
                    (LPVOID)       lpInBuffer,       // input buffer
                    (DWORD)        nInBufferSize,    // size of input buffer
                    NULL,                            // lpOutBuffer
                    0,                               // nOutBufferSize
                    (LPDWORD)      lpBytesReturned,  // number of bytes returned
                    (LPOVERLAPPED) lpOverlapped );   // OVERLAPPED structure

Parameters

hDevice [in]

A handle to the destination file to which the byte range is to be copied. To retrieve a file handle, call the CreateFile function.

dwIoControlCode [in]

The control code for the operation. Use FSCTL_DUPLICATE_EXTENTS_TO_FILE for this operation.

lpInBuffer

A pointer to a DUPLICATE_EXTENTS_DATA structure that specifies the source file, the source byte range, and the destination file offset to copy the range to.

nInBufferSize [in]

The size of the input buffer, in bytes.

lpOutBuffer [out]

Not used with this operation. Set to NULL.

nOutBufferSize [in]

Not used with this operation. Set to zero (0).

lpBytesReturned [out]

A pointer to a variable that receives the size of the data stored in the output buffer, in bytes.

If the output buffer is too small, the call fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and lpBytesReturned is zero.

If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation returns no output data and lpOutBuffer is NULL, DeviceIoControl makes use of lpBytesReturned. After such an operation, the value of lpBytesReturned is meaningless.

If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this parameter is not NULL and the operation returns data, lpBytesReturned is meaningless until the overlapped operation has completed. To retrieve the number of bytes returned, call GetOverlappedResult. If the hDevice parameter is associated with an I/O completion port, you can retrieve the number of bytes returned by calling GetQueuedCompletionStatus.

lpOverlapped [in]

A pointer to an OVERLAPPED structure.

If hDevice was opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored.

If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case, lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways.

For overlapped operations, DeviceIoControl returns immediately, and the event object is signaled when the operation has been completed. Otherwise, the function does not return until the operation has been completed or an error occurs.

Return value

If the operation completes successfully, DeviceIoControl returns a nonzero value.

If the operation fails or is pending, DeviceIoControl returns zero (0). To get extended error information, call GetLastError.

Remarks

For the implications of overlapped I/O on this operation, see the Remarks section of the DeviceIoControl topic.

See Block Cloning for more information on this operation.

In Windows Server 2016, this function is supported by the following technologies.

TechnologySupported

Server Message Block (SMB) 3.1.1 protocol

Yes

SMB 3.1.1 Transparent Failover (TFO)

Yes

SMB 3.1.1 with Scale-out File Shares (SoFS)

Yes

Cluster Shared Volume File System (CsvFS)

Yes

Resilient File System (ReFS)

Yes

 

Requirements

Minimum supported client

None supported

Minimum supported server

Windows Server 2016 [desktop apps only]

Header

WinIoCtl.h (include Windows.h)

See also

DeviceIoControl
File Management Control Codes
DUPLICATE_EXTENTS_DATA
Block Cloning

 

 

Show: