www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/03/18/10:51:32.1

Message-Id: <199903181551.PAA77260@out4.ibm.net>
From: "Mark E." <snowball3 AT usa DOT net>
To: djgpp-workers AT delorie DOT com
Date: Thu, 18 Mar 1999 10:51:15 -0500
MIME-Version: 1.0
Subject: Re: symlink question
References: <199903171807 DOT SAA76910 AT out5 DOT ibm DOT net>
In-reply-to: <Pine.SUN.3.91.990318114931.22105C-100000@is>
X-mailer: Pegasus Mail for Win32 (v3.01d)
Reply-To: djgpp-workers AT delorie DOT com

--Message-Boundary-25740
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body

Here is a corrected version of the patch. Attached is the revised 
documentation.


> Of course.  I was just asking where in the patched code is the case of a
> missing source file handled (presumably by calling `link').  Can you point
> at that place?
> 

The only change is that non-v2 exes are handled calling link()  instead 
of returning with an error. 

In the patch, you'll see two cases of
if (v2_prog == 0)
  handler code here

v2_prog == 0 means the file exists but isn't a v2 exe. v2_prog == -1 
(doesn't exist) and v2_prog == 1 (is v2 exe) are let through in both 
cases. The handler code was changed from return an error sentinal to 
return the result of link().

Further down in symlink.c, there is a comment that mentions non-
existing files.

    /* When we are here, either the file exists and is a v2 executable
     or it does not exist and we hope, the the user knows what he
     does. */

Since the only change I made was to the case of v2_prog == 0 and 
when the source and dest were in the same directory, non-existing 
files continue to work the same way as before the patch. Which is, to 
generate a DJGPP-style symlink as if the file existed.

*** src/libc/posix/unistd/symlink.c.orig	Tue Oct 28 14:22:54 1997
--- src/libc/posix/unistd/symlink.c	Thu Mar 18 10:29:24 1999
***************
*** 73,84 ****
    src_base = tail (src_abs);
    dest_base = tail (dest_abs);
  
!   /* DJGPP symlinks must be in the same directory.  */
    if (strnicmp (src_abs, dest_abs, src_base - src_abs))
!     {
!       errno = EXDEV;
!       return -1;
!     }
  
    /* Any file is already a link to itself.  */
    if (stricmp (src_abs, dest_abs) == 0)
--- 73,82 ----
    src_base = tail (src_abs);
    dest_base = tail (dest_abs);
  
!   /* DJGPP symlinks must be in the same directory.
!      Retry by calling link() to make a copy.  */
    if (strnicmp (src_abs, dest_abs, src_base - src_abs))
!     return link (source, dest);
  
    /* Any file is already a link to itself.  */
    if (stricmp (src_abs, dest_abs) == 0)
***************
*** 88,99 ****
       unstubbed COFF image) */
    v2_prog = is_v2_prog(src_abs);
  
!   /* It is an existing file but no v2 executable */
    if (v2_prog == 0)
!   {
!     errno = EXDEV;
!     return -1;
!   }
  
    /* Allow to say `ln -s src dest' when we really
       mean `src.exe' and `dest.exe'  */
--- 86,95 ----
       unstubbed COFF image) */
    v2_prog = is_v2_prog(src_abs);
  
!   /* It is an existing file but no v2 executable.
!      To make the best of things, call link(). */
    if (v2_prog == 0)
!     return link (source, dest);
  
    /* Allow to say `ln -s src dest' when we really
       mean `src.exe' and `dest.exe'  */
***************
*** 106,121 ****
      v2_prog = v2_prog == 1 ? v2_prog : is_v2_prog(src_abs);
    }
  
!   /* It is an existing file but no v2 executable */
    if (v2_prog == 0)
!   {
!     errno = EXDEV;
!     return -1;
!   }
  
    /* When we are here, either the file exists and is a v2 executable
!      or it does not exist and we hope, the the user knows what he
!      does. */
  
    /* Under LFN, we need the short version of the program name, since 
that
       is what the stub stores (and what a program gets in its argv[0]).  */
--- 102,115 ----
      v2_prog = v2_prog == 1 ? v2_prog : is_v2_prog(src_abs);
    }
  
!   /* It is an existing file but no v2 executable.
!      Retry by calling link() to make a regular copy. */
    if (v2_prog == 0)
!     return link (source, dest);
  
    /* When we are here, either the file exists and is a v2 executable
!      or it does not exist and we hope, that the user knows what he is
!      doing. */
  
    /* Under LFN, we need the short version of the program name, since 
that
       is what the stub stores (and what a program gets in its argv[0]).  */

--- 
Mark Elbrecht, snowball3 AT usa DOT net
http://snowball.digitalspace.net/


--Message-Boundary-25740
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Text from file 'symlink2.dif'

*** src/libc/posix/unistd/symlink.txh.orig	Sun Sep 27 11:22:28 1998
--- src/libc/posix/unistd/symlink.txh	Wed Mar 17 13:17:16 1999
***************
*** 17,24 ****
  depending on what's passed in @code{argv[0]}).  The file referred to by
  @var{exists} doesn't really have to exist when this function is called.
  If @var{exists} points to an @emph{existing} file, the function checks
! that it is a DJGPP executable; if not, the call will fail with
! @code{EXDEV}.
  
  Both @var{new} and @var{exists} can point to a name with or without the
  @file{.exe} extension.
--- 17,24 ----
  depending on what's passed in @code{argv[0]}).  The file referred to by
  @var{exists} doesn't really have to exist when this function is called.
  If @var{exists} points to an @emph{existing} file, the function checks
! that it is a DJGPP executable; if not, attempt to make a copy of the
! file by calling @code{link}(@pxref{link}).
  
  Both @var{new} and @var{exists} can point to a name with or without the
  @file{.exe} extension.

--Message-Boundary-25740--

- Raw text -


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