3.3.5.18 Receiving an SMB_COM_CREATE_NEW Request

This command is used to create a new file. It MUST NOT truncate or overwrite an existing file. If a file with the requested pathname already exists within the share represented by the TID, the command MUST fail with STATUS_OBJECT_NAME_COLLISION (ERRDOS/ERRfilexists). This command MUST be used only to create regular files.

When the server receives an SMB_COM_CREATE_NEW Request, it MUST verify the TID and the directory path portion of the FileName field. The server MUST verify the UID and ensure that the user has write permission on the file's parent directory in order to create a new file. If the underlying object store returns STATUS_ACCESS_DENIED, the server MUST increase Server.Statistics.sts0_permerrors by 1. If the file is created successfully, it is opened for read/write access in Compatibility Mode (see section 3.2.4.5.1).

If the command is successful, the server MUST increase Server.Statistics.sts0_fopens by 1 and MUST allocate an Open object and insert it into Server.Connection.FileOpenTable with the following default values:

  • A new FID MUST be created to uniquely identify this Open in Server.Connection.FileOpenTable.

  • If Server.EnableOplock is TRUE and a requested OpLock was granted, the type of OpLock MUST be set in Server.Open.OpLock and Server.Open.OplockState MUST be set to Held; otherwise, Server.Open.OpLock MUST be set to None and Server.Open.OplockState MUST be set to None.

  • Server.Open.TreeConnect MUST be set to the TreeConnect on which the open request was performed, and Server.Open.TreeConnect.OpenCount MUST be increased by 1.

  • Server.Open.Session MUST be set to Server.Open.TreeConnect.Session.

  • Server.Open.Connection MUST be set to the Server.Open.Session.Connection.

  • Server.Open.Locks MUST be set to an empty list.

  • Server.Open.PID MUST be set to the PID provided in the request.

  • Server.Open.PathName MUST be set to the FileName field of the request.

  • Server.Open.GrantedAccess MUST be set to (GENERIC_READ | GENERIC_WRITE).

The server MUST register the Open by invoking the event Server Registers a New Open ([MS-SRVS] section 3.1.6.4) and MUST assign the return value to Server.Open.FileGlobalId.

The server MUST construct an SMB_COM_CREATE_NEW Response (section 2.2.4.16.2) message and return the newly-created FID.<268>

If an error occurred, the server MUST send an error response message.

The response MUST be sent to the client as specified in section 3.3.4.1.