lib9p: fix lib9p wstat qid.type/mode checks (fixes lock(1) for ramfs/hjfs)

This commit is contained in:
cinap_lenrek 2015-06-13 12:43:15 +02:00
parent f92057cc39
commit 1473e5d437
2 changed files with 24 additions and 23 deletions

View file

@ -335,14 +335,8 @@ fswstat(Req *r)
}
if(r->d.mode != ~0){
f->mode = (r->d.mode & ~DMDIR) | (f->mode & DMDIR);
f->qid.type = 0;
if(f->mode & DMDIR)
f->qid.type |= QTDIR;
if(f->mode & DMAPPEND)
f->qid.type |= QTAPPEND;
if(f->mode & DMEXCL)
f->qid.type |= QTEXCL;
f->mode = r->d.mode;
f->qid.type = f->mode >> 24;
}
if(r->d.name[0] != '\0'){
free(f->name);

View file

@ -682,25 +682,32 @@ swstat(Srv *srv, Req *r)
respond(r, Ebaddir);
return;
}
if(r->d.type != (ushort)~0){
respond(r, "wstat -- attempt to change type");
if(r->d.qid.path != ~0 && r->d.qid.path != r->fid->qid.path){
respond(r, "wstat -- attempt to change qid.path");
return;
}
if(r->d.dev != ~0){
respond(r, "wstat -- attempt to change dev");
if(r->d.qid.vers != ~0 && r->d.qid.vers != r->fid->qid.vers){
respond(r, "wstat -- attempt to change qid.vers");
return;
}
if(r->d.qid.type != (uchar)~0 || r->d.qid.vers != ~0 || r->d.qid.path != ~0){
respond(r, "wstat -- attempt to change qid");
return;
}
if(r->d.muid && r->d.muid[0]){
respond(r, "wstat -- attempt to change muid");
return;
}
if(r->d.mode != ~0 && ((r->d.mode&DMDIR)>>24) != (r->fid->qid.type&QTDIR)){
respond(r, "wstat -- attempt to change DMDIR bit");
return;
if(r->d.mode != ~0){
if(r->d.mode & ~(DMDIR|DMAPPEND|DMEXCL|DMTMP|0777)){
respond(r, "wstat -- unknown bits in mode");
return;
}
if(r->d.qid.type != (uchar)~0 && r->d.qid.type != ((r->d.mode>>24)&0xFF)){
respond(r, "wstat -- qid.type/mode mismatch");
return;
}
if(((r->d.mode>>24) ^ r->fid->qid.type) & ~(QTAPPEND|QTEXCL|QTTMP)){
respond(r, "wstat -- attempt to change qid.type");
return;
}
} else {
if(r->d.qid.type != (uchar)~0 && r->d.qid.type != r->fid->qid.type){
respond(r, "wstat -- attempt to change qid.type");
return;
}
}
srv->wstat(r);
}