diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-08-27 23:27:46 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-08-27 23:27:46 +0200 |
commit | 84109a3159249369d1869fd887a7040b766e4540 (patch) | |
tree | f59d2ef1d691767fc6ee035aabd008d9fe52404c /sys/src/9/port/devshr.c | |
parent | 52a84514acca8c2afc7e33c6f3f7d95235cad75e (diff) |
devshr, devaudio: openmode()/devopen() error handling
Diffstat (limited to 'sys/src/9/port/devshr.c')
-rw-r--r-- | sys/src/9/port/devshr.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/src/9/port/devshr.c b/sys/src/9/port/devshr.c index faac78574..e959261cb 100644 --- a/sys/src/9/port/devshr.c +++ b/sys/src/9/port/devshr.c @@ -375,10 +375,12 @@ shropen(Chan *c, int omode) Sch *sch; Shr *shr; Mpt *mpt; + int mode; if(c->qid.type == QTDIR && omode != OREAD) error(Eisdir); + mode = openmode(omode); sch = tosch(c); switch(sch->level){ default: @@ -389,14 +391,14 @@ shropen(Chan *c, int omode) case Qshr: case Qcshr: shr = sch->shr; - devpermcheck(shr->owner, shr->perm, openmode(omode)); + devpermcheck(shr->owner, shr->perm, mode); break; case Qcmpt: if(omode&OTRUNC) error(Eexist); shr = sch->shr; mpt = sch->mpt; - devpermcheck(mpt->owner, mpt->perm, openmode(omode)); + devpermcheck(mpt->owner, mpt->perm, mode); rlock(&shr->umh.lock); if(mpt->m.to == nil || mpt->m.to->mchan == nil){ runlock(&shr->umh.lock); @@ -405,14 +407,14 @@ shropen(Chan *c, int omode) nc = mpt->m.to->mchan; incref(nc); runlock(&shr->umh.lock); - if(openmode(omode) != nc->mode){ + if(mode != nc->mode){ cclose(nc); error(Eperm); } cclose(c); return nc; } - c->mode = openmode(omode); + c->mode = mode; c->flag |= COPEN; c->offset = 0; return c; @@ -430,7 +432,9 @@ shrcreate(Chan *c, char *name, int omode, ulong perm) Mhead *h; Mount *m; Chan *nc; + int mode; + mode = openmode(omode); sch = tosch(c); switch(sch->level){ case Qcroot: @@ -460,7 +464,7 @@ shrcreate(Chan *c, char *name, int omode, ulong perm) case Qcroot: if(up->pgrp->noattach) error(Enoattach); - if((perm & DMDIR) == 0 || openmode(omode) != OREAD) + if((perm & DMDIR) == 0 || mode != OREAD) error(Eperm); if(strlen(name) >= sizeof(up->genbuf)) error(Etoolong); @@ -494,7 +498,7 @@ shrcreate(Chan *c, char *name, int omode, ulong perm) case Qcshr: if(up->pgrp->noattach) error(Enoattach); - if((perm & DMDIR) != 0 || openmode(omode) != OWRITE) + if((perm & DMDIR) != 0 || mode != OWRITE) error(Eperm); shr = sch->shr; @@ -539,7 +543,7 @@ shrcreate(Chan *c, char *name, int omode, ulong perm) break; } c->flag |= COPEN; - c->mode = openmode(omode); + c->mode = mode; return c; } |