delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/03/17/10:53:54

Message-Id: <199903171553.PAA28740@out2.ibm.net>
From: "Mark E." <snowball3 AT usa DOT net>
To: djgpp-workers AT delorie DOT com
Date: Wed, 17 Mar 1999 10:53:38 -0500
MIME-Version: 1.0
Subject: Re: symlink question
References: <Pine DOT A41 DOT 4 DOT 05 DOT 9903171010230 DOT 89100-100000 AT ieva01 DOT lanet DOT lv>
In-reply-to: <Pine.SUN.3.91.990317112522.11125N-100000@is>
X-mailer: Pegasus Mail for Win32 (v3.01d)
Reply-To: djgpp-workers AT delorie DOT com

How about altering symlink.c that if making a DJGPP-style soft link is 
impossible but where a Unix style soft link would succeed, call link() to 
try and make a hard link. Here's a patch that would do that:

*** src\libc\posix\unistd\symlink.c.orig	Tue Oct 28 14:22:54 1997
--- src\libc\posix\unistd\symlink.c	Wed Mar 17 10:37:58 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,117 ****
      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
--- 102,111 ----
      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, the the user knows what he

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

- Raw text -


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