Compartir a través de


3.3.5.58.2 Receiving a TRANS2_OPEN2 Request

The TRANS2_OPEN2 (section 2.2.6.1) subcommand is used to open or create a file and set extended attributes on the file. The parameters for the Open operation are passed in the Trans2_Parameters block. The list of extended attribute name/value pairs is passed in the Trans2_Data block.

When opening a named pipe, if Server.Session.IsAnonymous is TRUE, the server MUST invoke the event specified in [MS-SRVS] section 3.1.6.17 by providing the FileName field with the "\PIPE\" prefix removed as input parameter. If the event returns FALSE, indicating that no matching named pipe is found that allows an anonymous user, the server MUST fail the request with STATUS_ACCESS_DENIED and MUST increase Server.Statistics.sts0_permerrors by 1. Otherwise, the server MUST continue the create processing.

When the Trans2 subsystem receives a TRANS2_OPEN2 Request (section 2.2.6.1.1), it MUST first attempt to open or create the named file. The name of the file to be opened is provided as a null-terminated string in the FileName field in the Trans2_Parameters block of the transaction. The requested access modes are listed in the DesiredAccess field of the request. If DesiredAccess is not granted in Share.FileSecurity for the user indicated by the UID, the server MUST fail the request with STATUS_ACCESS_DENIED. The OpenMode field indicates the action to be taken depending on whether the file does or does not already exist. If the underlying object store returns STATUS_ACCESS_DENIED, Server.Statistics.sts0_permerrors MUST be increased by 1.

If the file is created or overwritten (truncated), the AllocationSize field specifies the number of bytes that the server MUST pre-allocate for the file. If the file is created, the FileAttributes field provides a set of standard file attributes to be applied. The response also includes a FileAttributes field, which indicates the actual attributes of the file (those successfully applied if the file is created, or the existing attributes of the file if it is opened or truncated).

The Trans2_Parameters.Flags field MAY be used by the client to request an exclusive or a batch OpLock on the file. If the Open or Create operation is successful, the server MUST indicate whether the OpLock was granted in the ActionTaken field of the response. The ActionTaken field also indicates the action taken to open the file (create, open, or truncate).

The Trans2_Parameters.Flags field MAY also be used by the client to request additional information from the server. If the client requests additional information, the server MUST include the requested values, as specified in section 2.2.6.1.1; otherwise, the server SHOULD zero-fill the additional information fields.

If the file is successfully opened, and a set of extended attributes is included in the request, the server MUST attempt to apply the extended attributes to the file. If an error is generated when the extended attributes are applied, the offset in bytes from the start of the extended attribute list of the attribute that caused the error MUST be returned in the ExtendedAttributeErrorOffset field. A full SMB_COM_TRANSACTION2 Response (section 2.2.4.46.2) (not an error response) MUST be sent to the client. The error code is returned in the Status field of the final SMB_COM_TRANSACTION2 Response.<339>

If the TRANS2_OPEN2 successfully opens the file, Server.Statistics.sts0_fopens MUST be increased by 1, and the FID MUST be returned to the client. A new Server.Open object with the PID, UID, TID from the request header, and the new FID MUST be entered into the Server.Connection.FileOpenTable. 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 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.PathName MUST be set to the FileName field of the request. Server.Open.GrantedAccess MUST be set to the AccessMode field of the request.

The server MUST register the new FID 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 completed TRANS2_OPEN2 subcommand response MUST be returned to the client via the SMB_COM_TRANSACTION2 (section 2.2.4.46) transaction mechanism.