On Mar  1 01:18, Dan Shelton via Cygwin wrote:
> On Fri, 28 Feb 2025 at 20:34, Dan Shelton <dan.f.shel...@gmail.com> wrote:
> >
> > Hello!
> >
> > Which Cygwin/POSIX file locking API work over SMB? We need file
> > locking across multiple SMB clients
> 
> Coworker just said that Cygwin does not support file locking over
> remote (SMB, NFS, ...) filesystems. Is that true?

Cygwin doesn't care if the filesystem is local or remote, because
the datastructures are held in the internal NT namespace as long
as at least one process still holds the handles to it.  However,
that also means POSIX and BSD advisory locks are machine-local.

What might work over SMB is the Windows mandatory lock type.  You can
use it from Cygwin by calling fcntl (fd, F_LCK_MANDATORY, 1) and use the
flock functions afterwards.

Opportunistic Locks in Windows may be an option, too, but theoretically
user sapce is not supposed to use them over the network.

Alternatively, just use a dotlock file in parallel to the data file.
This method is used a lot by POSIX apps, see, for instance, mutt,
which even handles files on NFS shares separately.


Corinna

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to