Compartir a través de


3.3.5.10 Receiving an SMB2 CLOSE Request

When the server receives a request with an SMB2 header with a Command value equal to SMB2 CLOSE, message handling proceeds as follows:

The server MAY<353> validate the open before session verification.

The server MUST locate the session, as specified in section 3.3.5.2.9.

Next, the server MUST locate the open being closed by performing a lookup in the Session.OpenTable, using FileId.Volatile of the request as the lookup key. If no open is found, or if Open.DurableFileId is not equal to FileId.Persistent, the server MUST fail the request with STATUS_FILE_CLOSED.

The server MUST locate the tree connection, as specified in section 3.3.5.2.11.

The server MUST locate the Request in Connection.RequestList for which Request.MessageId matches the MessageId value in the SMB2 header and set Request.Open to the Open.

If SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB is set in the Flags field of the request, the server MUST query the creation time, last access time, last write time, change time, allocation size in bytes, end of file in bytes, and file attributes of the file from the underlying object store in an implementation-specific manner<354>.

The server MUST close the Open as specified in section 3.3.4.17.

The server then MUST construct the response following the syntax specified in section 2.2.16. The values MUST be set as follows:

  • If the attributes of the file were requested and can be fetched, the server MUST set the Flags field to SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB. Otherwise Flags MUST be set to 0.

  • If SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB was set:

    • CreationTime, LastAccessTime, LastWriteTime, ChangeTime, AllocationSize, EndofFile, and FileAttributes MUST be set to the values returned from the attribute query.

  • If SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB was not set:

    • CreationTime, LastAccessTime, LastWriteTime, ChangeTime, AllocationSize, EndofFile, and FileAttributes MUST all be set to 0.

The response MUST then be sent to the client.

The Server MUST send an SMB2 CHANGE_NOTIFY Response with STATUS_NOTIFY_CLEANUP status code for all pending CHANGE_NOTIFY requests associated with the FileId that is closed.

The status code returned by this operation MUST be one of those defined in [MS-ERREF]. Common status codes returned by this operation include:

  • STATUS_SUCCESS

  • STATUS_INSUFFICIENT_RESOURCES

  • STATUS_FILE_CLOSED

  • STATUS_NETWORK_NAME_DELETED

  • STATUS_USER_SESSION_DELETED

  • STATUS_INVALID_PARAMETER

  • STATUS_NETWORK_SESSION_EXPIRED

  • STATUS_ACCESS_DENIED