3.3.5.58.3 Receiving a TRANS2_FIND_FIRST2 Request

The server MUST perform a directory search using the FileName field as the pattern with which to search. If the FileName field is an empty string, the server MUST return all the files that are present in the directory. The path indicated in the FileName field MUST exist within the specified TID, and the TID MUST indicate a file system share.

The SearchAttributes and Flags fields are used to further refine the search, as specified in section 2.2.6.2.1.

If the InformationLevel parameter field in the request is set to SMB_INFO_QUERY_EAS_FROM_LIST (section 2.2.8.1.3), the server MUST scan the EA list of each matching file and return the EAs that match the AttributeName field values specified in the GetExtendedAttributeList field of the request. Any errors in reading the list of requested EAs MUST be reported by sending a full response (not an error response) with the Status field set to indicate the error. The offset of the EA that caused the error is measured in bytes from the start of the GetExtendedAttributeList.GEAList field in the Trans2_Data block of the request and is reported in the EAErrorOffset field of the response.

The response format is dependent upon the InformationLevel requested, as specified in 2.2.8.1. The number of search result entries sent in the response is the minimum of:

  • The number of entries found.

  • The value of the SearchCount field in the request.

  • The number of entries that can fit into the response without exceeding the MaxDataCount field limit sent in the client's SMB_COM_TRANSACTION2 Request (section 2.2.4.46.1).

If no matching entries are found, the server SHOULD<340> fail the request with STATUS_NO_SUCH_FILE.

If the entire list of file system objects found by the search fit within a single response and SMB_FIND_CLOSE_AT_EOS is set in the Flags field, or if SMB_FIND_CLOSE_AFTER_REQUEST is set in the request, the server SHOULD<341> return a SID field value of zero. This indicates that the search has been closed and is no longer active on the server.<342>

Otherwise, if the number of entries in Server.Connection.SearchOpenTable is greater than or equal to Server.MaxSearches, the server MUST fail the request with STATUS_OS2_NO_MORE_SIDS. If not, the search remains open and can be continued with a TRANS2_FIND_NEXT2 Request (section 2.2.6.3.1) or closed using an SMB_COM_FIND_CLOSE2 Request (section 2.2.4.48.1).

If the search is to remain open, the server MUST allocate a SearchOpen object and insert it into Server.Connection.SearchOpenTable. The following values MUST be set by the server:

  • Server. SearchOpen.MID: The value of the MID from the SMB Header of the client request.

  • Server.SearchOpen.PID: The value of the PID from the SMB Header of the client request.

  • Server.SearchOpen.TID: The value of the TID from the SMB Header of the client request.

  • Server.SearchOpen.UID: The value of the UID from the SMB Header of the client request.

  • Server.SearchOpen.FindSID: A newly generated Search ID (SID) value, as specified in section 2.2.1.6.5.

  • Server.SearchOpen.PathName: The FileName in the client request, with its final component removed.

The search results MUST be returned to the client in a TRANS2_FIND_FIRST2 Response (section 2.2.6.2.2), which MUST be sent to the client as specified in section 3.3.4.1.