public inbox for ecos-devel@sourceware.org
 help / color / mirror / Atom feed
* Re: Should hard links to directories work?
@ 2009-05-20 14:21 sandeep
  2009-05-20 14:47 ` Ross Younger
  2009-05-20 16:00 ` Rutger Hofman
  0 siblings, 2 replies; 9+ messages in thread
From: sandeep @ 2009-05-20 14:21 UTC (permalink / raw)
  To: ecos-devel, Ross Younger


Hi Ross,

Younger ;) people often have interesting questions and are responsible for fresh insights.

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

Before we discuss it further, where/how do you think you will use directory hardlinking, if it were available for normal user?

Sandeep


      

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Should hard links to directories work?
  2009-05-20 14:21 Should hard links to directories work? sandeep
@ 2009-05-20 14:47 ` Ross Younger
  2009-05-20 16:00 ` Rutger Hofman
  1 sibling, 0 replies; 9+ messages in thread
From: Ross Younger @ 2009-05-20 14:47 UTC (permalink / raw)
  To: sandeep; +Cc: ecos-devel

sandeep wrote:
> Before we discuss it further, where/how do you think you will use directory hardlinking ...

I don't have a use for it :-) - I only ask as I'm integrating the YAFFS
filesystem (see discussion elsewhere on these lists...) and thought of the
question while writing test cases.

FWIW, the only time I've ever come across directory hardlinks being useful
is in a chroot on a standard Unix system where it's sometimes a good idea to
nobble '..' (usually to be the same as '.') to preclude one of the standard
gaol-escape tricks.

> ... if it were available for normal user?

Remember that eCos has no concept of users. Everything runs in the kernel -
everything is privileged, arguably higher than the 'root' user of the
standard Unix model.


Ross

-- 
Embedded Software Engineer, eCosCentric Limited.
Barnwell House, Barnwell Drive, Cambridge CB5 8UU, UK.
Registered in England no. 4422071.                  www.ecoscentric.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Should hard links to directories work?
  2009-05-20 14:21 Should hard links to directories work? sandeep
  2009-05-20 14:47 ` Ross Younger
@ 2009-05-20 16:00 ` Rutger Hofman
  2009-05-20 16:35   ` Nick Garnett
  1 sibling, 1 reply; 9+ messages in thread
From: Rutger Hofman @ 2009-05-20 16:00 UTC (permalink / raw)
  To: sandeep; +Cc: ecos-devel, Ross Younger

sandeep wrote:
> Hi Ross,
> 
> Younger ;) people often have interesting questions and are responsible for fresh insights.
> 
>> The Unix world traditionally shuns such things as an abomination.
>> The eCos docs are quiet on the subject, as is the code in
>> ramfs and jffs2.
>> Should they work? Does anybody use them?
> 
> Before we discuss it further, where/how do you think you will use directory hardlinking, if it were available for normal user?

FWIW, the Amoeba distributed OS had hard links to directories. It had no 
soft links at all. It introduces loops in the directory 'hierarchy' 
(because of the loops, there is no hierarchy any more), so e.g. find(1) 
had to be armed with loop detection.

Rutger

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Should hard links to directories work?
  2009-05-20 16:00 ` Rutger Hofman
@ 2009-05-20 16:35   ` Nick Garnett
  0 siblings, 0 replies; 9+ messages in thread
From: Nick Garnett @ 2009-05-20 16:35 UTC (permalink / raw)
  To: Rutger Hofman; +Cc: ecos-devel, Ross Younger

Rutger Hofman <rutger@cs.vu.nl> writes:

> sandeep wrote:
> > Hi Ross,
> > Younger ;) people often have interesting questions and are
> > responsible for fresh insights.
> >
> >> The Unix world traditionally shuns such things as an abomination.
> >> The eCos docs are quiet on the subject, as is the code in
> >> ramfs and jffs2.
> >> Should they work? Does anybody use them?
> > Before we discuss it further, where/how do you think you will use
> > directory hardlinking, if it were available for normal user?
> 
> FWIW, the Amoeba distributed OS had hard links to directories. It had
> no soft links at all. It introduces loops in the directory 'hierarchy'
> (because of the loops, there is no hierarchy any more), so
> e.g. find(1) had to be armed with loop detection.

Although, as a capability based operating system, hard links, in the
form of saved capabilities, were an essential feature of Amoeba to
confer and control access within the filesystem.

The main capability operating system I used (Chaos on the Cambridge
CAP machine) also implemented a directed graph filesystem. This
required a garbage collector to be run on it regularly to clean up
detached cycles. This is also why directory hard links are generally
not permitted, since detached cycles are hard to remove.

In eCos, support for hard directory links should generally be a
filesystem property. If a particular filesystem can deal with the
consequences the they should be passed through the other layers
without comment. For YAFFS, I suspect that they should not be
permitted.

-- 
Nick Garnett                                       eCos Kernel Architect
eCosCentric Limited    http://www.eCosCentric.com       The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.      Tel: +44 1223 245571
Registered in England and Wales:                         Reg No: 4422071

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Should hard links to directories work?
  2009-05-20 13:45 ` Bart Veer
  2009-05-20 13:52   ` Gary Thomas
@ 2009-05-20 16:56   ` Jonathan Larmour
  1 sibling, 0 replies; 9+ messages in thread
From: Jonathan Larmour @ 2009-05-20 16:56 UTC (permalink / raw)
  To: Bart Veer; +Cc: Ross Younger, ecos-devel

Bart Veer wrote:
>>>>>>"Ross" == Ross Younger <wry@ecoscentric.com> 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> http://bugzilla.ecoscentric.com/show_bug.cgi?id=1000775 )
> 
> From http://www.opengroup.org/onlinepubs/7990989775/xsh/link.html:
> 
>   "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)) {
    jffs2_iput(ds1.dir);
    jffs2_iput(ds1.node);
    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.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Should hard links to directories work?
  2009-05-20 13:52   ` Gary Thomas
@ 2009-05-20 14:42     ` Ross Younger
  0 siblings, 0 replies; 9+ messages in thread
From: Ross Younger @ 2009-05-20 14:42 UTC (permalink / raw)
  To: Gary Thomas; +Cc: Bart Veer, ecos-devel

Gary Thomas wrote:
> What about "./." and "./.."?  Those must certainly be allowed.

What about them? They're supported in the standard way, though each
filesystem does something different.

ramfs adds links (via an internal mechanism) to . and .. when a directory is
created, and does not appear to special-case them. It therefore seems
plausible that you might unlink '..' - or even '.' if you were mad enough -
and perhaps create fresh links pointing somewhere else.

As mk_romfs builds up a filesystem it adds . and .. links to the output
image in the conventional way, ignoring wherever they point on the
filesystem it reads from. It also doesn't appear to check for directory
hardlinks at all, anywhere, so if you do have a filesystem with such a hard
link, it presumably won't be maintained in your output romfs.

fatfs adds . and .. links when a directory is created, removes them when it
is deleted, and doesn't allow link() anyway so you can't change them.

jffs2 special-cases . and .. without making the links visible on-disk; a
path element of '.' is simply consumed, and '..' goes to the parent node of
the current node. (This is also what I've done in my YAFFS port.)


So, in short, of the four filesystems currently in eCos, all afford '.' and
'..' their usual behaviour by default. In three of them, this behaviour is
fixed in the code; only one, ramfs, might allow you to get jiggy with them,
but I haven't tested this and wouldn't want to. For a start, if you do touch
'..', you risk getting very very confused, and perhaps breaking getcwd(). DDTT!


Ross

-- 
Embedded Software Engineer, eCosCentric Limited.
Barnwell House, Barnwell Drive, Cambridge CB5 8UU, UK.
Registered in England no. 4422071.                  www.ecoscentric.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Should hard links to directories work?
  2009-05-20 13:45 ` Bart Veer
@ 2009-05-20 13:52   ` Gary Thomas
  2009-05-20 14:42     ` Ross Younger
  2009-05-20 16:56   ` Jonathan Larmour
  1 sibling, 1 reply; 9+ messages in thread
From: Gary Thomas @ 2009-05-20 13:52 UTC (permalink / raw)
  To: Bart Veer; +Cc: Ross Younger, ecos-devel

Bart Veer wrote:
>>>>>> "Ross" == Ross Younger <wry@ecoscentric.com> 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> http://bugzilla.ecoscentric.com/show_bug.cgi?id=1000775 )
> 
>From http://www.opengroup.org/onlinepubs/7990989775/xsh/link.html:
> 
>   "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.

What about "./." and "./.."?  Those must certainly be allowed.

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Should hard links to directories work?
  2009-05-20 12:28 Ross Younger
@ 2009-05-20 13:45 ` Bart Veer
  2009-05-20 13:52   ` Gary Thomas
  2009-05-20 16:56   ` Jonathan Larmour
  0 siblings, 2 replies; 9+ messages in thread
From: Bart Veer @ 2009-05-20 13:45 UTC (permalink / raw)
  To: Ross Younger; +Cc: ecos-devel

>>>>> "Ross" == Ross Younger <wry@ecoscentric.com> 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> http://bugzilla.ecoscentric.com/show_bug.cgi?id=1000775 )

From http://www.opengroup.org/onlinepubs/7990989775/xsh/link.html:

  "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.

Bart

-- 
Bart Veer                                   eCos Configuration Architect
eCosCentric Limited    The eCos experts      http://www.ecoscentric.com/
Barnwell House, Barnwell Drive, Cambridge, UK.      Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Should hard links to directories work?
@ 2009-05-20 12:28 Ross Younger
  2009-05-20 13:45 ` Bart Veer
  0 siblings, 1 reply; 9+ messages in thread
From: Ross Younger @ 2009-05-20 12:28 UTC (permalink / raw)
  To: ecos-devel

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

(By the way: I started this discussion with a bugzilla ticket, which as
Andrew points out is probably the wrong place.
http://bugzilla.ecoscentric.com/show_bug.cgi?id=1000775 )


Ross

-- 
Embedded Software Engineer, eCosCentric Limited.
Barnwell House, Barnwell Drive, Cambridge CB5 8UU, UK.
Registered in England no. 4422071.                  www.ecoscentric.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-05-20 16:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-20 14:21 Should hard links to directories work? sandeep
2009-05-20 14:47 ` Ross Younger
2009-05-20 16:00 ` Rutger Hofman
2009-05-20 16:35   ` Nick Garnett
  -- strict thread matches above, loose matches on Subject: below --
2009-05-20 12:28 Ross Younger
2009-05-20 13:45 ` Bart Veer
2009-05-20 13:52   ` Gary Thomas
2009-05-20 14:42     ` Ross Younger
2009-05-20 16:56   ` Jonathan Larmour

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).