Kprof uses an IRQ alarm
[akaros.git] / kern / drivers / dev / mnt.c
index 55d4943..ac0c426 100644 (file)
 
 #define MAXRPC (IOHDRSZ+8192)
 
+static __inline int isxdigit(int c)
+{
+       if ((c >= '0') && (c <= '9'))
+               return 1;
+       if ((c >= 'a') && (c <= 'f'))
+               return 1;
+       if ((c >= 'A') && (c <= 'F'))
+               return 1;
+       return 0;
+}
+
 struct mntrpc {
        struct chan *c;                         /* Channel for whom we are working */
        struct mntrpc *list;            /* Free/pending list */
@@ -293,7 +304,7 @@ struct chan *mntauth(struct chan *c, char *spec)
 
        c->qid = r->reply.aqid;
        c->mchan = m->c;
-       kref_get(&m->c->ref, 1);
+       chan_incref(m->c);
        c->mqid = c->qid;
        c->mode = ORDWR;
 
@@ -359,7 +370,7 @@ static struct chan *mntattach(char *muxattach)
 
        c->qid = r->reply.qid;
        c->mchan = m->c;
-       kref_get(&m->c->ref, 1);
+       chan_incref(m->c);
        c->mqid = c->qid;
 
        poperror();     /* r */
@@ -454,7 +465,7 @@ static struct walkqid *mntwalk(struct chan *c, struct chan *nc, char **name,
                if (wq->clone != c) {
                        wq->clone->type = c->type;
                        wq->clone->mchan = c->mchan;
-                       kref_get(&c->mchan->ref, 1);
+                       chan_incref(c->mchan);
                }
                if (r->reply.nwqid > 0)
                        wq->clone->qid = r->reply.wqid[r->reply.nwqid - 1];
@@ -746,6 +757,7 @@ void mountrpc(struct mnt *m, struct mntrpc *r)
 {
        char *sn, *cn;
        int t;
+       char *e;
 
        r->reply.tag = 0;
        r->reply.type = Tmax;   /* can't ever be a valid message type */
@@ -755,7 +767,20 @@ void mountrpc(struct mnt *m, struct mntrpc *r)
        t = r->reply.type;
        switch (t) {
                case Rerror:
-                       error(r->reply.ename);
+                       /* in Akaros mode, first four characters
+                        * are errno.
+                        */
+                       e = r->reply.ename;
+                       /* If it is in the format "XXXX <at least one char>" */
+                       if ((strlen(e) > 5) && isxdigit(e[0]) &&
+                               isxdigit(e[1]) &&
+                               isxdigit(e[2]) &&
+                               isxdigit(e[3])) {
+                               int errno = strtoul(e, NULL, 16);
+                               set_errno(errno);
+                               error(&r->reply.ename[5]);
+                       } else
+                               error(r->reply.ename);
                case Rflush:
                        error(Eintr);
                default:
@@ -783,6 +808,13 @@ void mountio(struct mnt *m, struct mntrpc *r)
        while (waserror()) {
                if (m->rip == current)
                        mntgate(m);
+               if (!strcmp(current_errstr(), "syscall aborted")) {
+                       /* not sure what devmnt wants us to do here.  bail on aborted
+                        * syscall?  keep looping forever? (probably not) */
+                       printk("[kernel] mountio had aborted syscall");
+                       mntflushfree(m, r);
+                       nexterror();
+               }
                if (strcmp(current_errstr(), Eintr) != 0) {
                        mntflushfree(m, r);
                        nexterror();
@@ -1055,6 +1087,7 @@ struct mntrpc *mntralloc(struct chan *c, uint32_t msize)
                        spin_unlock(&mntalloc.l);
                        exhausted("mount rpc header");
                }
+               rendez_init(&new->r);
                /*
                 * The header is split from the data buffer as
                 * mountmux may swap the buffer with another header.