On 4/12/22 07:05, Pádraig Brady wrote:
This does seem like a bug in that O_DIRECTORY should take precedence, especially considering O_SEARCH is documented in the Solaris open man page to return ENOTDIR for non directories.
I don't think it's a bug, as longstanding POSIX tradition is that if there are multiple reasons to fail (here, EACCES and ENOTDIR) then a library function can fail with either error number.
Your patch doesn't feel quite right to me but I haven't figured out why yet; I'll try to spring time to look at it in more detail.