db/hash.c: Allow O_WRONLY in dbm_open
The dbm(3) manpage explicitly states that O_WRONLY is not allowed in
dbm_open, but a more recent comment in __hash_open suggests otherwise.
Furthermore, POSIX.1 allows O_WRONLY in dbm_open and states
that the underlying file must be opened for both reading and writing.
Fix this by correcting the O_WRONLY check and moving it further into
the function to make sure that the original flags are stored in hashp.
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D51514