Process omode/VFS open flags before dev->open
authorBarret Rhoden <brho@cs.berkeley.edu>
Sat, 18 Jul 2015 20:28:41 +0000 (16:28 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 24 Jul 2015 07:05:13 +0000 (03:05 -0400)
By converting the flags and putting them on the chan before calling the
device's open, the device has a chance to prepare for the flags or error
out.

kern/src/ns/chan.c

index 4891f95..6deeaa6 100644 (file)
@@ -1164,8 +1164,6 @@ Open:
 
                                        if (omode == OEXEC)
                                                c->flag &= ~CCACHE;
-
-                                       c = devtab[c->type].open(c, omode & ~OCEXEC);
                                        /* here is where convert omode/vfs flags to c->flags */
                                        if (omode & O_APPEND)
                                                c->flag |= CAPPEND;
@@ -1174,6 +1172,7 @@ Open:
                                                c->flag |= CCEXEC;
                                        if (omode & ORCLOSE)
                                                c->flag |= CRCLOSE;
+                                       c = devtab[c->type].open(c, omode & ~OCEXEC);
                                        break;
                        }
                        break;