delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/08/23/16:15:19

From: Alain Magloire <alainm AT rcsm DOT ece DOT mcgill DOT ca>
Message-Id: <199908231935.PAA26614@mccoy2.ECE.McGill.CA>
Subject: Re: Real symlinks for DJGPP?
To: djgpp-workers AT delorie DOT com
Date: Mon, 23 Aug 1999 15:35:46 -0400 (EDT)
In-Reply-To: <37C021D1.46CF6EC@softhome.net> from "Laurynas Biveinis" at Aug 22, 99 06:14:09 pm
X-Mailer: ELM [version 2.4 PL25]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Bonjour M. Laurynas Biveinis

> Martin Str|mberg wrote:
> > 
> > Laurynas said:
> > > 1) symlink function creates a new file and writes path to
> > > linked file here. To avoid clashes between symlink and
> > > non-symlink files, it should have prefix and postfix, e.g.
> > > two ASCII chars from 0-31 or 128-255, string 'DJGPP symlink',
> > > path itself, newline, 'DJGPP symlink'.
> > 
> > Nice. Are the WINDOZE shortcuts equivalent to symlinks? If so perhaps
> > that format should be used?
> 
> That format is little bit overkill for DJGPP symlink - it
> contains fields about icons, hot keys for accessing, 16 bytes
> for GUID, network info, volume info and so on, and so on...  
> I think my suggestion is better because it is simpler.
> 
> Maybe it is good idea to add their support in open(), but
> symlink() should not generate them.
> 
> > (
> > > I'm waiting for advices. In fact, I've started writing
> > > some code.
> > 
> > Well, _are_ you waiting for advice or not?)
> 
> :) I'm writing code and accepting advices.

I don't have any code nor advices but a few notes:

- do you have protection against recursive loops in open()/stat() ?
    link0 --> link1 --> link2 --> link0
- how deep, or how many levels of indirection are allowed ?

# uname -rs
SunOS 5.6
# ln -s link0 link1
# ln -s link1 link0
# ls -l link*
lrwxrwxrwx   1 alain    techies        5 Aug 23 15:12 link0 -> link1
lrwxrwxrwx   1 alain    techies        5 Aug 23 15:12 link1 -> link0
# cat link1
cat: cannot open link1
# cat link0
cat: cannot open link0
# ls -L link0
link0: Number of symbolic links encountered during path name
       traversal exceeds MAXSYMLINKS
# ls -lL link1
link1: Number of symbolic links encountered during path name
       traversal exceeds MAXSYMLINKS

Probably the best/simple defence against this, is to check for a certain
number of indirection and then return ELOOP instead of trying to built
a graph cycle.

- attributes lchown()/chown ?

- are links to directories allowed ? how will
  open()/opendir()/chdir() behave in this case.

- any effects on the functions that manipulates files and directories
  readlink(), link(), access(), unlink(), rename(), touch(), etc ....

There's probably other issues related to DOS, but this is out of
my league.  It would be interesting to see the implementation with
tools like tar/cpio  who actually retry to recreate the links.
Note also, POSIX 1992 and 1996 do not, purposely, mention nor define
symlinks.  I think it is part of the newer drafts.

-- 
au revoir, alain
----
Aussi haut que l'on soit assis, on est toujours assis que sur son cul !!!

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019