I've suggested before that files should be divided into several types - unit, log, temp, and managed. This also addresses the locking problem.
Unit files are always updated as a unit - once written and closed, they can't be changed, only replaced. Using "creat" creates a new file, which replaces the old one on clean close. A crash or a program abort reverts to the old file. So they implicitly have a form of mandatory locking. Should two processes be able to create new updates at the same time? Probably not. This is the default kind of file.
Log files should be append-only. Multiple users can write, but only at the end. That deals with the locking problem there. That's what open for append should do.
Temp files disappear at reboot, and should have N-readers or 1 writer locking. Anything in /tmp gets this treatment.
Managed files are for databases. Shared access and partial file locking is supported. Managed files support an API where you get a callback when the data has been safely committed to disk, something ACID databases care about. Only a few programs use managed files, and you know which ones they are. Managed file mode has to be explicitly turned on for a file.
That's how locking ought to work.