Compartir a través de


3.3.5.34 Receiving an SMB_COM_WRITE_AND_CLOSE Request

Upon receipt of an SMB_COM_WRITE_AND_CLOSE Request (section 2.2.4.40.1), the server MUST perform the following actions:

  • The server MUST verify the FID, which MUST represent an open regular file.

  • The server MUST verify the UID as described in section 3.3.5.2 and ensure that the user has permission to write to the file. If the user does not have permission to write to the file, the server MUST send an error response with a status of STATUS_ACCESS_DENIED (ERRDOS/ERRnoaccess) and MUST increase Server.Statistics.sts0_permerrors by 1.

  • If the UID presented is different from the UID that opened the file, the server MUST send the error response with a Status of STATUS_INVALID_HANDLE (ERRDOS/ERRbaduid).

  • In the file identified by the FID, the server MUST perform a seek to the offset specified in the WriteOffsetInBytes field in the request.

  • The server MUST write CountOfBytesToWrite bytes sequentially from the Data field in the request to the file. Any failure that causes less than CountOfBytesToWrite bytes to be written SHOULD result in an error response to the client.

  • If the LastWriteTime field is nonzero in the request, the server SHOULD set the last write time of the file to this value.

In the event of an error, the server MUST send an error response message. Otherwise, the server MUST close the file indicated by the FID. The server MUST release every lock in Open.Locks. The FID MUST be invalidated by removing the Open entry from Server.Connection.FileOpenTable. Open.TreeConnect.OpenCount and Server.Statistics.sts0_fopens MUST be decreased by 1.<294> The server MUST provide Open.FileGlobalId as an input parameter and MUST deregister the Open by invoking the event Server Deregisters an Open ([MS-SRVS] section 3.1.6.5).

Again, an error MUST result in an error response message being sent to the client. Otherwise, the server MUST construct an SMB_COM_WRITE_AND_CLOSE Response (section 2.2.4.40.2) message. The CountOfBytesWritten field MUST contain the number of bytes written to the file. This value SHOULD be the equal to CountOfBytesToWrite. If the number of bytes written differs from the number of bytes requested to be written, and no error is indicated, the server has no resources available with which to satisfy the complete write. The response MUST be sent to the client as specified in section 3.3.4.1.