lockf over the network

Barry Comer barry at geovision.gvc.com
Thu Jun 27 05:02:52 AEST 1991


I am trying to find a way to unlock files on a server that have been
locked using lockf.  It goes something like this:

-machine "A" is a server.
-machine "B" and "C" are workstations with their own disk systems.  
-a file system located on machine "A" is NFS mounted on "B" and "C"
-machine "B" places a advisory lock on file "X" using the F_TLOCK option.
-machine "B" crashes (I.E. power outage, L1-A, etc) leaving the lock on file "X".
-when machine "C" tries to lockf file "X" it fails.

What can be done to unlock file "X" on the server(short of rebooting the server)?

I have tried using the following:

#include <unistd.h>
#include <sys/file.h>
#include <limits.h>
#include <stdio.h>
#include <fcntl.h>

FILE *fopen(), *fd1;
int  rc;

void main()
{
    fd1 = fopen("X", "w");
    rc = lockf(fileno(fd1), F_ULOCK, 0);
    fclose(fd1);
}

But all this should do is remove any lock that was put on during the
runtime of some program that this fragment might belong to.

It would seem to me that this could be a common type of problem, any
ideas.

thanks in advance
Barry Comer

P.S. Rebooting the server is not an option.  



More information about the Comp.unix.wizards mailing list