aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-06-11 18:57:32 +0000
committerrsc <devnull@localhost>2004-06-11 18:57:32 +0000
commitd9e16d252a4f84a6b30a7837ed6524e2dffec5ec (patch)
tree7ec4f669c15506da90df991c4e4822243eb9576d /src
parente750400529eb4e655e206cbfba42b156a03c29c3 (diff)
downloadplan9port-d9e16d252a4f84a6b30a7837ed6524e2dffec5ec.tar.gz
plan9port-d9e16d252a4f84a6b30a7837ed6524e2dffec5ec.tar.bz2
plan9port-d9e16d252a4f84a6b30a7837ed6524e2dffec5ec.zip
get this right
Diffstat (limited to 'src')
-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;
}