summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--e2fsck/rehash.c12
-rw-r--r--tests/f_dup_de2/expect.116
-rw-r--r--tests/f_dup_de2/expect.27
-rw-r--r--tests/f_dup_de2/image.gzbin0 -> 4860 bytes
-rw-r--r--tests/f_dup_de2/name1
5 files changed, 30 insertions, 6 deletions
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.
diff --git a/tests/f_dup_de2/expect.1 b/tests/f_dup_de2/expect.1
new file mode 100644
index 00000000..8dd3d912
--- /dev/null
+++ b/tests/f_dup_de2/expect.1
@@ -0,0 +1,16 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Duplicate entry 'test-008' found.
+ Marking / (2) to be rebuilt.
+
+Pass 3: Checking directory connectivity
+Pass 3A: Optimizing directories
+Entry 'test-008' in / (2) has a non-unique filename.
+Rename to test-0~0? yes
+
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 21/256 files (0.0% non-contiguous), 1087/2048 blocks
+Exit status is 1
diff --git a/tests/f_dup_de2/expect.2 b/tests/f_dup_de2/expect.2
new file mode 100644
index 00000000..8781274c
--- /dev/null
+++ b/tests/f_dup_de2/expect.2
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 21/256 files (0.0% non-contiguous), 1087/2048 blocks
+Exit status is 0
diff --git a/tests/f_dup_de2/image.gz b/tests/f_dup_de2/image.gz
new file mode 100644
index 00000000..a8e4db3e
--- /dev/null
+++ b/tests/f_dup_de2/image.gz
Binary files differ
diff --git a/tests/f_dup_de2/name b/tests/f_dup_de2/name
new file mode 100644
index 00000000..e337f102
--- /dev/null
+++ b/tests/f_dup_de2/name
@@ -0,0 +1 @@
+duplicate directory entries for non-indexed dirs