Skip to contentSkip to conversation

ext2/3 bugfix 2/6: readdir() needs to return '.' and '..'

PATCH New [email protected] 1 participant 1 message Nov 7, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext2/3 bugfix 2/6: readdir() needs to return '.' and '..'

Add '.' and '..' entries to be returned by readdir of htree directories

This patch from Chris Li adds '.' and '..' to the rbtree so that they are properly returned by readdir.

namei.c | 9 +++++++++

1 files changed, 9 insertions(+)
fs/ext3/namei.c +9 -0
diff -Nru a/fs/ext3/namei.c b/fs/ext3/namei.c
@@ -549,6 +549,15 @@
 	if (!frame)
 		return err;
 
+	/* Add '.' and '..' from the htree header */
+	if (!start_hash && !start_minor_hash) {
+		de = (struct ext3_dir_entry_2 *) frames[0].bh->b_data;
+		ext3_htree_store_dirent(dir_file, 0, 0, de);
+		de = ext3_next_entry(de);
+		ext3_htree_store_dirent(dir_file, 0, 0, de);
+		count += 2;
+	}
+
 	while (1) {
 		block = dx_get_block(frame->at);
 		dxtrace(printk("Reading block %d\n", block));