path: root/fsck-objects.c
diff options
authorJunio C Hamano <>2006-01-20 01:13:51 (GMT)
committerJunio C Hamano <>2006-01-22 03:33:22 (GMT)
commit35a730f01c6caba93d452fa938e7d93ffcc4cf25 (patch)
treeceeeafb38d09feb7bd0230fe85ac34c438ad0a33 /fsck-objects.c
parentbdc37f5a817543fc5eaf16dd6f30dd7b821adc70 (diff)
fsck-objects: support platforms without d_ino in struct dirent.
The d_ino field is only used for performance reasons in fsck-objects. On a typical filesystem, i-number tends to have a strong correlation with where the actual bits sit on the disk platter, and we sort the entries to allow us scan things that ought to be close together together. If the platform lacks support for it, it is not a big deal. Just do not use d_ino for sorting, and scan them unsorted. Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'fsck-objects.c')
1 files changed, 11 insertions, 2 deletions
diff --git a/fsck-objects.c b/fsck-objects.c
index 90e638e..9950be2 100644
--- a/fsck-objects.c
+++ b/fsck-objects.c
@@ -20,6 +20,13 @@ static int check_strict = 0;
static int keep_cache_objects = 0;
static unsigned char head_sha1[20];
+#define SORT_DIRENT 0
+#define DIRENT_SORT_HINT(de) 0
+#define SORT_DIRENT 1
+#define DIRENT_SORT_HINT(de) ((de)->d_ino)
static void objreport(struct object *obj, const char *severity,
const char *err, va_list params)
@@ -307,7 +314,9 @@ static void fsck_sha1_list(void)
int i, nr =;
- qsort(sha1_list.entry, nr, sizeof(struct sha1_entry *), ino_compare);
+ qsort(sha1_list.entry, nr,
+ sizeof(struct sha1_entry *), ino_compare);
for (i = 0; i < nr; i++) {
struct sha1_entry *entry = sha1_list.entry[i];
unsigned char *sha1 = entry->sha1;
@@ -361,7 +370,7 @@ static int fsck_dir(int i, char *path)
memcpy(name+2, de->d_name, len+1);
if (get_sha1_hex(name, sha1) < 0)
- add_sha1_list(sha1, de->d_ino);
+ add_sha1_list(sha1, DIRENT_SORT_HINT(de));
fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);