file locking question: Unix/NT environment

Jinhai Yang jyang at
Mon Oct 21 19:49:00 GMT 2002

This is follow-up to my original question, really appreciate if somebody
could give me some advises here.

What I tried to do is to implement an advisory locking scheme among both
Unix and Windows 2000 clients over Samba. The files are on a disk local to
the Unix box, the W2K clients access them through Samba.

Couple of questions:
a) is this possible? if not, what's the best way to handle file locking
involving access from both NT and Unix clients?
b) is advisory locking supported under win32? I cannot seem to find the
POSIX style fcntl(), lockf() calls under win32, have I missed something?

Thanks for any help,


-----Original Message-----
From: samba-technical-admin at
[mailto:samba-technical-admin at]On Behalf Of Simo Sorce
Sent: Friday, October 18, 2002 6:14 PM
To: Jinhai Yang
Cc: samba-technical at
Subject: Re: file locking question: Unix/NT environment

It really depends on which OS you are using.

Currently only linux 2.4.x (whith x something > than 4 I think) and IRIX
latest kernels have support for kernel oplocks and the ability to share
locks beetween samba and nfs.

On Sat, 2002-10-19 at 00:28, Jinhai Yang wrote:
> We have some files on a Unix/Samba server which the users can access from
> both the Unix side and Windows NT side. We'd like to implement file
> on these files for client applications which could run from both the unix
> boxes and the NT boxes. However, I cannot seem to get it right.
> On NT, we used:
> 	...
> 	_locking( fd, LK_LCK, 100L );
> 	...
> On Unix, we used:
> 	...
> 	fcntl(fd, F_SETLKW, &fl);
> 	...
> The NT clients can lock out each other, the Unix clients can also lock out
> each other. However, a NT client CANNOT lock out a Unix client, and vice
> versa.
> Am I using the right call? Is there something I missed? Or is there
> something in samba.conf I should tweak?
> I'm fairly new to Samba, thanks for any help.
> -----------------------------
> Jinhai Yang
> Triant Technology Inc.
Simo Sorce - simo.sorce at
Xsec s.r.l.
via Durando 10 Ed. G - 20158 - Milano
tel. +39 02 2399 7130 - fax: +39 02 700 442 399

More information about the samba-technical mailing list