Re: [PATCH] ramfs: pretend dirent sizes

From: Jan Blunck
Date: Wed Jul 20 2005 - 13:47:22 EST


Chris Wedgwood wrote:

To my understanding, you can lseek to any "proper" offset inside a
directory. Proper means that the offset marks the beginning of a
new dirent (or end of file) in the interpretation of the filesystem.


But you can never tell where these are in general.



I don't want to tell where these are in general, I need an easy way to seek to the m'th directory + offset position without reading every single dirent. With i_sizes != 0 it is straight forward to use "the sum of the m directory's i_sizes + offset" as the f_pos to seek to. For this purpose it is not necessary to have a "honest" i_size as long as the i_size is bigger than the offset of the last dirent in the directory.


I don't see why or how this can be true in general (it might be, but I
don't see how myself). If we are half way through scanning a
directory and people start messing with it we could end up somewhere
bogus (in which case f_op->readdir I guess is expected to try and do
something sane here?)


E.g.: ext2_validate_entry() is called if filp->f_version != inode->i_version.


Reopening the same directory may result in a formerly proper offset
isn't anymore.


Which is a user problem again. Might be that you are opening a different directory with the same name ... or even a regular file!

Jan
-
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/