Hi, >> > Build and regtested on x86-64-gnu-linux. >> > OK for the trunk? >> >> the patch looks pretty much trivial, int the sense that you just >> hard-wire the expected values for the std* units as a special case. I >> wonder why the 'inquire_read' and 'inquire_write' functions don't >> actually return the correct values? > > One can inquire by FILE= name and by UNIT=; inquire_read() is using > the file name - either via FILE= directly or for an opened unit > via u->file; it then calls POSIX's access() function on the file name > to determine the permissions. Obviously, that fails if no file > actually exists. > > Thus, simply calling the function won't work - and as all three cases > are slightly different, hardcoding the condition is simplest. > > > However, I now wonder whether one should also take care of other cases, > where no file name exists - but which could be queried. In that case, > one could simply use the mode in which the file was opened - which > one could do in general for files in the UNIT= mode - contrary to > the FILE= mode. I am in particular thinking of scratch files - they > are often opened, then deleted and only file descriptor remains. > > > Namely, either unconditionally using for UNIT=: > > if ((cf & IOPARM_INQUIRE_HAS_READWRITE) != 0) > p = (u->flags.action == ACTION_READWRITE) ? yes : no; > > We probably still need some special case for stdin/stdout/stderr.
Do we? If the new version of the patch works correctly, then it seems that we don't? > Or adding as additional condition: > if (u->flags->status == STATUS_SCRATCH) > p = (u->flags.action == ACTION_READWRITE) ? yes : no; > to also handle SCRATCH correctly. > > > * Advantage of access(): Gives the true file mode by the OS. > * Advantage of the open mode: Gives the permissions for which the > unit was opened. Is there actually a difference? In any case I think INQUIRE with FILE should use the former, while INQUIRE with UNIT should use the latter, which is apparently what your new patch does. > Also works in corner cases (scratch, stdout, ...). > Simpler code. > > I have no idea what users prefer - but when using the unit directly, > the OPEN's ACCTION= mode feels a bit more natural than access(). > > Thoughts? > > What about the new version of the patch? I like the new version much better, because it is more general and even simpler. To my taste it is ok for trunk ... Thanks, Janus