From: acherman@inf.ethz.ch (Erwin Achermann)
Subject: Re: rcs problems in B19 (patch) : bug in API function readlink()
12 Mar 1998 04:37:01 -0800
Message-ID: <3507936B.67BC2A13.cygnus.gnu-win32@inf.ethz.ch>
References: <3514df62.5658566@berlin.snafu.de>
Reply-To: erwin.achermann@switzerland.org
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: Wolfgang Guelcker <wgue@berlin.snafu.de>
Cc: gnu-win32@cygnus.com, achermann@inf.ethz.ch, ian@visage.demon.co.uk,
        noer@cygnus.com, "cgf@bbc.com" <cgf@bbc.com>, sos@prospect.com.ru

Thanks Wolfgang, the patched version of rcs does its Job well. But I
think the right thing is to fix cygwinb19's readlink() in the first
place. Thanks for locating the bug. I hope the fixed readlink() will
soon make it into cygwinb19.dll

Happy hacking

Erwin

Wolfgang Guelcker wrote:
> 
> Erwin Achermann and Ian Lowrey reported problems with rcs when
> built under B19.
> 
> The problems arise due to a bug in the B19 cygwin API function
> "readlink()".
> 
> readlink() is called in rcsedit.c to check the file in question.
> The correct behaviour is:
>     if readlink() succeeds the file is a symbolic link
>     if readlink() fails and errno is EINVAL the file is a regular file
>     if readlink() fails and errno is ENOENT the file does not exist
> 
> The bug is, that readlink() in B19 sets errno to EINVAL if the file is
> 
> a regular file AND if the file does not exist. In B18 errno was OK.
> 
> That means if a file does NOT exist, RCS in B19 thinks it does exists
> in this context.
> 
> The RCS patch below adds a check for file existance after the call to
> readlink(). The patches from the "Package status report" are included.
> 
> This error shows only if the you work with an rcs extension like ",v".
> The test script "rcsedit" works without one (RSCINIT=-x).
> 
> I changed the test script "rcstest" to work with an extension.
> 
> I reported the readlink() problem on Mar 7, but it didn't show up.
> This mail was sent on Mar 11 19:00 GMT.
> 
> Wolfgang
> 
> diff -c -r rcs-5.7.ori/src/Makefile.in rcs-5.7/src/Makefile.in
> *** rcs-5.7.ori/src/Makefile.in Fri Jun 16 08:19:24 1995
> --- rcs-5.7/src/Makefile.in     Tue Mar 10 21:34:56 1998
> ***************
> *** 87,93 ****
>    o = .o
>   #o = .s# Minix/PC with ACK cc
> 
> !  x =
> 
>   #)
>   # On non-Unix hosts you must manually create and edit conf.h from conf.heg.
> --- 87,93 ----
>    o = .o
>   #o = .s# Minix/PC with ACK cc
> 
> !  x = .exe
> 
>   #)
>   # On non-Unix hosts you must manually create and edit conf.h from conf.heg.
> diff -c -r rcs-5.7.ori/src/conf.sh rcs-5.7/src/conf.sh
> *** rcs-5.7.ori/src/conf.sh     Fri Jun 16 08:19:24 1995
> --- rcs-5.7/src/conf.sh Tue Mar 10 20:42:44 1998
> ***************
> *** 1036,1042 ****
>                 then
>                         case `ls -t a.c a.d` in
>                         a.d*)
> !                               has_mmap=1
>                                 rm -f a.ous
>                                 mv $aout a.ous
>                                 $PREPARE_CC || exit
> --- 1036,1042 ----
>                 then
>                         case `ls -t a.c a.d` in
>                         a.d*)
> !                               has_mmap=0
>                                 rm -f a.ous
>                                 mv $aout a.ous
>                                 $PREPARE_CC || exit
> diff -c -r rcs-5.7.ori/src/rcsedit.c rcs-5.7/src/rcsedit.c
> *** rcs-5.7.ori/src/rcsedit.c   Fri Jun 16 08:19:24 1995
> --- rcs-5.7/src/rcsedit.c       Tue Mar 10 21:51:09 1998
> ***************
> *** 1279,1286 ****
>         bufautoend(&bigbuf);
>         errno = e;
>         switch (e) {
> !           case readlink_isreg_errno: return 1;
> !           case ENOENT: return 0;
>             default: return -1;
>         }
>   }
> --- 1279,1292 ----
>         bufautoend(&bigbuf);
>         errno = e;
>         switch (e) {
> !           case readlink_isreg_errno: {
> !                 /* B19 readlink does return readlink_isreg_errno = EINVAL  */
> !                 /* if file does not exist instead of ENOENT                */
> !               struct stat st;
> !               if ( stat(L->string, &st) == 0 )
> !                     return 1;   /* File exists, but no symlink */
> !             }
> !           case ENOENT: return 0;  /* Nothing exists */
>             default: return -1;
>         }
>   }
> diff -c -r rcs-5.7.ori/src/rcstest rcs-5.7/src/rcstest
> *** rcs-5.7.ori/src/rcstest     Fri Jun 16 08:19:24 1995
> --- rcs-5.7/src/rcstest Tue Mar 10 21:53:13 1998
> ***************
> *** 50,62 ****
> 
>   CL="$CC $ALL_CFLAGS $LDFLAGS -o a.out"
>   L=$LIBS
> !
> ! RCSINIT=-x
>   export RCSINIT
> 
>   SLASH=/
> ! RCSfile=RCS${SLASH}a.c
> ! RCS_alt=RCS${SLASH}a.d
>   lockfile=RCS${SLASH}a._
> 
>   case $1 in
> --- 50,63 ----
> 
>   CL="$CC $ALL_CFLAGS $LDFLAGS -o a.out"
>   L=$LIBS
> !
> ! RCSext=,v
> ! RCSINIT=-x$RCSext
>   export RCSINIT
> 
>   SLASH=/
> ! RCSfile=RCS${SLASH}a.c$RCSext
> ! RCS_alt=RCS${SLASH}a.d$RCSext
>   lockfile=RCS${SLASH}a._
> 
>   case $1 in
> ***************
> *** 195,208 ****
>   @Author: w @
>   @Date: $date @
>   @Header: $PWD$SLASH$RCSfile 2.1 $date w s @
> ! @Id: a.c 2.1 $date w s @
>   @Locker:  @
> !  * @Log: a.c @
>    * Revision 2.1  $date  w
>    * m
>    *
>   @Name: Oz @
> ! @RCSfile: a.c @
>   @Revision: 2.1 @
>   @Source: $PWD$SLASH$RCSfile @
>   @State: s @
> --- 196,209 ----
>   @Author: w @
>   @Date: $date @
>   @Header: $PWD$SLASH$RCSfile 2.1 $date w s @
> ! @Id: a.c$RCSext 2.1 $date w s @
>   @Locker:  @
> !  * @Log: a.c$RCSext @
>    * Revision 2.1  $date  w
>    * m
>    *
>   @Name: Oz @
> ! @RCSfile: a.c$RCSext @
>   @Revision: 2.1 @
>   @Source: $PWD$SLASH$RCSfile @
>   @State: s @
> --
> Wolfgang Guelcker                wgue@berlin.snafu.de

-- 
Erwin Achermann                               Tel:      ++41 1 632 74 40
Institut fuer Wissenschaftliches Rechnen      Fax:      ++41 1 632 11 72
ETH Zentrum, IFW C29.2         mailto:achermann@inf.ethz.ch  ICQ:4625051
CH-8092 Zuerich	               http://www.inf.ethz.ch/personal/acherman/
>  Perfection is reached, not when there is no longer anything to add, <
>  but when there is no longer anything to take away.                  <
>                                          -- Antoine de Saint-Exupery <
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
