Compartilhar via


3.3.5.6 Receiving an SMB_COM_CREATE Request

Upon receipt of an SMB_COM_CREATE Request (section 2.2.4.4.1), the server MUST attempt to create or overwrite the file named in the FileName field of the request. If the file does not already exist (is being created), the server MUST also attempt to set the attributes of the file to those provided in the FileAttributes field. The server MAY<246> set the creation time of the file from the CreationTime field.

  • The user indicated by the UID MUST have write permission on the file's parent directory in order to create a new file; otherwise, the server MUST increase Server.Statistics.sts0_permerrors by 1, fail the request, and return an error response with STATUS_ACCESS_DENIED (ERRDOS/ERRnoaccess).

  • The user indicated by the UID MUST have write permission on the file itself in order to truncate it; otherwise, the server MUST increase Server.Statistics.sts0_permerrors by 1, fail the request, and return an error response with STATUS_ACCESS_DENIED (ERRDOS/ERRnoaccess).

  • The server MUST grant read/write permission for the creator if the file is created. Access permissions for truncated files are not modified. The newly created or truncated file is opened for read/write in Compatibility Mode (see section 3.2.4.5.1).

If the Create operation fails, the server MUST return an error response with a Status code from the list provided in section 2.2.4.4.2. Otherwise, the server MUST allocate a new FID, format an SMB_COM_CREATE response message as defined in section 2.2.4.4.2, and set SMB_Header.Status to indicate success. Server.Statistics.sts0_fopens MUST be increased by 1, and an Open containing the new FID MUST be created, initialized, and entered into the Server.Connection.FileOpenTable.<247> 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 request was performed, and Server.Open.TreeConnect.OpenCount MUST be increased by 1. .Server.Open.Session MUST be set to the 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).<248>

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

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