[PATCH] Fix OPEN with unspecified ACTION on read-only filesystem

Jakub Jelinek jakub@redhat.com
Mon Mar 12 12:41:00 GMT 2007


Hi!

regular_file only special-cases EACCESS for ACTION_UNSPECIFIED if O_RDWR
open failed, but on a read-only filesystem errno might be EROFS and that
needs the same treatment - retry with O_RDONLY.  For more details see
http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=231134

Ok for trunk and after a few days for 4.2/4.1?

2007-03-12  Jakub Jelinek  <jakub@redhat.com>

	* io/unix.c (regular_file): For ACTION_UNSPECIFIED retry with
	O_RDONLY even if errno is EROFS.

--- libgfortran/io/unix.c.jj	2007-01-24 22:24:23.000000000 +0100
+++ libgfortran/io/unix.c	2007-03-12 09:47:42.000000000 +0100
@@ -1213,7 +1213,7 @@ regular_file (st_parameter_open *opp, un
       break;
 
     case STATUS_REPLACE:
-        crflag = O_CREAT | O_TRUNC;
+      crflag = O_CREAT | O_TRUNC;
       break;
 
     default:
@@ -1229,14 +1229,14 @@ regular_file (st_parameter_open *opp, un
   mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
   fd = open (path, rwflag | crflag, mode);
   if (flags->action != ACTION_UNSPECIFIED)
-      return fd;
+    return fd;
 
   if (fd >= 0)
     {
       flags->action = ACTION_READWRITE;
       return fd;
     }
-  if (errno != EACCES)
+  if (errno != EACCES && errno != EROFS)
      return fd;
 
   /* retry for read-only access */

	Jakub



More information about the Gcc-patches mailing list