Subject: Re: [NOT FIXED] Symbolic links & RCS -- READ IT!
From: "David O'Riva" <[email-masked]>
To: [email-masked]
Date: Mon, 15 Nov 1999 05:09:33 -0800

Andre Oliveira da Costa wrote:
> 
> Well, I'm sorry to say that this is _not_ great news -- I said "OK" too soon
> =T The RCS tools I created did understand the symbolic links scheme of
> Cygwin, but they show some strange behavior that makes it impossible to use
> them. ci.exe is unable to check-in files if they don't exist on the RCS dir;
> it complains about being unable to create the files on the RCS dir due to
> permission problems, and aborts leaving some temporary files around in my
> HD.
> 

Yeah - I remember this from b19.  Had to rebuild them myself about a
week ago, so I took the time to work up a reasonable patch to the
distribution (attached).  This should work for b19 and b20/.1.

Specific changes:
	fixed conf.sh to not bomb out during mmap_signal check
	fixed rcslex.c so that O_BINARY doesn't assume !(large_memory &&
has_mmap)
	fixed rcsedit.c in two places:
		readlink is still screwed on b20 (setup via conf.sh)
		renaming read-only files is wierd (setup via conf.sh)

This patch fixes the ci bug and prevents the occasional truncation of
stored revision files, and cause configure to run very smoothly.

If you are still running b19, you may need to change "x=" to "x=.exe" in
the makefile as per the "Package Report" (BTW, does someone want to post
this patch there?)

-- 
-dave        _________________________
------------/      David O'Riva       \--------------
408-        | Staff Software Engineer | oriva@
 473-9413   |    Atari Games, Inc.    |   agames.com
            \_________________________/

#  patches rcs-5.7 to work with cygwin b19/20/20.1
#  doesn't break the configure script for other systems
#  To apply: cd rcs-5.7 ; patch -p 1 -i rcs-5.7-cygwinb20.patch

diff -r -c rcs-5.7/src/conf.sh rcs-5.7-good/src/conf.sh
*** rcs-5.7/src/conf.sh	Thu Jun 15 23:19:24 1995
--- rcs-5.7-good/src/conf.sh	Fri Nov 12 14:33:59 1999
***************
*** 311,325 ****
  # We must do has_readlink next, because it might generate
  # #include directives that affect later definitions.
  
! $ech >&3 "$0: configuring has_readlink, readlink_isreg_errno $dots"
  cat >a.c <<EOF
  #include "$A_H"
  static char b[7];
  int
! main() {
  	if (readlink("a.sym2",b,7) == 6  &&  strcmp(b,"a.sym1") == 0  &&
  		readlink("a.c",b,7) == -1  &&  errno != ENOENT
  	) {
  		if (errno == EINVAL)
  			printf("EINVAL\n");
  		else
--- 311,338 ----
  # We must do has_readlink next, because it might generate
  # #include directives that affect later definitions.
  
! $ech >&3 "$0: configuring has_readlink, readlink_isreg_errno, bad_readlink_enoent $dots"
  cat >a.c <<EOF
  #include "$A_H"
  static char b[7];
  int
! main(argc, argv) int argc; char **argv; {
  	if (readlink("a.sym2",b,7) == 6  &&  strcmp(b,"a.sym1") == 0  &&
  		readlink("a.c",b,7) == -1  &&  errno != ENOENT
  	) {
+ 		/*
+ 		* test for readlink returning same errno for
+ 		* regular files and non-existent files
+ 		*/
+ 		if (1 < argc) {
+ 			int e=errno;
+ 			readlink("a.sym3",b,7);
+ 			if( errno==e )
+ 				printf( "1\n" );
+ 			else
+ 				printf( "0\n" );
+ 			exitmain(ferror(stdout) || fclose(stdout)!=0);
+ 		}
  		if (errno == EINVAL)
  			printf("EINVAL\n");
  		else
***************
*** 335,343 ****
  then h=1
  else h=0
  fi
! echo >&3 $h, $readlink_isreg_errno
  cat <<EOF
  #define has_readlink $h /* Does readlink() work?  */
  #define readlink_isreg_errno $readlink_isreg_errno /* errno after readlink on regular file */
  
  #if has_readlink && !defined(MAXSYMLINKS)
--- 348,361 ----
  then h=1
  else h=0
  fi
! case $h in
! 1) bh=`$aout t`;;
! *) bh=0;;
! esac
! echo >&3 $h, $readlink_isreg_errno, $bh
  cat <<EOF
  #define has_readlink $h /* Does readlink() work?  */
+ #define bad_readlink_enoent $bh /* Does readlink() return ENOENT correctly?  */
  #define readlink_isreg_errno $readlink_isreg_errno /* errno after readlink on regular file */
  
  #if has_readlink && !defined(MAXSYMLINKS)
***************
*** 1053,1059 ****
  		# when someone unexpectedly truncates a file
  		# while RCS has it mmapped.
  		rm -f a.e && cp a.c a.e &&
! 		mmap_signal=`$aout a.e <a.e` || exit
  	esac
  esac
  echo >&3 $has_map_fd, $has_mmap, $has_madvise, $mmap_signal
--- 1071,1077 ----
  		# when someone unexpectedly truncates a file
  		# while RCS has it mmapped.
  		rm -f a.e && cp a.c a.e &&
! 		mmap_signal=`$aout a.e <a.e` || mmap_signal=
  	esac
  esac
  echo >&3 $has_map_fd, $has_mmap, $has_madvise, $mmap_signal
diff -r -c rcs-5.7/src/rcsedit.c rcs-5.7-good/src/rcsedit.c
*** rcs-5.7/src/rcsedit.c	Thu Jun 15 23:19:24 1995
--- rcs-5.7-good/src/rcsedit.c	Fri Nov 12 14:35:39 1999
***************
*** 1279,1285 ****
  	bufautoend(&bigbuf);
  	errno = e;
  	switch (e) {
! 	    case readlink_isreg_errno: return 1;
  	    case ENOENT: return 0;
  	    default: return -1;
  	}
--- 1279,1300 ----
  	bufautoend(&bigbuf);
  	errno = e;
  	switch (e) {
! 	    case readlink_isreg_errno:
! #			if bad_readlink_enoent
! 			/*
! 			* Cygwin32 betas 19 & 20 report EINVAL if the
! 			* file doesn't exist, instead of ENOENT.
! 			* Make sure the file really does exist.
! 			*/
! 			{
! 		 		struct stat st;
!  				if ( stat(L->string, &st) == 0 )
! 					/* File exists, but no symlink */
! 					return 1;
! 			}
! #			else
! 				return 1;
! #			endif
  	    case ENOENT: return 0;
  	    default: return -1;
  	}
***************
*** 1595,1601 ****
  	    }
  #	endif
  
! #	if bad_a_rename
  		/*
  		* There's a short window of inconsistency
  		* during which the lock file is writable.
--- 1610,1616 ----
  	    }
  #	endif
  
! #	if bad_a_rename || bad_nw_rename
  		/*
  		* There's a short window of inconsistency
  		* during which the lock file is writable.
***************
*** 1650,1656 ****
  	}
  #	endif
  
! #	if bad_a_rename
  	    if (0 < set_mode  &&  chmod(to, mode) != 0)
  		return -1;
  #	endif
--- 1665,1671 ----
  	}
  #	endif
  
! #	if bad_a_rename || bad_nw_rename
  	    if (0 < set_mode  &&  chmod(to, mode) != 0)
  		return -1;
  #	endif
diff -r -c rcs-5.7/src/rcslex.c rcs-5.7-good/src/rcslex.c
*** rcs-5.7/src/rcslex.c	Thu Jun 15 23:19:24 1995
--- rcs-5.7-good/src/rcslex.c	Fri Nov 12 11:56:47 1999
***************
*** 1113,1119 ****
  /* Open NAME for reading, yield its descriptor, and set *STATUS.  */
  {
  	int fd = fdSafer(open(name, O_RDONLY
! #		if OPEN_O_BINARY
  			|  (strchr(type,'b') ? OPEN_O_BINARY : 0)
  #		endif
  	));
--- 1113,1119 ----
  /* Open NAME for reading, yield its descriptor, and set *STATUS.  */
  {
  	int fd = fdSafer(open(name, O_RDONLY
! #		if OPEN_O_BINARY && !(large_memory && maps_memory)
  			|  (strchr(type,'b') ? OPEN_O_BINARY : 0)
  #		endif
  	));

--
Want to unsubscribe from this list?
Send a message to [email-masked]