* @brief Directory indexing procedures.
*/
-#include "ext4_config.h"
-#include "ext4_types.h"
-#include "ext4_misc.h"
-#include "ext4_errno.h"
-#include "ext4_debug.h"
-
-#include "ext4_trans.h"
-#include "ext4_dir_idx.h"
-#include "ext4_dir.h"
-#include "ext4_blockdev.h"
-#include "ext4_fs.h"
-#include "ext4_super.h"
-#include "ext4_inode.h"
-#include "ext4_crc32.h"
-#include "ext4_hash.h"
+#include <ext4_config.h>
+#include <ext4_types.h>
+#include <ext4_misc.h>
+#include <ext4_errno.h>
+#include <ext4_debug.h>
+
+#include <ext4_trans.h>
+#include <ext4_dir_idx.h>
+#include <ext4_dir.h>
+#include <ext4_blockdev.h>
+#include <ext4_fs.h>
+#include <ext4_super.h>
+#include <ext4_inode.h>
+#include <ext4_crc32.h>
+#include <ext4_hash.h>
#include <string.h>
#include <stdlib.h>
return rc;
}
-#if CONFIG_DIR_INDEX_COMB_SORT
-#define SWAP_ENTRY(se1, se2) \
- do { \
- struct ext4_dx_sort_entry tmp = se1; \
- se1 = se2; \
- se2 = tmp; \
- \
-} while (0)
-
-static void comb_sort(struct ext4_dx_sort_entry *se, uint32_t count)
-{
- struct ext4_dx_sort_entry *p, *q, *top = se + count - 1;
- bool more;
- /* Combsort */
- while (count > 2) {
- count = (count * 10) / 13;
- if (count - 9 < 2)
- count = 11;
- for (p = top, q = p - count; q >= se; p--, q--)
- if (p->hash < q->hash)
- SWAP_ENTRY(*p, *q);
- }
- /* Bubblesort */
- do {
- more = 0;
- q = top;
- while (q-- > se) {
- if (q[1].hash >= q[0].hash)
- continue;
- SWAP_ENTRY(*(q + 1), *q);
- more = 1;
- }
- } while (more);
-}
-#else
-
/**@brief Compare function used to pass in quicksort implementation.
* It can compare two entries by hash value.
* @param arg1 First entry
else
return 1;
}
-#endif
/**@brief Insert new index entry to block.
* Note that space for new entry must be checked by caller.
de = (void *)((uint8_t *)de + elen);
}
-/* Sort all entries */
-#if CONFIG_DIR_INDEX_COMB_SORT
- comb_sort(sort, idx);
-#else
qsort(sort, idx, sizeof(struct ext4_dx_sort_entry),
ext4_dir_dx_entry_comparator);
-#endif
+
/* Allocate new block for store the second part of entries */
ext4_fsblk_t new_fblock;
uint32_t new_iblock;