I've made the same test but using fcntl as I read in the man page of flock
that it didn't work correctly over NFS, but fcnt doesn't work either :-(
any ideas?
> 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
>
>
> --
> To unsubscribe from this list go to the following URL and read the
instructions:
http://lists.samba.org/mailman/listinfo/samba>
>
Albert Cervera Areny
Dept. Inform?tica Sedifa, S.L.
Av. Can Bordoll, 149
08202 - Sabadell (Barcelona)
Tel. 93 715 51 11
Albert Cervera Areny
Dept. Inform?tica Sedifa, S.L.
Av. Can Bordoll, 149
08202 - Sabadell (Barcelona)
Tel. 93 715 51 11