3.2.5.7 Receiving an SMB2 CREATE Response for a New Create Operation

If the Status field of the SMB2 header of the response indicates an error, the client MUST return the received status code to the calling application that initiated the open of a file or named pipe.

The client MUST locate the corresponding request in Connection.OutstandingRequests using the MessageId field of the SMB2 header. If the request is for a new create operation, then the processing MUST continue as specified below.

If Connection.Dialect belongs to the SMB 3.x dialect family and the status code is STATUS_SERVER_UNAVAILABLE, and Connection.ServerCapabilities includes SMB2_GLOBAL_CAP_PERSISTENT_HANDLES or SMB2_GLOBAL_CAP_MULTI_CHANNEL, the client SHOULD<193> replay the request by setting SMB2_FLAGS_REPLAY_OPERATION bit in the SMB2 header.

If the Status field of the SMB2 header of the response indicates success, the client MUST locate the session in the Connection.SessionTable using the SessionId in the SMB2 header of the response. The client MUST locate a tree connect in the Session.TreeConnectTable using the TreeId in the SMB2 header of the response. The client MUST allocate an open object and initialize it as follows:

  • Open.FileId MUST be set to the FileId that is received in the SMB2 CREATE Response following the SMB2 header.

  • Open.TreeConnect MUST be set to the tree connect that was looked up in the Session.TreeConnectTable.

  • Open.Connection MUST be set to the connection on which the response was received.

  • Open.OplockLevel MUST be set to the OplockLevel in the SMB2 CREATE Response.

  • Open.Durable MUST be set to FALSE.

  • Open.ResilientHandle MUST be set to FALSE.

  • Open.LastDisconnectTime MUST be set to zero.

  • Open.DesiredAccess MUST be set to the DesiredAccess field of the request.

  • Open.ShareMode MUST be set to the ShareAccess field of the request.

  • Open.CreateOptions MUST be set to the CreateOptions field of the request.

  • Open.FileAttributes MUST be set to the FileAttributes field of the request.

  • Open.CreateDisposition MUST be set to the CreateDisposition field of the request.

  • If TreeConnect.IsDfsShare is TRUE, Open.FileName MUST be initialized with the name from the Buffer field of the request.

  • If TreeConnect.IsDfsShare is FALSE, Open.FileName MUST be initialized with the concatenation of Connection.ServerName, TreeConnect.ShareName, and the name from the Buffer field of the request, joined with pathname separators (example: server\share\path).

Each entry of Open.OperationBuckets MUST be initialized as follows:

Set the Free element to TRUE and SequenceNumber element to 0.

If the response includes response create contexts following the syntax specified in section 2.2.14.2, the processing described in subsequent subsections MUST be handled if the specified create context is present in the response.

The client MUST insert the Open into the Session.OpenTable. If Connection.Dialect is not "2.0.2" and Connection.SupportsFileLeasing is TRUE, the client MUST locate the File corresponding to Open.FileName in the GlobalFileTable. If no File is found, the client MUST create a new File entry and add it to the GlobalFileTable and assign a new File.LeaseKey, as specified in section 3.2.1.5, to the entry. File.OpenTable MUST be initialized to an empty table and File.LeaseState MUST be initialized to SMB2_LEASE_NONE. The client MUST insert the Open into File.OpenTable.

If Connection.Dialect belongs to the SMB 3.x dialect family and Connection.SupportsDirectoryLeasing is TRUE, the client MUST search the GlobalFileTable for the parent directory of the file being opened.  The name of the parent directory is obtained by removing the last component of the path used to search the GlobalFileTable above. If an entry is not found, a new File entry MUST be created and added to the GlobalFileTable and a File.LeaseKey, as specified in section 3.2.1.5, MUST be assigned to the entry. File.OpenTable MUST be initialized to an empty table and File.LeaseState MUST be initialized to SMB2_LEASE_NONE.

The client MUST generate a handle for the Open, and it MUST return success and the generated handle to the calling application.