delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/03/03/07:05:11

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 523C5Abq2801888
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 523C5Abq2801888
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=cYyGOcB/
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0323C385840E
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1741003510;
bh=81obPs7QlgZX7/8AcKQLxnRG6FYyQbyOq6rgQPlqL3s=;
h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=cYyGOcB/GdDVDG8CVsD2EHJe78E5ZnK/pJDsiYqepvdRZ4/R86S09YE7IhnFp0e+V
WD6WJgxX3gDiLLbHEW7hrncLy9M2xMbp76kyI2vZF6TA+2MvQxaFWN5/yz+WyG/FCO
NVEphoyPyyEAtWHiHa/03d1sLtHr/BEoOuIx2GGA=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A1EB3858D21
Date: Mon, 3 Mar 2025 13:04:10 +0100
To: cygwin AT cygwin DOT com
Subject: Re: Which Cygwin file locking API works over SMB?
Message-ID: <Z8WauqBHVPK6MhLn@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <CAAvCNcBrnDOcUcNOpYTDp3dsbjmf7bqhFDHTZkf4DqshE+FhOg AT mail DOT gmail DOT com>
<CAAvCNcCj2bU6V58bSLj26QtVOAMNo-VMBjmf-7eq3Ct9JzMWkg AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <CAAvCNcCj2bU6V58bSLj26QtVOAMNo-VMBjmf-7eq3Ct9JzMWkg@mail.gmail.com>
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

On Mar  1 01:18, Dan Shelton via Cygwin wrote:
> On Fri, 28 Feb 2025 at 20:34, Dan Shelton <dan DOT f DOT shelton AT gmail DOT 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019