Added explicit errno reporting from error() API.
[akaros.git] / kern / drivers / dev / regress.c
index 30ce706..274e678 100644 (file)
 #include <console.h>
 #include <ktest.h>
 
+struct dev regressdevtab;
+
+static char *devname(void)
+{
+       return regressdevtab.name;
+}
+
 struct regress
 {
        spinlock_t lock;
@@ -58,7 +65,7 @@ regressattach(char *spec)
        if (! regress.monitor) {
                printk("monitor allocate failed. No monitor output\n");
        }
-       return devattach('Z', spec);
+       return devattach(devname(), spec);
 }
 
 static void
@@ -87,8 +94,8 @@ static struct chan*
 regressopen(struct chan *c, int omode)
 {
        if(c->qid.type & QTDIR){
-               if(openmode(omode) != OREAD)
-                       error(Eperm);
+               if(openmode(omode) != O_READ)
+                       error(EPERM, NULL);
        }
        c->mode = openmode(omode);
        c->flag |= COPEN;
@@ -127,7 +134,7 @@ regressread(struct chan *c, void *va, long n, int64_t off)
                        else
                                n = 0;
                } else
-                       error("no monitor queue");
+                       error(EFAIL, "no monitor queue");
                break;
        default:
                n = 0;
@@ -154,7 +161,7 @@ regresswrite(struct chan *c, void *a, long n, int64_t unused)
                if(strncmp(a, "ktest", 5) == 0){
                        run_registered_ktest_suites();
                } else {
-                       error("regresswrite: only commands are %s", ctlcommands);
+                       error(EFAIL, "regresswrite: only commands are %s", ctlcommands);
                }
                break;
 
@@ -163,7 +170,7 @@ regresswrite(struct chan *c, void *a, long n, int64_t unused)
                        n = -1;
                break;
        default:
-               error(Ebadusefd);
+               error(EBADFD, NULL);
        }
        kfree(cb);
        poperror();
@@ -171,7 +178,6 @@ regresswrite(struct chan *c, void *a, long n, int64_t unused)
 }
 
 struct dev regressdevtab __devtab = {
-       'Z',
        "regress",
 
        devreset,