This is the mail archive of the mailing list for the eCos project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Should hard links to directories work?

Bart Veer wrote:
"Ross" == Ross Younger <> writes:

    Ross> The Unix world traditionally shuns such things as an
    Ross> abomination. The eCos docs are quiet on the subject, as is
    Ross> the code in ramfs and jffs2. Should they work? Does anybody
    Ross> use them?

    Ross> (By the way: I started this discussion with a bugzilla
    Ross> ticket, which as Andrew points out is probably the wrong
    Ross> place.
    Ross> )


  "The link() function creates a new link (directory entry) for the
  existing file, path1.

  The path1 argument points to a pathname naming an existing file. The
  path2 argument points to a pathname naming the new directory entry
  to be created. The link() function will atomically create a new link
  for the existing file and the link count of the file is incremented
  by one.

  If path1 names a directory, link() will fail unless the process has
  appropriate privileges and the implementation supports using link()
  on directories."

So creating links to directories is not completely disallowed, but
from my reading it is certainly discouraged. I would be happy with
changes to ramfs and jffs2 to prevent new links to directories.
jffs2 should probably continue to support such links in an existing
filesystem, in case they are created in another OS.

JFFS2's other OS is linux which does not support hard linked directories. Presumably at the VFS layer.

Since hard linking directories can cause infinite recursion in directory tree searches, I think they should be discouraged if at all possible.

For JFFS2, something like this in jffs2's fs-ecos.c:jffs2_ops_link() before the handling of dir2 should bring it into line with linux:

if (S_ISDIR(ds1.node->i_mode)) {
   return EPERM;

[Untested, and someone else would have to do that, sorry.]

I would not be surprised if hard-linked directories caused JFFS2's filesystem rebuild phase to blow up.

------["The best things in life aren't things."]------      Opinions==mine

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]