Re: How to use mandatory file locking on afpfs volumes
Re: How to use mandatory file locking on afpfs volumes
- Subject: Re: How to use mandatory file locking on afpfs volumes
- From: Kevin Elliott <email@hidden>
- Date: Wed, 28 Mar 2018 17:15:43 -0700
> On Mar 13, 2018, at 12:18 PM, James Bucanek <email@hidden> wrote:
>
> Follow up on my own post...
>
> My intention is to perform file locking on remote volumes, including AFPFS
> volumes. So far, I've found no documentation on how to implement "AFP-style"
> mandatory locking using fcntl().
>
> Then I remember that, while deprecated, the now-ancient FS API is still
> around. Plan B was born: use FSOpenFork's deny-read & deny-write permissions
> to implement file locking, then turn around and use open(2) to access the
> data.
>
> That didn't work. As soon as I opened the file via FSOpenFork, open(2) would
> fail with "resource not available" error.
>
> Hmm, that sounds exactly like what happens when open(2) tries to open a file
> that has been opened by another process with O_SHLOCK or O_EXLOCK.
>
> So it would appear that, rather than being completely different file locking
> mechanisms, FSOpenFork() bridges to the advisory locking provided by open(2).
> And when I rewrite my test code to use open(2) O_SHLOCK and O_EXLOCK to
> access the same AFPFS volume from two different clients, it works perfectly!
>
> Now I'm wondering why the AFPFS volume (this on a Time Capsule, by the way)
> reports VOL_CAP_INT_FLOCK=NO and VOL_CAP_INT_ADVLOCK=NO. The functionality of
> open(2) on that volume would appear to directly contradict that capability
> test.
>
> Can anyone explain this?
Were you testing this on two different machines simultaneously? The point of
AFP locking is to protect the file contents from simultaneous access on
different machines, not within the same machine.
-Kevin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden