use fcntl F_SETLK instead of flock, for sun's.
This commit is contained in:
parent
b4223cd6f2
commit
f84eebeb81
1 changed files with 8 additions and 1 deletions
|
|
@ -2,6 +2,8 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#define NOPLAN9DEFINES
|
#define NOPLAN9DEFINES
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#ifndef O_DIRECT
|
#ifndef O_DIRECT
|
||||||
|
|
@ -12,6 +14,7 @@ int
|
||||||
p9create(char *path, int mode, ulong perm)
|
p9create(char *path, int mode, ulong perm)
|
||||||
{
|
{
|
||||||
int fd, cexec, umode, rclose, lock, rdwr;
|
int fd, cexec, umode, rclose, lock, rdwr;
|
||||||
|
struct flock fl;
|
||||||
|
|
||||||
rdwr = mode&3;
|
rdwr = mode&3;
|
||||||
lock = mode&OLOCK;
|
lock = mode&OLOCK;
|
||||||
|
|
@ -49,7 +52,11 @@ p9create(char *path, int mode, ulong perm)
|
||||||
out:
|
out:
|
||||||
if(fd >= 0){
|
if(fd >= 0){
|
||||||
if(lock){
|
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);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue