cap: Fix openmode issue
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 27 Jan 2017 21:14:00 +0000 (16:14 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 8 Feb 2017 21:36:32 +0000 (16:36 -0500)
You couldn't ls \#capability.  Plan 9 had a bunch of different rules about
omode than we have.  Incidentally, O_READ is not 0.  And O_RDONLY isn't a
good check - it's just there for compatibility.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/drivers/dev/capability.c

index 1d46269..a59c7b6 100644 (file)
@@ -97,9 +97,9 @@ static int32_t capstat(struct chan *c, uint8_t *db, int32_t n)
 static struct chan *capopen(struct chan *c, int omode)
 {
        if (c->qid.type & QTDIR) {
-               if (omode != O_RDONLY)
-                       error(EISDIR, "Is a directory");
-               c->mode = omode;
+               if (openmode(omode) != O_READ)
+                       error(EISDIR, "Can only read a directory");
+               c->mode = openmode(omode);
                c->flag |= COPEN;
                c->offset = 0;
                return c;