Re: Fw: [POSSIBLE-BUG] telldir() broken on ext3 dir_index'd directories just after the first entry.
From: Theodore Ts'o
Date: Wed Nov 17 2004 - 23:57:09 EST
On Thu, Nov 18, 2004 at 12:00:05AM +0000, Stephen C. Tweedie wrote:
>
> Doesn't this make things worse?
> don't we end up silently ignoring all dirents with a major hash <= 1,
> even for unbroken getdents() with no intervening seekdir?
Oops, yes, I screwed up.
> If we're going to do this, I think we need to stuff . and .. into the
> rbtree with the right hashes, but without ignoring other existing
> dirents with colliding hashes.
We can't just do that, because there are programs that's assume '.'
and '..' are the first and second entries in the directory. Yes, they
are broken and non-portable, but so are programs that depend on
d_off....
So instead what we need to do is wire '.' and '..' to have hash values
of (0,0) and (2,0), respectively, without ignoring other existing
dirents with colliding hashes. (In those cases the programs will
break, but they are statistically rare, and there's not much we can do
in those cases anyway.)
This patch should do this.
Signed-off-by: "Theodore Ts'o" <tytso@xxxxxxx>
--- 1.59/fs/ext3/namei.c 2004-10-19 05:40:30 -04:00
+++ edited/fs/ext3/namei.c 2004-11-17 23:05:35 -05:00
@@ -610,10 +610,14 @@ int ext3_htree_fill_tree(struct file *di
de = (struct ext3_dir_entry_2 *) frames[0].bh->b_data;
if ((err = ext3_htree_store_dirent(dir_file, 0, 0, de)) != 0)
goto errout;
+ count++;
+ }
+ if (start_hash < 2 || (start_hash ==2 && start_minor_hash==0)) {
+ de = (struct ext3_dir_entry_2 *) frames[0].bh->b_data;
de = ext3_next_entry(de);
- if ((err = ext3_htree_store_dirent(dir_file, 0, 0, de)) != 0)
+ if ((err = ext3_htree_store_dirent(dir_file, 2, 0, de)) != 0)
goto errout;
- count += 2;
+ count++;
}
while (1) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/