[patch] work around ClearCase bug

Zack Weinberg zack@codesourcery.com
Wed Dec 5 22:59:00 GMT 2001


I'm doing some consulting work for Wind River.  They use ClearCase
extensively.  It has a bug where close(2) will report failure with
errno == EROFS for any file opened in a read-only "view" of the
repository, even if the file was opened O_RDONLY.

Most Unix utilities ignore error returns from close for files opened
for reading, but BFD doesn't.  Therefore, if you have object files
stored in a read-only ClearCase view, GNU ld will fail when asked to
link them.

Fixing the ClearCase bug is not practical, so I'm submitting this
workaround for BFD.  It simply ignores a failed fclose(3) if the BFD
object was opened for reading and errno is EROFS.

Reactions?

zw

	* cache.c (bfd_cache_delete): Ignore failed fclose() if errno
	is EROFS and the file was open for reading.

===================================================================
Index: bfd/cache.c
--- bfd/cache.c	2001/09/18 09:57:21	1.7
+++ bfd/cache.c	2001/12/06 06:57:03
@@ -175,6 +175,13 @@ bfd_cache_delete (abfd)
 
   if (fclose ((FILE *) abfd->iostream) == 0)
     ret = true;
+  /* ClearCase has an entertaining bug where close will fail and set
+     errno to EROFS when applied to any file in a read-only view, even
+     if the file was opened for reading.  Detect this situation and
+     ignore the error.  */
+  else if (errno == EROFS && (abfd->direction == no_direction
+			      || abfd->direction == read_direction))
+    ret = true;
   else
     {
       ret = false;



More information about the Binutils mailing list