READ: Read File

The read message is sent to read bytes of a resource indicated by fid in the SMB header.

Client Request
===============================
Description
====================================
UCHAR WordCount; Count of parameter words = 5
USHORT Fid; File handle
USHORT Count; Count of bytes being requested
ULONG Offset; Offset in file of first byte to read
USHORT Remaining; Estimate of bytes to read if nonzero
USHORT ByteCount; Count of data bytes = 0

count is used to specify the requested number of bytes.

offset specifies the offset in the file of the first byte to be read. Note that this offset is limited to 32 bits, so this client request is inappropriate for files having 64 bit offsets.

remaining is advisory. If the value is not zero, then it is taken as an estimate of the total number of bytes that will be read, including those read by this request. This additional information may be used by the server to optimize buffer allocation or read-ahead.

Server Response
==================================
Description
=================================
UCHAR WordCount; Count of parameter words = 5
USHORT Count; Count of bytes actually returned
USHORT Reserved [4]; Reserved (must be 0)
USHORT ByteCount; Count of data bytes
UCHAR BufferFormat; 0x01 -- Data block
USHORT DataLength; Length of data

bytecount is the number of bytes actually being returned. If fid refers to a disk file, bytecount may be less than the count requested only if a read specifies bytes beyond the current file size. In this case only the bytes that exist are returned. A read completely beyond the end of file results in a response of length zero. This is the only circumstance when a zero length response is generated. A count returned which is less than the count requested is the end of file indicator.

If a Read requests more data than can be placed in a message of the maximum-xmit-size for the tid specified, the server will abort the connection to the client.