* unsure about the correctness of O_ACCMODE definition
@ 2014-07-01 19:08 u-igbb
2014-07-01 19:31 ` Rich Felker
0 siblings, 1 reply; 3+ messages in thread
From: u-igbb @ 2014-07-01 19:08 UTC (permalink / raw)
To: musl
Hello,
I am troubleshooting lilo linked against musl. The combination does not
work which is not surprising:
It looks like there are two incompatible interpretations of O_ACCMODE
in musl and in lilo.
musl:
----
#define O_ACCMODE (03|O_SEARCH)
----
lilo:
----
#ifdef O_ACCMODE
# define O_NOACCESS O_ACCMODE
#else
...
----
(it makes open(...,O_NOACCESS) which succeeds, fully according to
opengroup.org: O_SEARCH in open(<non-dir>) leads to "undefined results"
but doesn't have to fail; then lilo tries ioctl() on the resulting fd,
which fails)
Then there is
http://pubs.opengroup.org/onlinepubs/7908799/xsh/fcntl.h.html :
----
O_ACCMODE
Mask for file access modes.
File access modes used for open() and fcntl():
O_RDONLY
Open for reading only.
O_RDWR
Open for reading and writing.
O_WRONLY
Open for writing only.
----
This document suggests somehow that O_ACCMODE is equivalent to
(O_RDONLY|O_RDWR|O_WRONLY)
Actually it does not _have_ to be defined in such a way and might
e.g. include bits which are known to always be zero but that
would not look like a robust design.
I feel that the heuristics used in lilo is flawed but I lack firm
arguments to be able to say it is a bug (O_NOACCESS per se
seems to be obscure / non-standard / hardly documented).
I feel on the other side that the definition of O_ACCMODE in musl is
questionable and wonder whether anybody can comment on what and why
is right.
Thanks,
Rune
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: unsure about the correctness of O_ACCMODE definition
2014-07-01 19:08 unsure about the correctness of O_ACCMODE definition u-igbb
@ 2014-07-01 19:31 ` Rich Felker
2014-07-02 6:12 ` u-igbb
0 siblings, 1 reply; 3+ messages in thread
From: Rich Felker @ 2014-07-01 19:31 UTC (permalink / raw)
To: musl
On Tue, Jul 01, 2014 at 09:08:15PM +0200, u-igbb@aetey.se wrote:
> Hello,
>
> I am troubleshooting lilo linked against musl. The combination does not
> work which is not surprising:
>
> It looks like there are two incompatible interpretations of O_ACCMODE
> in musl and in lilo.
>
> musl:
>
> ----
> #define O_ACCMODE (03|O_SEARCH)
> ----
>
> lilo:
>
> ----
> #ifdef O_ACCMODE
> # define O_NOACCESS O_ACCMODE
> #else
> ...
> ----
> (it makes open(...,O_NOACCESS) which succeeds, fully according to
> opengroup.org: O_SEARCH in open(<non-dir>) leads to "undefined results"
> but doesn't have to fail; then lilo tries ioctl() on the resulting fd,
> which fails)
Using a value of 3 as the argument to open is a traditional Linux
extension for getting an fd that's usable only for ioctls. That's
reasonable. What's not reasonable or correct is using O_ACCMODE as a
way to get a 3.
> Then there is
> http://pubs.opengroup.org/onlinepubs/7908799/xsh/fcntl.h.html :
That document is from 1997. The current version of it is:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html
And as you can see, O_SEARCH and O_PATH are required to be included in
the bits for O_ACCMODE.
> I feel that the heuristics used in lilo is flawed but I lack firm
> arguments to be able to say it is a bug (O_NOACCESS per se
> seems to be obscure / non-standard / hardly documented).
Simply the current version of the standard is all you need to show
it's wrong.
> I feel on the other side that the definition of O_ACCMODE in musl is
> questionable and wonder whether anybody can comment on what and why
> is right.
Because it's required by the standard.
Rich
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: unsure about the correctness of O_ACCMODE definition
2014-07-01 19:31 ` Rich Felker
@ 2014-07-02 6:12 ` u-igbb
0 siblings, 0 replies; 3+ messages in thread
From: u-igbb @ 2014-07-02 6:12 UTC (permalink / raw)
To: musl
On Tue, Jul 01, 2014 at 03:31:04PM -0400, Rich Felker wrote:
> The current version of it is:
> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html
Thanks Rich,
It is exactly the information I was missing.
(Now reporting the bug to lilo)
Rune.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-02 6:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-01 19:08 unsure about the correctness of O_ACCMODE definition u-igbb
2014-07-01 19:31 ` Rich Felker
2014-07-02 6:12 ` u-igbb
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).