[OpenAFS-port-darwin] flock problems

Jason Ferrara jeferrara@sarnoff.com
Mon, 14 Feb 2005 16:04:01 -0500


flock seems to be broken for OpenAFS under MacOS 10.3.

If I run the following test program...

#include <sys/file.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
int main(int argc, char** argv)
{
         int fd = open("testfile",O_RDONLY, 0);
         printf("Got fd %d\n", fd);
         int result = flock(fd, LOCK_EX);
         printf("LOCK_EX result %d\n", result);
         result = flock(fd, LOCK_UN);
         printf("LOCK_UN result %d\n", result);
         if (result == -1)
         {
                 printf("Error %d %s\n", errno, strerror(errno));
         }
}

in a directory in afs I get...

Got fd 3
LOCK_EX result 0
LOCK_UN result -1
Error 22 Invalid argument

If I run it in a directory in a local disk or an smb share I get the 
expected

Got fd 3
LOCK_EX result 0
LOCK_UN result 0


Also, two processes can both get a successful LOCK_EX on a file in afs 
at the same time.

Note that this is all running on one client. I'm not even worried right 
now about the lock working across multiple clients.


I'm running Mac OS X 10.3.8 (7U16) and the openafs kernel extension 
from /afs/andrew.cmu.edu/usr/shadow/macos-afs-kext-20040623, which 
works reliably except for the locking problem. If I use the kernel 
extension from the OpenAFS 1.2.13 release, the locking still doesn't 
work, and I also get a kernel panic after the system has been running 
for a few minutes.

Does anyone have any suggestions?

Thanks.

  - Jason