Clarifies O_TRUNC warnings
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 24 Jan 2014 20:09:08 +0000 (12:09 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 24 Jan 2014 21:26:07 +0000 (13:26 -0800)
And some dev debugging.

kern/drivers/dev/dev.c
kern/src/ns/sysfile.c

index 2eabe53..4aebdb3 100644 (file)
@@ -201,14 +201,18 @@ devwalk(struct chan *c,
                for(i=0;; i++) {
                        switch((*gen)(nc, n, tab, ntab, i, &dir)){
                        case -1:
+                               printd("DEVWALK -1, i was %d, want path %p\n", i, c->qid.path);
                        Notfound:
                                if(j == 0)
                                        error(Enonexist);
                                set_errstr(Enonexist);
                                goto Done;
                        case 0:
+                               printd("DEVWALK continue, i was %d\n", i);
                                continue;
                        case 1:
+                               printd("DEVWALK gen returns path %p name %s, want path %p\n",
+                                      dir.qid.path, dir.name, c->qid.path);
                                if(strcmp(n, dir.name) == 0){
                                        nc->qid = dir.qid;
                                        goto Accept;
@@ -247,6 +251,7 @@ devstat(struct chan *c, uint8_t *db, int n,
                switch((*gen)(c, NULL, tab, ntab, i, &dir)){
                case -1:
                        if(c->qid.type & QTDIR){
+                               printd("DEVSTAT got a dir: %llu\n", c->qid.path);
                                if(c->name == NULL)
                                        elem = "???";
                                else if(strcmp(c->name->s, "/") == 0)
@@ -294,12 +299,15 @@ devdirread(struct chan *c, char *d, long n,
        for(m=0; m<n; c->dri++) {
                switch((*gen)(c, NULL, tab, ntab, c->dri, &dir[0])){
                case -1:
+                       printd("DEVDIRREAD got -1, asked for s = %d\n", c->dri);
                        return m;
 
                case 0:
+                       printd("DEVDIRREAD got 0, asked for s = %d\n", c->dri);
                        break;
 
                case 1:
+                       printd("DEVDIRREAD got 1, asked for s = %d\n", c->dri);
                        dsz = convD2M(&dir[0], ( uint8_t *)d, n-m);
                        if(dsz <= BIT16SZ){     /* <= not < because this isn't stat; read is stuck */
                                if(m == 0)
index 7742466..f286fb7 100644 (file)
@@ -108,9 +108,12 @@ fdtochan(struct fgrp *f, int fd, int mode, int chkmnt, int iref)
                error(Ebadusefd);
        }
 
-       /* TODO: this is probably wrong */
+       /* TODO: this is probably wrong.  if you get this from a dev, in the dev's
+        * open, you are probably saving mode directly, without passing it through
+        * openmode. */
        if((mode&~OTRUNC) != c->mode) {
-               warn("Trunc mode issue, check this crap out");
+               warn("Trunc mode issue: mode %o, mode minus trunc %o, chan mode %o\n",
+                    mode, mode & ~OTRUNC, c->mode);
                if(iref)
                        cclose(c);
                error(Ebadusefd);