다음을 통해 공유


3.3.4.4 Sending an Error Response

When the server is responding with a failure to any command sent by the client, the response message MUST be constructed as described here. An error code other than one of the following indicates a failure:

The server MUST provide the error code of the failure and a data buffer to be returned with the error. If nothing is specified, the buffer MUST be considered to be zero bytes in length.

The server can return any of the following errors if the server, the file, or the share is not ready to process an I/O request from the client.

  • STATUS_SERVER_UNAVAILABLE

  • STATUS_FILE_NOT_AVAILABLE

  • STATUS_SHARE_UNAVAILABLE

The server MUST construct the SMB2 header of the error response to match the SMB2 header of the request with the following changes:

  • The Status field of the SMB2 header MUST be set to the error code provided.

  • The NextCommand field MUST be set to 0. If this response is later combined with other responses into a compounded response, as specified in section 3.3.4.1.3, this value will change later.

  • The SMB2_FLAGS_SERVER_TO_REDIR bit MUST be set in the Flags field of the SMB2 header.

  • If Request.AsyncId is nonzero, the server MUST set the AsyncId field to it, and MUST set the SMB2_FLAGS_ASYNC_COMMAND bit in the Flags field, and MUST set the CreditResponse field to 0.

  • Otherwise, the server MUST set the CreditResponse field to the number of credits the server chooses to grant the request, as specified in section 3.3.1.2.

Following the SMB2 header MUST be an SMB2 ERROR Response structure, as specified in section 2.2.2.

If Connection.Dialect is "3.1.1", the server MUST construct an SMB2 ERROR Response structure as follows:

  • The ErrorContextCount of this response MUST be set to the number of SMB2 ERROR Context structures to be set in the ErrorData array of the response.

  • The ByteCount of this response MUST be set to the length of the buffer that is provided as part of the error.

  • If ErrorContextCount is greater than zero, the server MUST format the ErrorData array of the response as a variable-length array of SMB2 ERROR Context structures as specified in section 2.2.2.1.

Otherwise, the server MUST construct an SMB2 ERROR Response structure as follows:

  • The ErrorContextCount of this response MUST be set to 0.

  • The ByteCount of this response MUST be set to the length of the buffer that is provided as part of the error.

  • If ByteCount is greater than zero, the server MUST format the ErrorData array of the response as described in section 2.2.2.2.

This response MUST then be sent to the client, and the request MUST be removed from Connection.RequestList and freed.