• File/Directory Unification

    From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.misc on Sun Sep 14 07:07:29 2025
    From Newsgroup: comp.misc

    I recall an interview with Hans Reiser many years ago (before he was done
    for murdering his wife, obviously), when he was still working on the
    Reiser4 filesystem, the intended successor to ReiserFS, where he mentioned
    one of its notable features (besides tail-packing -- notable to me,
    anyway!) was that every file was also a directory, and every directory was
    a file.

    To put it another way, each item in the filesystem has a “data fork” and a “directory fork”; if you open it as a file, you can read and write the data fork. If you open it as a directory, then you can access and
    manipulate the set of child items referenced in the directory fork, which
    in turn are themselves both files and directories.

    Either fork can be empty, of course. So to represent a conventional POSIX directory, you leave the data fork empty; and to represent a conventional POSIX file, you leave the directory fork empty.

    This sounded like a neat idea. But, thinking about it, I realized recently
    it can’t really work on POSIX systems. (Or maybe it can ... see below.)

    The problem is that POSIX allows multiple hard links to a file, but not to
    a directory. There are good reasons for this. So if every file can also be
    a directory, then you must either forbid multiple-linking for *all*
    filesystem items, or rescind the rule against it, with consequent
    unpleasant ramifications for the integrity of your filesystem.

    Alternatively, you could keep the rule, and just forbid creating a second
    hard link to an item with a nonempty directory fork; and conversely,
    forbid creating a nonempty directory fork on an item which is already hard-linked into more than one parent directory.

    That would be a way to make it work.

    You still have the ambiguity that a newly-created item has both an empty
    data fork and empty directory fork, so it has the potential to turn into either a POSIX-type file or a POSIX-type directory, depending on which
    fork has stuff added to it first ...
    --- Synchronet 3.21a-Linux NewsLink 1.2