Jamie Lokier wrote:
>
> Ben Fennema wrote:
> > My first question is, CAN I actually use lookup and readdir on a file
> > (Is it ls being too smart by looking at the thing, deceiding its not a
> > directory, and giving up -- or is it the kernel?)
>
> The kernel will more or less do what you ask, though Alex Viro's
> concerns are valid.
>
> In particular, from my quick skim of fs/namei.c and fs/open.c, namei
> will accept your pseudo-directory as a path component, open with
> O_DIRECTORY will open it, and readdir will read it.
>
> So almost everything is there for you to try. The one glaring
> inconsistency there is that you can't chdir to it. I've attached a
> patch (compiled but untested) which should fix that.
>
> The reason you might like to try it but _don't_ make it mainstream are
> things like this: you open a file inside your pseudo-directory. You
> unlink() the pseudo-directory. The unlink _succeeds_ because it passes
> the !S_ISDIR check. Now what happens to the child dentries?
Well, theres a few other pain in the butt things to consider.
One, I have to keep track of the file sizes of all the files in the streams
directory (there is a record of the total size of the main file + all
streams) I guess I'd need a link from the stream file to the main file,
so when the stream file gets written out and the size differs from the
on-disc size, I adjust the main file total size. Sounds like race city :)
The link count of a file w/ stream is + 1, so the whole thing will just
get pruned from the tree but still exist *laf* (Of course phyiscal link
count doesn't have to equal inode->i_count)
Removing the file is supposed to unlink the stream directory and all files
in it.
> Overall summary
> ---------------
>
> The obvious anomalies for the user experience are chdir/fchdir. I think
> they should be changed to call __namei() with
> LOOKUP_DIRECTORY|LOOKUP_FOLLOW, instead of just LOOKUP_FOLLOW as they do
> now. (namei(s) just calls __namei(s,LOOKUP_FOLLOW)). And drop the
> S_ISDIR check.
>
> With that tiny change you could chdir into your UDF directories
It looks simple enough. Prolly still not a good idea though, but
probably not bad for testing.
Ben
--
Linux UDF - http://www.trylinux.com/projects/udf/index.html
Latest Is - udf-0.9.1 (http://www.csc.calpoly.edu/~bfennema/udf.html)