DISK_IOCTL_WRITE

Block device drivers respond to this I/O control code in order to service FAT file system requests to write data to the block device.

Parameters

hDevice
Handle to the block device.
dwIoControlCode
DISK_IOCTL_WRITE.
lpInBuffer
Address of a SG_REQ structure.
nInBufferSize
Size of the SG_REQ structure.
lpOutBuffer
Not used.
nOutBufferSize
Not used.
lpBytesReturned
Address of a DWORD to receive total bytes returned.
lpOverlapped
Not used.

Return Values

When this function returns, the FAT file system expects the sr_status member of the SG_REQ structure to be set to either ERROR_SUCCESS if the write succeeded, or a standard Win32 error code otherwise. Certain errors are automatically retried, such as ERROR_BAD_UNIT if the device has been removed and ERROR_NOT_READY if the driver is in the process of shutting down or starting up. The block device driver should return ERROR_GEN_FAILURE for any unknown or unexpected errors, and ERROR_WRITE_PROTECT for attempts to write to media that is write-protected.

Remarks

The FAT file system fills in the SG_REQ structure passed to the block device driver as follows:

sr_start
Starting block number.
sr_num_sec
Number of blocks to write.
sr_num_sg
Number of scatter/gather buffers (normally 1).
sr_callback
NULL.
sr_sglist[0].sb_buf
Address of the buffer to write blocks into. Note that this buffer is unaligned.
sr_sglist[0].sb_len
Size of the sr_sglist[0].sb_buf buffer in bytes.

Remarks

If sr_num_sg is greater than 1, then the block device driver should fill in additional entries in the sr_sglist array.