Re: [PATCH] ramfs: pretend dirent sizes

From: Jörn Engel
Date: Thu Jul 21 2005 - 02:28:51 EST


On Wed, 20 July 2005 20:48:17 +0200, Jan Blunck wrote:
>
> 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.

So you use file->offset of the pseudo-directory representing the whole
union stack for two values:
1. level within the union stack we're currently at and
2. offset within the real directory at said level.

And you need a sane value for i_size at every level (but perhaps the
last) to break the converged file->offset apart into (level, offset)
again. Right?

> >>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!

Yep. Two consecutive open() on the "same file" are racy, so anything
could have happened in between. That's a well-known proplem in
userspace.

Jörn

--
Linux is more the core point of a concept that surrounds "open source"
which, in turn, is based on a false concept. This concept is that
people actually want to look at source code.
-- Rob Enderle
-
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/