libc: Switch open to use a mode_t on unix

While I'm at it, export O_SYNC with the other flags that are exported.

Closes #15581
Closes #15582