If you are only wanting to lock a whole file, then just keep using flock. Only bother with the other functions if you really need that sort of power. If you want to use one of the other methods, just...