In order to guarantee cache consistency you generally want to obtain
the write lock before opening the file you want to modify.
The best way to do this is to lock a different file than the one
you're trying to modify. Most of the code I have seen/written that
locks files in AFS work like this:
* open lock file (O_RDONLY | O_CREAT)
* while lock attempt fails (EWOULDBLOCK)
* give up if too many tries
* wait
* open data file
* modify data file
* close data file
* release lock & close lock file
_.John