@zfigura Thanks for your review. I'm sorry myself for taking so long to address your points.
I think you're right about `O_CREAT`. My tests pass just as well without it, so I rebased my patches with it removed.
Do we actually need write access for anything that FILE_WRITE_ATTRIBUTES does? And if not, the condition from 3/3 seems a little odd.
No we don't need write access for attribute writing. Any access will do.
Therefore we should "piggy-back" on whatever access we are getting via other flags. So previously `O_RDONLY` access would become `O_RDWR` if `FILE_WRITE_ATTRIBUTES` was specified, which is impossible for read-only files. In that case `O_RDONY` is sufficient.
However, in the case where `O_TRUNC` is also required, we need write-access. I this case attribute writing can piggy-back on `O_WRONLY` or `O_RDWR`.
Does this sound reasonable to you?