Re: [PATCH] ramfs: pretend dirent sizes

From: Jan Blunck
Date: Tue Jul 19 2005 - 13:21:54 EST


Chris Wedgwood wrote:

I'm using the i_size of directories in my patches. When reading
from a union directory, I'm using the i_size to seek to the right
offset in the union stack.


Ick. That'a a bit of a hack.


Don't think so:

1st dir: [XXXXXXXXXXXXXXXXXXXXX]
f_pos=0 f_pos=i_size(1st)


2nd dir: [XXXXXXXXXXX|---------]
f_pos=i_size(1st) f_pos=i_size(1st+2nd)
^
| f_pos=i_size(1st)+offset

Since these "arranged" values are also used as the offsets in the return dirent IMO it is quite clean.


Hence the value of 20 I guess --- assuming nothing will stack this
high?


Nope. This value is kind of traditional: tmpfs is using it (http://marc.theaimsgroup.com/?l=linux-kernel&m=103208296515378&w=2). I think a better value would be 1 (one) since this is also used as the dirent offset by dcache_readdir().


I personally would prefer that to be honest or some other way that
doesn't change i_size.

The i_size of a directory isn't covered by the POSIX standard. IMO, it should be possible to seek in the range of i_size and a following readdir() on the directory should succeed. But this isn't possible even not with real file systems like ext2.
But keeping the i_size bound to zero even if the directory contains entries does not make sense at all.

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/