This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix OPEN with unspecified ACTION on read-only filesystem
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Mon, 12 Mar 2007 05:46:29 -0500
- Subject: [PATCH] Fix OPEN with unspecified ACTION on read-only filesystem
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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