188.8.131.52 Receiving an SMB_COM_WRITE_AND_UNLOCK Request
The SMB_COM_WRITE_AND_UNLOCK (section 184.108.40.206) command combines the behavior of SMB_COM_WRITE (section 220.127.116.11) with that of SMB_COM_UNLOCK_BYTE_RANGE (section 18.104.22.168). SMB_COM_WRITE_AND_UNLOCK (section 22.214.171.124) is intended to be paired with SMB_COM_LOCK_AND_READ (section 126.96.36.199) 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 188.8.131.52.2. The response MUST be sent to the client as specified in section 184.108.40.206 The server MUST remove the matching entry from the Server.Open.Locks list.