Export (0) Print
Expand All

IOCTL_COPYCHUNK control code

The IOCTL_COPYCHUNK control code initiates a server-side copy of a range of data, also called a chunk.

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


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

Parameters

hDevice [in]

A handle to the file that is the target of the server-side copy operation. To obtain this handle, call the CreateFile function.

dwIoControlCode [in]

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

lpInBuffer

A pointer to the input buffer, a SRV_COPYCHUNK_COPY structure. For more information, see the Remarks section.

nInBufferSize [in]

The size of the input buffer, in bytes.

lpOutBuffer [out]

A pointer to the output buffer, a SRV_COPYCHUNK_RESPONSE structure. For more information, see the Remarks section.

nOutBufferSize [in]

The size of the output buffer, in bytes.

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, the GetLastError function returns ERROR_INSUFFICIENT_BUFFER, and lpBytesReturned is zero.

If the lpOverlapped parameter is NULL, lpBytesReturned cannot be NULL. Even when an operation returns no output data and the lpOutBuffer parameter 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 lpOverlapped 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 the GetOverlappedResult function. If the hDevice parameter is associated with an I/O completion port, you can retrieve the number of bytes returned by calling the GetQueuedCompletionStatus function.

lpOverlapped [in]

A pointer to an OVERLAPPED structure.

If the hDevice parameter 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 until 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. To get extended error information, call GetLastError.

Remarks

This control code has no associated header file. You must define the control code and data structures as follows.


#define IOCTL_COPYCHUNK CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 262, METHOD_BUFFERED,  FILE_READ_ACCESS)

typedef struct _SRV_COPYCHUNK {
    LARGE_INTEGER SourceOffset;
    LARGE_INTEGER DestinationOffset;
    ULONG  Length;
} SRV_COPYCHUNK, *PSRV_COPYCHUNK;

typedef struct _SRV_COPYCHUNK_COPY {
    SRV_RESUME_KEY SourceFile;
    ULONG          ChunkCount;
    ULONG          Reserved;
    SRV_COPYCHUNK  Chunk[1];    // Array
} SRV_COPYCHUNK_COPY, *PSRV_COPYCHUNK_COPY;

typedef struct _SRV_COPYCHUNK_RESPONSE {
    ULONG          ChunksWritten;
    ULONG          ChunkBytesWritten;
    ULONG          TotalBytesWritten;
} SRV_COPYCHUNK_RESPONSE, *PSRV_COPYCHUNK_RESPONSE;

These members can be described as follows.

MemberDescription

SourceOffset

The offset, in bytes, from the beginning of the source file to the chunk to be copied.

DestinationOffset

The offset, in bytes, from the beginning of the target file to the location where the chunk is to be copied.

Length

The number of bytes of data in the chunk to be copied. Must be greater than zero and less than or equal to 1 MB. Length * ChunkCount must be less than or equal to 16 MB.

SourceFile

A key that represents the source file with the data to be copied. This key is obtained through FSCTL_SRV_REQUEST_RESUME_KEY.

ChunkCount

The number of chunks to be copied. Must be greater than zero and less than or equal to 256.

Reserved

This member is reserved for system use; do not use.

Chunk

An array of ChunkCount SRV_COPYCHUNK structures, one for each chunk to be copied. The length, in bytes, of this array must be ChunkCount * sizeof(SRV_COPYCHUNK).

ChunksWritten

If the operation failed with ERROR_INVALID_PARAMETER, this value indicates the maximum number of chunks the server will accept in a single request, which is 256. Otherwise, this value indicates the number of chunks that were successfully written.

ChunkBytesWritten

If the operation failed with ERROR_INVALID_PARAMETER, this value indicates the maximum number of bytes the server will allow to be written in a single chunk, which is 1 MB. Otherwise, this value indicates the number of bytes that were successfully written in the last chunk that was not successfully processed (if a partial write occurred).

TotalBytesWritten

If the operation failed with ERROR_INVALID_PARAMETER, this value indicates the maximum number of bytes the server will copy in a single request, which is 16 MB. Otherwise, this value indicates the number of bytes that were successfully written.

 

See also

DeviceIoControl
FSCTL_SRV_REQUEST_RESUME_KEY

 

 

Community Additions

ADD
Show:
© 2014 Microsoft