Compartilhar via


2.2.4.21 SMB_COM_WRITE_AND_UNLOCK (0x14)

This command was introduced in the CorePlus dialect, but is often listed as part of the LAN Manager 1.0 dialect. This command is deprecated. Clients SHOULD use the SMB_COM_LOCKING_ANDX (section 2.2.4.32) command.

The write and unlock command has the effect of writing to a range of bytes and then unlocking them. This command is usually associated with an earlier usage of SMB_COM_LOCK_AND_READ (section 2.2.4.20) on the same range of bytes. The server's response field CountOfBytesWritten indicates the number of bytes actually written.

Aside from the lack of special handling of zero-length writes, this request behaves in an identical fashion to the SMB_COM_WRITE (section 2.2.4.12) command followed by a core protocol SMB_COM_UNLOCK_BYTE_RANGE command. Support for this SMB command is optional. A server SHOULD set bit 0 in the SMB Header (section 2.2.3.1) Flags field of the SMB_COM_NEGOTIATE (section 2.2.4.52) response to indicate to the client that the command is supported. If the command sends a message of length greater than the MaxBufferSize for the TID specified, the server MAY abort the connection to the client. If an error occurs on the write, the bytes remain locked.

This command supports only 32-bit offsets and is inappropriate for files having 64-bit offsets. The client SHOULD use SMB_COM_WRITE_ANDX (section 2.2.4.43) to write to files requiring 64-bit file offsets.

When FID represents a disk file and the request specifies a byte range beyond the current end of file, the file MUST be extended. Any bytes between the previous end of file and the requested offset are initialized to zero (0x00). When a write specifies a count of zero, the file is not truncated or extended to the length specified by the offset.

The client MUST have at least write access to the file.