get this right
This commit is contained in:
parent
e750400529
commit
d9e16d252a
2 changed files with 7 additions and 5 deletions
|
|
@ -11,8 +11,9 @@
|
|||
int
|
||||
p9create(char *path, int mode, ulong perm)
|
||||
{
|
||||
int fd, cexec, umode, rclose, lock;
|
||||
int fd, cexec, umode, rclose, lock, rdwr;
|
||||
|
||||
rdwr = mode&3;
|
||||
lock = mode&OLOCK;
|
||||
cexec = mode&OCEXEC;
|
||||
rclose = mode&ORCLOSE;
|
||||
|
|
@ -48,7 +49,7 @@ p9create(char *path, int mode, ulong perm)
|
|||
out:
|
||||
if(fd >= 0){
|
||||
if(lock){
|
||||
if(flock(fd, (mode==OREAD) ? LOCK_SH : LOCK_EX) < 0){
|
||||
if(flock(fd, (rdwr==OREAD) ? LOCK_SH : LOCK_EX) < 0){
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@ int
|
|||
p9open(char *name, int mode)
|
||||
{
|
||||
int cexec, rclose;
|
||||
int fd, umode, lock;
|
||||
int fd, umode, lock, rdwr;
|
||||
|
||||
umode = mode&3;
|
||||
rdwr = mode&3;
|
||||
umode = rdwr;
|
||||
cexec = mode&OCEXEC;
|
||||
rclose = mode&ORCLOSE;
|
||||
lock = mode&OLOCK;
|
||||
|
|
@ -33,7 +34,7 @@ p9open(char *name, int mode)
|
|||
fd = open(name, umode);
|
||||
if(fd >= 0){
|
||||
if(lock){
|
||||
if(flock(fd, (mode==OREAD) ? LOCK_SH : LOCK_EX) < 0){
|
||||
if(flock(fd, (rdwr==OREAD) ? LOCK_SH : LOCK_EX) < 0){
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue