22.214.171.124 Receiving an SMB_COM_WRITE_AND_UNLOCK Request
The SMB_COM_WRITE_AND_UNLOCK (section 126.96.36.199) command combines the behavior of SMB_COM_WRITE (section 188.8.131.52) with that of SMB_COM_UNLOCK_BYTE_RANGE (section 184.108.40.206). SMB_COM_WRITE_AND_UNLOCK (section 220.127.116.11) is intended to be paired with SMB_COM_LOCK_AND_READ (section 18.104.22.168) to perform record updates to a file.
The FID provided in the command request MUST indicate a file held open by the client with, at minimum, write access. The server MUST first perform the write operation and then release the lock. The bytes to be written are passed in the Data field of the request, and MUST be written starting at the file position indicated by the WriteOffsetInBytes field. Once the data has been successfully written, the server MUST attempt to unlock the byte range specified by WriteOffsetInBytes (offset) and CountOfBytesToWrite (length).<273>
It is possible that the actual number of bytes available in the request, as indicated by the DataLength field, is less than CountOfBytesToWrite. If this occurs, the server MUST write DataLength bytes from the Data field to the file indicated by the FID starting at the position indicated by WriteOffsetInBytes. When the byte range is unlocked, however, the full range as specified by WriteOffsetInBytes and CountOfBytesToWrite MUST be unlocked.
In the event of an error, the server MUST send an error response message. If the write and unlock are successful, the server MUST construct an SMB_COM_WRITE_AND_UNLOCK response message as specified in section 22.214.171.124.2. The response MUST be sent to the client as specified in section 126.96.36.199 The server MUST remove the matching entry from the Server.Open.Locks list.