Open
Description
Message
Linux and apparently OSX support F_OFD_SETLK, which is what you would really expect from F_SETLK.
https://lwn.net/Articles/586904/
https://www.gnu.org/software/libc/manual/html_node/Open-File-Description-Locks.html
https://man7.org/linux/man-pages/man2/fcntl.2.html
https://github.com/apple/darwin-xnu/blob/main/bsd/sys/fcntl.h
It's not clear if FreeBSD has them.
This would let us get rid of most of exfile.c(), and replace it with just open / lock / close.
The issue with normal F_SETLK is that they are process specific. So two threads can't lock the same file. With F_OFD_SETLK, different threads should be able to lock the same file without an issue.