Re: [CFT][PATCH] ext2 directories in pagecache

From: Alexander Viro (viro@math.psu.edu)
Date: Tue Sep 26 2000 - 17:31:04 EST


On Wed, 27 Sep 2000, Marko Kreen wrote:

> On Tue, Sep 26, 2000 at 05:29:27PM -0400, Alexander Viro wrote:
> > Comments and help in testing are more than welcome.
>
> There is something fishy in ext2_empty_dir:

Why?

> + /* check for . and .. */
> + if (de->name[0] != '.')
> + goto not_empty;

Doesn't start with '.' - definitely not an empty directory

> + if (!de->name[1]) {

OK, it's {'.','\0'}, aka. ".".

> + if (de->inode !=
> + le32_to_cpu(inode->i_ino))

Consistency check... Aha, I see. Yup, s/le32_to_cpu/cpu_to_le32/. Doesn't
matter on all normal architectures, but yes, it's still wrong.

> + goto not_empty;

If we have it screwed - leave it as is and don't mess with it.
Otherwise - skip this record, it's all right for empty directory.

> + } else if (de->name[2])

Starts with '.' and longer than 2 characters? Not empty.

> + goto not_empty;
> + else if (de->name[1] != '.')

Starts with '.', 2 characters, but the second isn't '.'? Not empty.

> + goto not_empty;

Otherwise - skip the record.

        So checks are OK, the only thing being that we should use
cpu_to_le32() instead of le32_to_cpu(). Doesn't affect the behaviour right
now, but ought to be fixed anyway.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Sep 30 2000 - 21:00:18 EST