[Samba] flock a file in a NT server
Albert Cervera Areny
informatic at sedifa.com
Sat Apr 5 15:11:00 GMT 2003
Hi,
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:
f=open("/mnt/smb/file",O_RDWR|O_CREAT|O_APPEND,S_IRUSR|S_IWUSR);
if (flock(f, LOCK_EX)) {
printf("Error locking");
exit;
}
printf("Text: "); scanf("%s",c);
strcat(c,"\n");
write(f,c,strlen(c));
printf("Say something to quit: "); scanf("%s",c);
if (flock(f, LOCK_UN)) {
printf("Error unlocking");
exit;
}
close(f);
Albert Cervera Areny
More information about the samba
mailing list