Post by Tim RÃ¼hsen Post by Paul Eggert Post by Tim RÃ¼hsen
on GNU/Linux open() on a directory returns -1 and sets errno to EISDIR.
No, for example on my platform (Fedora 25 x86-64), 'strace cat .'
outputs the line 'open(".", O_RDONLY) = 3'.
Same here on Debian unstable.
What you want to say is, that it depends on the flags.
And you are right, I wasn't very precise in that point.
Here we use
fd = open(fname, O_WRONLY | flag | O_CREAT | O_NONBLOCK | O_BINARY, S_IRUSR |
S_IWUSR | S_IRGRP | S_IROTH);
'flag' might be one of O_TRUNC, O_APPEND or O_EXCL.
A test with different flags for open(<existing directory>) shows failure +
errno EISDIR when opening for writing.
This portability issue is an ideal "skills ramp up" for someone who has only done
smaller contributions to gnulib so far.
1) Consider the standards: What does POSIX:2008 say about the issue?
2) Extend the unit test of module 'open'.
3) Ask us to test these extended unit tests on various platforms (Mac OS X, Solaris,
FreeBSD, HP-UX, etc.).
4) Mention the issue in the doc section about 'open'.
5) Extend the Autoconf test to recognize this case and arrange to override the
'open' function when the Autoconf test fails.
6) Extend the workaround (lib/open.c) and make sure the unit test now succeeds
on the relevant platform(s).
Any takers? Tim? Gisle?