summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-06-15 08:28:10 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-06-15 08:28:10 +0200
commit9ab48ee37050e2676ae0ddbf253bb3ae5567eb45 (patch)
treecd01b2e25c1a2f5824f638bf434e27a73cc8236c
parent13ec55922f0819aaa2cbb95a9f9bdbed5ae73e2b (diff)
downloadplan9front-9ab48ee37050e2676ae0ddbf253bb3ae5567eb45.tar.xz
hjfs: defer parent directory permission check for wstat
check parent directory permission *after* we determined that the new name does not exist in the parent, so that when the new name is the same as old name then no write permission is required in the parent directory.
-rw-r--r--sys/src/cmd/hjfs/fs2.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/sys/src/cmd/hjfs/fs2.c b/sys/src/cmd/hjfs/fs2.c
index 71658cfb3..4390404f1 100644
--- a/sys/src/cmd/hjfs/fs2.c
+++ b/sys/src/cmd/hjfs/fs2.c
@@ -698,18 +698,17 @@ chanwstat(Chan *ch, Dir *di)
d = getdent(ch->loc->next, pb);
if(d == nil)
goto error;
- if((ch->flags & CHFNOPERM) == 0)
- if(!permcheck(ch->fs, d, ch->uid, OWRITE))
- goto perm;
rc = findentry(ch->fs, ch->loc->next, pb, di->name, &f, ch->flags & CHFDUMP);
- if(rc > 0){
- if(f.blk == ch->loc->blk && f.deind == ch->loc->deind)
- rc = 0;
- else
- werrstr(Eexists);
- }
- if(rc != 0)
+ if(rc < 0)
+ goto error;
+ else if(rc == 0){
+ if((ch->flags & CHFNOPERM) == 0)
+ if(!permcheck(ch->fs, d, ch->uid, OWRITE))
+ goto perm;
+ } else if(f.blk != ch->loc->blk || f.deind != ch->loc->deind){
+ werrstr(Eexists);
goto error;
+ }
}
b = getbuf(ch->fs->d, ch->loc->blk, TDENTRY, 0);
if(b == nil)