From b71e01835ff844d5be09ecbf7e51acad4d75447b Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 16 Nov 2009 21:56:24 -0500 Subject: e2fsck: Fix duplicate directory entries for non-indexed directories Duplicate directory entries were not necessarily getting found and fixed for non-indexed directories, since we were sorting these directories by inode number, and the duplicate entry code assumed the entries were getting sorted by name or directory name hash. Addresses-Sourceforge-Bug: #2862551 Signed-off-by: "Theodore Ts'o" --- e2fsck/rehash.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'e2fsck/rehash.c') diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c index 50388f36..46d04e49 100644 --- a/e2fsck/rehash.c +++ b/e2fsck/rehash.c @@ -751,12 +751,7 @@ errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino) /* Sort the list */ resort: - if (fd.compress) - qsort(fd.harray+2, fd.num_array-2, - sizeof(struct hash_entry), ino_cmp); - else - qsort(fd.harray, fd.num_array, - sizeof(struct hash_entry), hash_cmp); + qsort(fd.harray, fd.num_array, sizeof(struct hash_entry), hash_cmp); /* * Look for duplicates @@ -769,6 +764,11 @@ resort: goto errout; } + /* Sort non-hashed directories by inode number */ + if (fd.compress) + qsort(fd.harray+2, fd.num_array-2, + sizeof(struct hash_entry), ino_cmp); + /* * Copy the directory entries. In a htree directory these * will become the leaf nodes. -- cgit v1.2.3