commit f84eebeb8147a4527cea0ed4839c7c8becfaf8df from: rsc date: Tue Jan 04 22:18:40 2005 UTC use fcntl F_SETLK instead of flock, for sun's. commit - b4223cd6f27153b6c27a88cae3955274416d8749 commit + f84eebeb8147a4527cea0ed4839c7c8becfaf8df blob - af621099cb266020a9e202e598db99f1e5c300a1 blob + c8f6605a6dc6d8d52f40d6a9f7765ee070a2fa74 --- src/lib9/create.c +++ src/lib9/create.c @@ -2,6 +2,8 @@ #include #define NOPLAN9DEFINES #include +#include +#include #include #include #ifndef O_DIRECT @@ -12,6 +14,7 @@ int p9create(char *path, int mode, ulong perm) { int fd, cexec, umode, rclose, lock, rdwr; + struct flock fl; rdwr = mode&3; lock = mode&OLOCK; @@ -49,7 +52,11 @@ p9create(char *path, int mode, ulong perm) out: if(fd >= 0){ if(lock){ - if(flock(fd, (rdwr==OREAD) ? LOCK_SH : LOCK_EX) < 0){ + fl.l_type = (rdwr==OREAD) ? F_RDLCK : F_WRLCK; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + if(fcntl(fd, F_SETLK, &fl) < 0){ close(fd); return -1; }