Make safeguard against incorrect flags for fsync more portable.

The existing code assumed that O_RDONLY is defined as 0, but this is
not required by POSIX and is not true on GNU Hurd.  We can avoid
the assumption by relying on O_ACCMODE to mask the fcntl() result.
(Hopefully, all supported platforms define that.)

Author: Michael Banck <[email protected]>
Co-authored-by: Samuel Thibault
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 13

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d0a695cf41de8f11a596b42f52af7e0f68f5b86f

Modified Files
--------------
src/backend/storage/file/fd.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)

Reply via email to