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: Mail-Followup-To: cygwin AT cygwin DOT com References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Corinna Vinschen via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Corinna Vinschen Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" On Mar 1 01:18, Dan Shelton via Cygwin wrote: > On Fri, 28 Feb 2025 at 20:34, Dan Shelton 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