aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib9/create.c5
-rw-r--r--src/lib9/open.c7
2 files changed, 7 insertions, 5 deletions
diff --git a/src/lib9/create.c b/src/lib9/create.c
index a9e796ad..af621099 100644
--- a/src/lib9/create.c
+++ b/src/lib9/create.c
@@ -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;
}
diff --git a/src/lib9/open.c b/src/lib9/open.c
index 5b4935c1..526b2a94 100644
--- a/src/lib9/open.c
+++ b/src/lib9/open.c
@@ -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;
}