On Wed, Sep 2, 2015 at 11:50 AM, Niall Douglas
On 1 Sep 2015 at 23:51, Jeremy Maitin-Shepard wrote:
The normal way to do this with POSIX *at APIs would be to just open a handle to the directory in the first place. I suppose the purpose of this more complex approach is to avoid having to keep an extra file descriptor to the directory open, or to allow the user to open a sibling file from an arbitrary AFIO file handle without preparing in advance (as I suppose would be required by your shadow file-based locking approach). It does seem like rather specific and not necessarily all that common functionality to require users to pay for by default.
The approach you just suggested doesn't handle the case where you open a file, and then it gets moved before the sibling lookup.
Fair enough; I think the desired semantics would depend on the particular case. It seems there is always a time at which you issue the open call in order to open/create the sibling file, and there will inevitably be a race between that and concurrently moving the original file.