+static EXT2_QSORT_TYPE name_cf_cmp(const struct name_cmp_ctx *ctx,
+ const void *a, const void *b)
+{
+ const struct hash_entry *he_a = (const struct hash_entry *) a;
+ const struct hash_entry *he_b = (const struct hash_entry *) b;
+ unsigned int he_a_len, he_b_len;
+ int ret;
+
+ he_a_len = ext2fs_dirent_name_len(he_a->dir);
+ he_b_len = ext2fs_dirent_name_len(he_b->dir);
+
+ ret = ext2fs_casefold_cmp(ctx->tbl,
+ (unsigned char *) he_a->dir->name, he_a_len,
+ (unsigned char *) he_b->dir->name, he_b_len);
+ if (ret == 0) {
+ if (he_a_len > he_b_len)
+ ret = 1;
+ else if (he_a_len < he_b_len)
+ ret = -1;
+ else
+ ret = he_b->dir->inode - he_a->dir->inode;
+ }
+ return ret;
+}
+