3.2.4.5 Application Requests Closing a File or Named Pipe

The application provides:

  • A handle to the Open identifying the file or named pipe to be closed.

  • A Boolean that, if set, specifies that it requires the attributes of the file after the close is executed.

If the handle is invalid, or if no Open referenced by the handle is found, the client MUST return an implementation-specific error code. If the handle is valid, and Open is found, the client MUST proceed as follows.

For the specified Open, the client MUST select a connection as specified in section 3.2.4.1.7. If no connection is available, the client MUST fail the close operation.

Otherwise, the client MUST initialize an SMB2 CLOSE Request by following the syntax specified in section 2.2.15. The SMB2 header MUST be initialized as follows:

  • The Command field is set to SMB2 CLOSE.

  • The MessageId field is set as specified in section 3.2.4.1.3.

  • The SessionId field is set to Open.TreeConnect.Session.SessionId.

  • The TreeId field is set to Open.TreeConnect.TreeConnectId.

The SMB2 CLOSE Request MUST be initialized as follows:

  • If the application requires to have the attributes of the file returned after close, the client sets SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB to TRUE in the Flags field.

  • The FileId field is set to Open.FileId.

This request MUST be sent to the server.