다음을 통해 공유


3.2.4.15.1 Client Requests Raw Write

SMB_COM_WRITE_RAW is a specialized write command intended to maximize the performance of writing large blocks of data to an open regular file, a named pipe, device, or spooled output (printer). The command permits a client to send a large unformatted data (raw byte) message over the SMB transport without requiring the usual SMB request format. It also permits a client to send messages in excess of the maximum buffer size (Client.Connection.ServerMaxBufferSize) that was established during session setup. To accomplish this, the client and the server enter into a dialog. For the dialog to begin, the client MUST perform the following steps:

  • The client MUST compose the SMB_COM_WRITE_RAW request as described in section 2.2.4.25.1. This request informs the server of the total number of bytes that the client designates to send over the course of the dialog. For the dialog to begin, the request MUST be sent to the server as described in section 3.2.4.1, with the exception that SMB_COM_WRITE_RAW and message signing are mutually exclusive. Message signing MUST be disabled in order to perform a raw write. When the SMB_COM_WRITE_RAW request is received, the server MUST validate the request and attempt to write the initial data contained within the request. If an error is detected, the server returns a Final Server Response (section 2.2.4.25.3), which completes the dialog. Otherwise, the server MUST respond with an Interim Server Response (section 2.2.4.25.2) to indicate that the message was received and that the server is ready for the unformatted raw data. The server MUST then begin waiting for the unformatted data message to arrive.

  • The client MUST send the unformatted data message to the server. Because the message contains unformatted raw bytes, the server MUST rely on the SMB transport to determine whether the message was received successfully, and to determine the message size.

    • If the WritethroughMode bit was set in the WriteMode field of the original request, then the server MUST send a Final Server Response following receipt of the raw data from the client.

    • If the WritethroughMode bit was clear in the WriteMode field of the original request, then the server MUST NOT send a Final Server Response following receipt of the raw data from the client.

A sample dialog flow is:

Write Raw request/response message flow

Figure 8: Write Raw request/response message flow

Because the client sends a raw data message that does not include the typical request data, the SMB Protocol cannot guarantee that the server can associate the client's raw data message with the correct corresponding client's SMB_COM_WRITE_RAW command. Therefore, the client MUST guarantee that there are no other SMB requests from the client to the server for the duration of the SMB_COM_WRITE_RAW command's dialog processing.

Server support of SMB_COM_WRITE_RAW is optional. This command is not supported over connectionless SMB transports. If SMB_COM_WRITE_RAW is supported by the server, the CAP_RAW_MODE flag MUST be set in the Capabilities field in the response to the SMB_COM_NEGOTIATE SMB. If the Client.Connection.SelectedDialect is NT LAN Manager or later, and the response to the SMB_COM_NEGOTIATE SMB has CAP_LARGE_FILES set in the Capabilities field, an additional request format is allowed that accommodates very large files having 64-bit offsets (see the OffsetHigh field in the command description in section 2.2.4.25.1).<207>