- struct wim_dentry *child;
- while (node) {
- if (ignore_case)
- child = rb_entry(node, struct wim_dentry, rb_node_case_insensitive);
- else
- child = rb_entry(node, struct wim_dentry, rb_node);
-
- int result = cmp_utf16le_strings(name,
- name_nbytes / 2,
- child->file_name,
- child->file_name_nbytes / 2,
- ignore_case);
- if (result < 0) {
- node = node->rb_left;
- } else if (result > 0) {
- node = node->rb_right;
- } else if (!ignore_case ||
- list_empty(&child->case_insensitive_conflict_list)) {
- return child;
- } else {
- /* Multiple dentries have the same case-insensitive
- * name, and a case-insensitive lookup is being
- * performed. Choose the dentry with the same
- * case-sensitive name, if one exists; otherwise print a
- * warning and choose one arbitrarily. */
- struct wim_dentry *alt = child;
- size_t num_alts = 0;
-
- do {
- num_alts++;
- if (0 == cmp_utf16le_strings(name,
- name_nbytes / 2,
- alt->file_name,
- alt->file_name_nbytes / 2,
- false))
- return alt;
- alt = list_entry(alt->case_insensitive_conflict_list.next,
- struct wim_dentry,
- case_insensitive_conflict_list);
- } while (alt != child);
-
- WARNING("Result of case-insensitive lookup is ambiguous\n"
- " (returning \"%"TS"\" of %zu "
- "possible files, including \"%"TS"\")",
- dentry_full_path(child),
- num_alts,
- dentry_full_path(list_entry(child->case_insensitive_conflict_list.next,
- struct wim_dentry,
- case_insensitive_conflict_list)));
- return child;
- }
- }
- return NULL;
+ if (!ignore_case)
+ /* Case-sensitive lookup. */
+ return dir_lookup(dir, &dummy);
+
+ /* Case-insensitive lookup. */
+
+ child = dir_lookup_ci(dir, &dummy);
+ if (!child)
+ return NULL;
+
+ if (likely(list_empty(&child->d_ci_conflict_list)))
+ /* Only one dentry has this case-insensitive name; return it */
+ return child;
+
+ /* Multiple dentries have the same case-insensitive name. Choose the
+ * dentry with the same case-sensitive name, if one exists; otherwise
+ * print a warning and choose one of the possible dentries arbitrarily.
+ */
+ struct wim_dentry *alt = child;
+ size_t num_alts = 0;
+
+ do {
+ num_alts++;
+ if (!dentry_compare_names_case_sensitive(&dummy, alt))
+ return alt;
+ alt = list_entry(alt->d_ci_conflict_list.next,
+ struct wim_dentry, d_ci_conflict_list);
+ } while (alt != child);
+
+ WARNING("Result of case-insensitive lookup is ambiguous\n"
+ " (returning \"%"TS"\" of %zu "
+ "possible files, including \"%"TS"\")",
+ dentry_full_path(child),
+ num_alts,
+ dentry_full_path(list_entry(child->d_ci_conflict_list.next,
+ struct wim_dentry,
+ d_ci_conflict_list)));
+ return child;