[Samba] flock a file in a NT server

Albert Cervera Areny informatic at sedifa.com
Sat Apr 5 15:11:00 GMT 2003

   I'm writing an application with C under Linux and I'm trying to use the
flock system function to lock a file of an NT4 Server over Samba. The
problem is that the lock works well within the same machine but if it
is a process on another machine (the same program) the one that tries
to access the locked file, the process is not blocked until the lock is
released but given full access to it.
	I suppose it is a matter of configuration of my clients but what should I
use to get propper file locking? Windows machines lock without problems.

Here it is a short verson of the test program I'm using:

if (flock(f, LOCK_EX)) {
	printf("Error locking");

printf("Text: "); scanf("%s",c);

printf("Say something to quit: "); scanf("%s",c);

if (flock(f, LOCK_UN)) {
	printf("Error unlocking");

Albert Cervera Areny

More information about the samba mailing list