Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jul 2011 08:17:21 -0700
From:      perryh@pluto.rain.com
To:        jang@ioctl.org, jan.grant@bristol.ac.uk
Cc:        freebsd-hackers@freebsd.org, rwatson@freebsd.org, s@samu.pl
Subject:   Re: Finding symlink information in MAC Framework
Message-ID:  <4e32cf01.R6F64Wsxhnb%2Bt0xb%perryh@pluto.rain.com>
In-Reply-To: <alpine.BSF.2.00.1107281632110.58073@tribble.ilrt.bris.ac.uk>
References:  <c0c76b43d88b48a8b354df409b5167e5@samu.pl> <alpine.BSF.2.00.1107250942340.51541@fledge.watson.org> <cdf7c352c5d4a2edc308a6e1ab7d63c0@samu.pl> <4e303567.2SHj2vERr0n8Op6Q%perryh@pluto.rain.com> <alpine.BSF.2.00.1107281632110.58073@tribble.ilrt.bris.ac.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
jan.grant@bristol.ac.uk wrote:

> On Wed, 27 Jul 2011, perryh@pluto.rain.com wrote:
...
> One additional thing that symlinks manage to do is to refer to
> directories as well as files

Yes; I left that aspect out by way of simplification since it did
not seem pertinent to the OP's situation.

> hard links to directories spawn problems such as requiring garbage
> collection and smarter filesystem descent algorithms, which is
> another reason they're typically prohibited except in the case
> where they're created by "mkdir".

or by "mv", when moving a directory within the same physical
filesystem.

The two biggest problems I'm aware of are:

* They create the possibility that the filesystem is no longer a
  tree but a more general directed graph which may even be cyclic.
  The possibility of a cyclic graph would indeed require handling
  in utilities such as find(1) and "ls -R", but the only case I've
  thought of that would need garbage collection -- as opposed to
  some minor extension of the current reference-counting scheme
  -- would be detection of cycles that have become disconnected
  (unreachable from either the root or any currently-open
  directory).

  However, I think prohibition of hard-links to directories is not
  sufficient to prevent the creation of isolated cycles.  Consider:

  $ mkdir -p /tmp/a/b/c/d/e/f/g
  $ cd /tmp/a/b/c/d/e
  $ mv /tmp/a/b f/g

  Unless either mv or the kernel goes to some trouble to detect the
  subterfuge, this will create an isolated cycle f/g/b/c/d/e/f/...

* Where should my .. entry point, if links to me (other than my .
  entry and my subdirectories' .. entries) appear in more than one
  directory?

> FWIW one of the early unix systems I was exposed to permitted the
> creation of hard links by arbitrary users.

Just _one_?  I've never heard of any that did _not_ permit that!
(AFAIK Posix requires it.)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4e32cf01.R6F64Wsxhnb%2Bt0xb%perryh>