This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, libgfortran] PR 65200 Handle EPERM as EACCES


Hi,

the attached patch makes GFortran handle errno=EPERM in the same way
as EACCES (this affects only when no ACTION= specifier is used in the
OPEN statement and opening the file in read-write mode fails).
Ostensibly the distinction is roughly

- EACCES: Insufficient privilege. E.g. do the same as root and this should work.
- EPERM: Operation not permitted. That is, no matter the privilege
level, this isn't allowed. E.g. truncating a file opened with O_APPEND
and such.

However, it seems at least the Linux NFSv4 client returns EPERM when
trying to open a read-only file in read-write mode, whereas local
filesystems and the NFSv3 client return EACCES. So it seems reasonable
to check for EPERM as well in the same situations one checks for
EACCES.

The patch also contains a doc snippet to explain how GFortran behaves
when no ACTION= is given when opening a file. This brings me to a
standards interpretation question: When no ACTION= is given, F2008
9.5.6.4 (ACCESS= specifier in OPEN statement) says: "If this specifier
is omitted, the default value is processor dependent."  So does this
mean that the current GFortran behavior is allowed, or must the
behavior be exactly as with one of the possible ACTION= specifiers
(READ, WRITE, READWRITE)?

The patch as is causes gfortran.dg/open_errors.f90 to fail, due to
changed error messages. I'm a bit unsure of to fix this, as now
strerror* is used to generate part of the message, and thus the
message can be different on different targets, and even dependent on
the locale settings. Just checking for the fixed part of the error
message doesn't seem that useful in this case; should the entire
testcase just be removed?

Regtested on x86_64-unknown-linux-gnu, Ok for trunk (with some
decision wrt open_errors.f90)?

gcc/fortran ChangeLog:

2015-03-07  Janne Blomqvist  <jb@gcc.gnu.org>

    PR libfortran/65200
    * gfortran.texi: Document behavior when opening files without
    explicit ACTION= specifier.

libgfortran ChangeLog:

2015-03-07  Janne Blomqvist  <jb@gcc.gnu.org>

    PR libfortran/65200
    * io/open.c (new_unit): Use gf_strerror rather than hardcoding
    error messages for different errno values.
    * io/unix.c (regular_file2): Handle EPERM in addition to EACCES.

gcc/testsuite ChangeLog:

2015-03-07  Janne Blomqvist  <jb@gcc.gnu.org>

    PR libfortran/65200
    * gfortran.dg/open_new_segv.f90: Fix error message pattern.


-- 
Janne Blomqvist

Attachment: eperm.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]