I was wondering if anyone had a tool for spoofing the RPC call(s) necessary to tell an NFS server to let go of a lock.
I don't know of any way to selectively release locks that have been "forgotton" by a client, but one of our support people once developed a procedure which can be used to rid yourself of *all* locks that are associated with a particular client. It goes like this:
1. Kill statd on the client. 2. With "lockd" running, lock a file over NFS. 3. Kill lockd on the client. 4. Restart statd. Statd will send a STATMON packet to the filer that causes the filer to blow away all of the locks for that client. 5. Restart lockd.
It is, of course, very easy to write a little C program that creates locks. The below PERL script can also be used.
Keith ---- #!/usr/local/bin/perl5 # Check the input @ARGV for errors. if(!defined($ARGV[0]) || ($ARGV[0]=~/[^0-9]/) && defined($ARGV[1])) { die "Usage: lock <seconds> <filename>\n"; }
# Get the filename from @ARGV if(!defined($ARGV[1])) { $filename=$ARGV[0]; } else { $filename=$ARGV[1]; $wait_time=$ARGV[0]; }
$LOCK_EX=2; $LOCK_UN=8;
open(F, ">>$filename") || die "$filename: $!\n"; flock(F, $LOCK_EX) || die "$!\n";
if (defined($wait_time)) { sleep($wait_time); }
flock(F, $LOCK_UN) || die "$!\n";