[lkml]   [1999]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: I discussed reading directories as files with jra, Stallman, and loic
In article <m10vnlI-003VuJC@reiser>, root  <> wrote:
>I convinced him that directories can do this, and do it cleaner than
>that MS crud they use as an FS model. The directories need a few
>features added though.
>First, they need to be able to have a file that when you read them they
>resolve to. That is, inside the directory there is one file that when
>you open (dirname) you get a file descriptor pointing to
>dirname/default. Now please note that dirname/default can be a symlink,
>a hard link (presumably to a file within the same directory), it can be
>all sorts of things. It can also be called something like "....", or
>even "". I have to think some about which I like.

Note that the Linux VFS layer was pretty much _designed_ with something
like this in mind. From very early on, I decided that the VFS layer
should not make too much of a distinction between a directory and a
regular file: both have "lookup" properties, and both have "read"

Some of that has been corrupted over time, and some of it was never done
because nobody actually used it - so there's a few places where the VFS
layer does things like "if (!S_ISDIR(d_inode->i_imode))" etc and thus
"knows" about the difference between a directory and a regular file, but
that was never really meant to be a design goal, and I'd be happy to try
to clean it up.

So basically it all should be doable today: if a low-level filesystem
wants to export directories both as regular files and as pathname
components, it can be done. The low-level FS can look at the
O_DIRECTORY flag to know whether somebody wants to read the thing as a
directory or not (ie "readdir()" obviously opens the directory, while
normal operations open the default file), and it should all work pretty
much today.

It's going to confuse a lot of UNIX applications, but at the same time a
reasonable number of them won't ever really have to know.

>Next files need to be able to inherit stat data, so that a file can
>share its modification time with its parent directory, so that modifying
>the file changes the mod time on the directory.

I don't think that is true. I think the directory and the file should be
considered separate, it's just that "lookup()" can find one or the other
depending on use..

So I think it should be considered a _naming_ issue, and not much else.

>Finally, you need a new file type flag indicating that it is both a file
>and a directory.

Not necessarily. Just open it with O_DIRECTORY (or with a slash at the
end) and it gets opened as a directory, otherwise it gets opened as the
file. Works today, and is the most transparent option anyway.

Things like "tar" etc probably need to be taught about how to see
distinctions like that, and we may want to have other ways of accessing
the information, but I don't think we _have_ to have them.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:52    [W:0.138 / U:1.216 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site