Re: FS: hardlinks on directories

Stephan von Krawczynski
2003-08-04T13:32:40Z

On Mon, 4 Aug 2003 16:47:14 +0400
Nikita Danilov <Nikita@Namesys.COM> wrote:

> Hard links on directories are hard to do in the UNIX file system model.
>
> Where ".." should point? How to implement rmdir? You can think about
> UNIX unlink as some form of reference counter based garbage
> collector---when last (persistent) reference to the object is removed it
> is safe to recycle it. It is well-known that reference counting GC
> cannot cope with cyclical references. Usually this is not a problem for
> the file system because all cyclical references are very well
> known---they always involve "." and "..". But as one allows hard links
> on directories, file system is no longer tree, but generic directed
> graph and reference counting GC wouldn't work.

If file-/directory-nodes are single-linked list nodes inside one directory, and
directory-nodes pointing to the same directory are single-linked list nodes,
you can:

- ".." do as first node of a directory and the "shared" part of the directory
follows on its next-pointer, so you have one ".." for every hard-link.
- implement rmdir as throw-away dir-node and ".." node and only if pointer to
next hw-linked directory-node is itself remove rest of linked node list

Are there further questionable operations?

Regards,
Stephan