Added explicit errno reporting from error() API.
authorDavide Libenzi <dlibenzi@google.com>
Wed, 7 Oct 2015 02:46:23 +0000 (19:46 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 14 Oct 2015 18:50:45 +0000 (14:50 -0400)
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
40 files changed:
kern/arch/x86/devarch.c
kern/drivers/dev/acpi.c
kern/drivers/dev/alarm.c
kern/drivers/dev/cons.c
kern/drivers/dev/ether.c
kern/drivers/dev/eventfd.c
kern/drivers/dev/kprof.c
kern/drivers/dev/mnt.c
kern/drivers/dev/nix.c
kern/drivers/dev/pci.c
kern/drivers/dev/pipe.c
kern/drivers/dev/proc.c
kern/drivers/dev/regress.c
kern/drivers/dev/root.c
kern/drivers/dev/srv.c
kern/drivers/net/bnx2x/bnx2x_dev.c
kern/drivers/net/ether8169.c
kern/drivers/net/ether82563.c
kern/drivers/net/etherigbe.c
kern/include/err.h
kern/include/error.h
kern/include/ros/errno.h
kern/src/net/arp.c
kern/src/net/devip.c
kern/src/net/ethermedium.c
kern/src/net/ipifc.c
kern/src/net/iproute.c
kern/src/net/netif.c
kern/src/net/netlog.c
kern/src/net/nullmedium.c
kern/src/ns/chan.c
kern/src/ns/dev.c
kern/src/ns/devtab.c
kern/src/ns/parse.c
kern/src/ns/pgrp.c
kern/src/ns/qio.c
kern/src/ns/random.c
kern/src/ns/sysfile.c
kern/src/rendez.c
kern/src/syscall.c

index 4ea42fa..071046c 100644 (file)
@@ -316,7 +316,7 @@ static void checkport(int start, int end)
 
        if (iounused(start, end))
                return;
 
        if (iounused(start, end))
                return;
-       error(Eperm);
+       error(EPERM, NULL);
 }
 
 static struct chan *archattach(char *spec)
 }
 
 static struct chan *archattach(char *spec)
@@ -374,7 +374,7 @@ static long archread(struct chan *c, void *a, long n, int64_t offset)
 
                case Qiow:
                        if (n & 1)
 
                case Qiow:
                        if (n & 1)
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        checkport(offset, offset + n);
                        sp = a;
                        for (port = offset; port < offset + n; port += 2)
                        checkport(offset, offset + n);
                        sp = a;
                        for (port = offset; port < offset + n; port += 2)
@@ -383,7 +383,7 @@ static long archread(struct chan *c, void *a, long n, int64_t offset)
 
                case Qiol:
                        if (n & 3)
 
                case Qiol:
                        if (n & 3)
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        checkport(offset, offset + n);
                        lp = a;
                        for (port = offset; port < offset + n; port += 4)
                        checkport(offset, offset + n);
                        lp = a;
                        for (port = offset; port < offset + n; port += 4)
@@ -396,12 +396,12 @@ static long archread(struct chan *c, void *a, long n, int64_t offset)
                default:
                        if (c->qid.path < narchdir && (fn = readfn[c->qid.path]))
                                return fn(c, a, n, offset);
                default:
                        if (c->qid.path < narchdir && (fn = readfn[c->qid.path]))
                                return fn(c, a, n, offset);
-                       error(Eperm);
+                       error(EPERM, NULL);
                        break;
        }
 
        if ((buf = kzmalloc(n, 0)) == NULL)
                        break;
        }
 
        if ((buf = kzmalloc(n, 0)) == NULL)
-               error(Enomem);
+               error(ENOMEM, NULL);
        p = buf;
        n = n / Linelen;
        offset = offset / Linelen;
        p = buf;
        n = n / Linelen;
        offset = offset / Linelen;
@@ -420,7 +420,7 @@ static long archread(struct chan *c, void *a, long n, int64_t offset)
                        spin_unlock(&(&iomap)->lock);
                        break;
                case Qmapram:
                        spin_unlock(&(&iomap)->lock);
                        break;
                case Qmapram:
-                       error("Not yet");
+                       error(ENOSYS, NULL);
                        break;
        }
 
                        break;
        }
 
@@ -444,13 +444,13 @@ static long archwrite(struct chan *c, void *a, long n, int64_t offset)
                case Qgdb:
                        p = a;
                        if (n != 1)
                case Qgdb:
                        p = a;
                        if (n != 1)
-                               error("Gdb: Write one byte, '1' or '0'");
+                               error(EFAIL, "Gdb: Write one byte, '1' or '0'");
                        if (*p == '1')
                                gdbactive = 1;
                        else if (*p == '0')
                                gdbactive = 0;
                        else
                        if (*p == '1')
                                gdbactive = 1;
                        else if (*p == '0')
                                gdbactive = 0;
                        else
-                               error("Gdb: must be 1 or 0");
+                               error(EFAIL, "Gdb: must be 1 or 0");
                        return 1;
 
                case Qiob:
                        return 1;
 
                case Qiob:
@@ -462,7 +462,7 @@ static long archwrite(struct chan *c, void *a, long n, int64_t offset)
 
                case Qiow:
                        if (n & 1)
 
                case Qiow:
                        if (n & 1)
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        checkport(offset, offset + n);
                        sp = a;
                        for (port = offset; port < offset + n; port += 2)
                        checkport(offset, offset + n);
                        sp = a;
                        for (port = offset; port < offset + n; port += 2)
@@ -471,7 +471,7 @@ static long archwrite(struct chan *c, void *a, long n, int64_t offset)
 
                case Qiol:
                        if (n & 3)
 
                case Qiol:
                        if (n & 3)
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        checkport(offset, offset + n);
                        lp = a;
                        for (port = offset; port < offset + n; port += 4)
                        checkport(offset, offset + n);
                        lp = a;
                        for (port = offset; port < offset + n; port += 4)
@@ -481,7 +481,7 @@ static long archwrite(struct chan *c, void *a, long n, int64_t offset)
                default:
                        if (c->qid.path < narchdir && (fn = writefn[c->qid.path]))
                                return fn(c, a, n, offset);
                default:
                        if (c->qid.path < narchdir && (fn = writefn[c->qid.path]))
                                return fn(c, a, n, offset);
-                       error(Eperm);
+                       error(EPERM, NULL);
                        break;
        }
        return 0;
                        break;
        }
        return 0;
@@ -517,7 +517,7 @@ static long cputyperead(struct chan *unused, void *a, long n, int64_t off)
 {
        char buf[512], *s, *e;
        int i, k;
 {
        char buf[512], *s, *e;
        int i, k;
-       error("unimplemented");
+       error(EFAIL, "unimplemented");
 #if 0
        e = buf + sizeof buf;
        s = seprintf(buf, e, "%s %d\n", "AMD64", 0);
 #if 0
        e = buf + sizeof buf;
        s = seprintf(buf, e, "%s %d\n", "AMD64", 0);
@@ -535,21 +535,21 @@ static long cputyperead(struct chan *unused, void *a, long n, int64_t off)
 static long rmemrw(int isr, void *a, long n, int64_t off)
 {
        if (off < 0)
 static long rmemrw(int isr, void *a, long n, int64_t off)
 {
        if (off < 0)
-               error("offset must be >= 0");
+               error(EFAIL, "offset must be >= 0");
        if (n < 0)
        if (n < 0)
-               error("count must be >= 0");
+               error(EFAIL, "count must be >= 0");
        if (isr) {
                if (off >= MB)
        if (isr) {
                if (off >= MB)
-                       error("offset must be < 1MB");
+                       error(EFAIL, "offset must be < 1MB");
                if (off + n >= MB)
                        n = MB - off;
                memmove(a, KADDR((uint32_t) off), n);
        } else {
                /* realmode buf page ok, allow vga framebuf's access */
                if (off >= MB)
                if (off + n >= MB)
                        n = MB - off;
                memmove(a, KADDR((uint32_t) off), n);
        } else {
                /* realmode buf page ok, allow vga framebuf's access */
                if (off >= MB)
-                       error("offset must be < 1MB");
+                       error(EFAIL, "offset must be < 1MB");
                if (off + n > MB && (off < 0xA0000 || off + n > 0xB0000 + 0x10000))
                if (off + n > MB && (off < 0xA0000 || off + n > 0xB0000 + 0x10000))
-                       error("bad offset/count in write");
+                       error(EFAIL, "bad offset/count in write");
                memmove(KADDR((uint32_t) off), a, n);
        }
        return n;
                memmove(KADDR((uint32_t) off), a, n);
        }
        return n;
index 65de225..a7f96a4 100644 (file)
@@ -347,7 +347,7 @@ static long regio(struct Reg *r, void *p, uint32_t len, uintptr_t off, int iswr)
                        if (r->p == NULL)
                                r->p = KADDR_NOCHECK(r->base);
                        if (r->p == NULL)
                        if (r->p == NULL)
                                r->p = KADDR_NOCHECK(r->base);
                        if (r->p == NULL)
-                               error("regio: vmap/KADDR failed");
+                               error(EFAIL, "regio: vmap/KADDR failed");
                        rp = (uintptr_t) r->p + off;
                        rio = memio;
                        break;
                        rp = (uintptr_t) r->p + off;
                        rio = memio;
                        break;
@@ -367,7 +367,7 @@ static long regio(struct Reg *r, void *p, uint32_t len, uintptr_t off, int iswr)
                case Ripmi:
                case Rfixedhw:
                        printd("regio: reg %s not supported\n", acpiregstr(r->spc));
                case Ripmi:
                case Rfixedhw:
                        printd("regio: reg %s not supported\n", acpiregstr(r->spc));
-                       error("region not supported");
+                       error(EFAIL, "region not supported");
        }
        if (iswr)
                regcpy(&rio, rp, &memio, (uintptr_t) p, len, r->accsz);
        }
        if (iswr)
                regcpy(&rio, rp, &memio, (uintptr_t) p, len, r->accsz);
@@ -1495,7 +1495,7 @@ static struct chan *acpiattach(char *spec)
         * This code must use 64 registers to be acpi ready in nix.
         */
        if (acpiinit() < 0) {
         * This code must use 64 registers to be acpi ready in nix.
         */
        if (acpiinit() < 0) {
-               error("no acpi");
+               error(EFAIL, "no acpi");
        }
 
        /*
        }
 
        /*
@@ -1523,7 +1523,7 @@ static struct chan *acpiattach(char *spec)
                if (getpm1ctl() & Pm1SciEn)
                        break;
        if (i == 10)
                if (getpm1ctl() & Pm1SciEn)
                        break;
        if (i == 10)
-               error("acpi: failed to enable\n");
+               error(EFAIL, "acpi: failed to enable\n");
 //  if(fadt.sciint != 0)
 //      intrenable(fadt.sciint, acpiintr, 0, BUSUNKNOWN, "acpi");
        return devattach(devname(), spec);
 //  if(fadt.sciint != 0)
 //      intrenable(fadt.sciint, acpiintr, 0, BUSUNKNOWN, "acpi");
        return devattach(devname(), spec);
@@ -1563,7 +1563,7 @@ static long acpiread(struct chan *c, void *a, long n, int64_t off)
                ttext = kzmalloc(tlen, 0);
        }
        if (ttext == NULL) {
                ttext = kzmalloc(tlen, 0);
        }
        if (ttext == NULL) {
-               error("acpiread: no memory");
+               error(EFAIL, "acpiread: no memory");
        }
        q = c->qid.path;
        switch (q) {
        }
        q = c->qid.path;
        switch (q) {
@@ -1605,10 +1605,10 @@ static long acpiread(struct chan *c, void *a, long n, int64_t off)
                        return readstr(off, a, n, ttext);
                case Qio:
                        if (reg == NULL)
                        return readstr(off, a, n, ttext);
                case Qio:
                        if (reg == NULL)
-                               error("region not configured");
+                               error(EFAIL, "region not configured");
                        return regio(reg, a, n, off, 0);
        }
                        return regio(reg, a, n, off, 0);
        }
-       error(Eperm);
+       error(EPERM, NULL);
        return -1;
 }
 
        return -1;
 }
 
@@ -1622,11 +1622,11 @@ static long acpiwrite(struct chan *c, void *a, long n, int64_t off)
 
        if (c->qid.path == Qio) {
                if (reg == NULL)
 
        if (c->qid.path == Qio) {
                if (reg == NULL)
-                       error("region not configured");
+                       error(EFAIL, "region not configured");
                return regio(reg, a, n, off, 1);
        }
        if (c->qid.path != Qctl)
                return regio(reg, a, n, off, 1);
        }
        if (c->qid.path != Qctl)
-               error(Eperm);
+               error(EPERM, NULL);
 
        cb = parsecmd(a, n);
        if (waserror()) {
 
        cb = parsecmd(a, n);
        if (waserror()) {
@@ -1647,7 +1647,7 @@ static long acpiwrite(struct chan *c, void *a, long n, int64_t off)
                        if (r->spc < 0) {
                                kfree(r);
                                reg = NULL;
                        if (r->spc < 0) {
                                kfree(r);
                                reg = NULL;
-                               error("bad region type");
+                               error(EFAIL, "bad region type");
                        }
                        if (r->spc == Rpcicfg || r->spc == Rpcibar) {
                                rno = r->base >> Rpciregshift & Rpciregmask;
                        }
                        if (r->spc == Rpcicfg || r->spc == Rpcibar) {
                                rno = r->base >> Rpciregshift & Rpciregmask;
@@ -1667,7 +1667,7 @@ static long acpiwrite(struct chan *c, void *a, long n, int64_t off)
                        if (r->accsz < 1 || r->accsz > 4) {
                                kfree(r);
                                reg = NULL;
                        if (r->accsz < 1 || r->accsz > 4) {
                                kfree(r);
                                reg = NULL;
-                               error("bad region access size");
+                               error(EFAIL, "bad region access size");
                        }
                        reg = r;
                        printd("region %s %s %p %p sz%d",
                        }
                        reg = r;
                        printd("region %s %s %p %p sz%d",
@@ -1676,7 +1676,7 @@ static long acpiwrite(struct chan *c, void *a, long n, int64_t off)
                case CMgpe:
                        i = strtoul(cb->f[1], NULL, 0);
                        if (i >= ngpes)
                case CMgpe:
                        i = strtoul(cb->f[1], NULL, 0);
                        if (i >= ngpes)
-                               error("gpe out of range");
+                               error(EFAIL, "gpe out of range");
                        kstrdup(&gpes[i].obj, cb->f[2]);
                        setgpeen(i, 1);
                        break;
                        kstrdup(&gpes[i].obj, cb->f[2]);
                        setgpeen(i, 1);
                        break;
index f085abb..7ecee2d 100644 (file)
@@ -246,9 +246,9 @@ static struct chan *alarmopen(struct chan *c, int omode)
                case Qtopdir:
                case Qalarmdir:
                        if (omode & O_REMCLO)
                case Qtopdir:
                case Qalarmdir:
                        if (omode & O_REMCLO)
-                               error(Eperm);
+                               error(EPERM, NULL);
                        if (omode & O_WRITE)
                        if (omode & O_WRITE)
-                               error(Eisdir);
+                               error(EISDIR, NULL);
                        break;
                case Qclone:
                        a = kzmalloc(sizeof(struct proc_alarm), KMALLOC_WAIT);
                        break;
                case Qclone:
                        a = kzmalloc(sizeof(struct proc_alarm), KMALLOC_WAIT);
@@ -287,7 +287,7 @@ static struct chan *alarmopen(struct chan *c, int omode)
                        }
                        spin_unlock(&p->alarmset.lock);
                        if (!a_i)
                        }
                        spin_unlock(&p->alarmset.lock);
                        if (!a_i)
-                               error("Unable to open alarm, concurrent closing");
+                               error(EFAIL, "Unable to open alarm, concurrent closing");
                        break;
        }
        c->mode = openmode(omode);
                        break;
        }
        c->mode = openmode(omode);
@@ -299,17 +299,17 @@ static struct chan *alarmopen(struct chan *c, int omode)
 
 static void alarmcreate(struct chan *c, char *name, int omode, uint32_t perm)
 {
 
 static void alarmcreate(struct chan *c, char *name, int omode, uint32_t perm)
 {
-       error(Eperm);
+       error(EPERM, NULL);
 }
 
 static void alarmremove(struct chan *c)
 {
 }
 
 static void alarmremove(struct chan *c)
 {
-       error(Eperm);
+       error(EPERM, NULL);
 }
 
 static int alarmwstat(struct chan *c, uint8_t * dp, int n)
 {
 }
 
 static int alarmwstat(struct chan *c, uint8_t * dp, int n)
 {
-       error("No alarmwstat");
+       error(EFAIL, "No alarmwstat");
        return 0;
 }
 
        return 0;
 }
 
@@ -363,7 +363,7 @@ static long alarmwrite(struct chan *c, void *ubuf, long n, int64_t unused)
        switch (TYPE(c->qid)) {
                case Qtopdir:
                case Qalarmdir:
        switch (TYPE(c->qid)) {
                case Qtopdir:
                case Qalarmdir:
-                       error(Eperm);
+                       error(EPERM, NULL);
                case Qctl:
                        p_alarm = QID2A(c->qid);
                        cb = parsecmd(ubuf, n);
                case Qctl:
                        p_alarm = QID2A(c->qid);
                        cb = parsecmd(ubuf, n);
@@ -372,21 +372,21 @@ static long alarmwrite(struct chan *c, void *ubuf, long n, int64_t unused)
                                nexterror();
                        }
                        if (cb->nf < 1)
                                nexterror();
                        }
                        if (cb->nf < 1)
-                               error("short control request");
+                               error(EFAIL, "short control request");
                        if (!strcmp(cb->f[0], "evq")) {
                                if (cb->nf < 2)
                        if (!strcmp(cb->f[0], "evq")) {
                                if (cb->nf < 2)
-                                       error("evq needs a pointer");
+                                       error(EFAIL, "evq needs a pointer");
                                /* i think it's safe to do a stroul on a parsecmd.  it's kernel
                                 * memory, and space or 0 terminated */
                                hexval = strtoul(cb->f[1], 0, 16);
                                /* This is just to help userspace - event code can handle it */
                                if (!is_user_rwaddr((void *)hexval, sizeof(struct event_queue)))
                                /* i think it's safe to do a stroul on a parsecmd.  it's kernel
                                 * memory, and space or 0 terminated */
                                hexval = strtoul(cb->f[1], 0, 16);
                                /* This is just to help userspace - event code can handle it */
                                if (!is_user_rwaddr((void *)hexval, sizeof(struct event_queue)))
-                                       error("Non-user ev_q pointer");
+                                       error(EFAIL, "Non-user ev_q pointer");
                                p_alarm->ev_q = (struct event_queue *)hexval;
                        } else if (!strcmp(cb->f[0], "cancel")) {
                                unset_alarm(p_alarm->proc->alarmset.tchain, &p_alarm->a_waiter);
                        } else {
                                p_alarm->ev_q = (struct event_queue *)hexval;
                        } else if (!strcmp(cb->f[0], "cancel")) {
                                unset_alarm(p_alarm->proc->alarmset.tchain, &p_alarm->a_waiter);
                        } else {
-                               error("%s: not implemented", cb->f[0]);
+                               error(EFAIL, "%s: not implemented", cb->f[0]);
                        }
                        kfree(cb);
                        poperror();
                        }
                        kfree(cb);
                        poperror();
@@ -396,7 +396,8 @@ static long alarmwrite(struct chan *c, void *ubuf, long n, int64_t unused)
                         * user strings) */
                        if (n > sizeof(num64)) {
                                set_errno(EINVAL);
                         * user strings) */
                        if (n > sizeof(num64)) {
                                set_errno(EINVAL);
-                               error("attempted to write %d chars, max %d", n, sizeof(num64));
+                               error(EFAIL, "attempted to write %d chars, max %d", n,
+                                         sizeof(num64));
                        }
                        memcpy(num64, ubuf, n);
                        num64[n] = 0;   /* enforce trailing 0 */
                        }
                        memcpy(num64, ubuf, n);
                        num64[n] = 0;   /* enforce trailing 0 */
index 1f8b741..173c7bb 100644 (file)
@@ -212,7 +212,7 @@ void sysfatal(char *fmt, ...)
        va_start(arg, fmt);
        vsnprintf(buf, sizeof(buf), fmt, arg);
        va_end(arg);
        va_start(arg, fmt);
        vsnprintf(buf, sizeof(buf), fmt, arg);
        va_end(arg);
-       error(buf);
+       error(EFAIL, buf);
 }
 
 int pprint(char *fmt, ...)
 }
 
 int pprint(char *fmt, ...)
@@ -607,7 +607,7 @@ static struct chan *consopen(struct chan *c, int omode)
        switch ((uint32_t) c->qid.path) {
                case Qconsctl:
                        if (!iseve())
        switch ((uint32_t) c->qid.path) {
                case Qconsctl:
                        if (!iseve())
-                               error(Eperm);
+                               error(EPERM, NULL);
                        qlock(&(&kbd)->qlock);
                        kbd.ctl++;
                        qunlock(&(&kbd)->qlock);
                        qlock(&(&kbd)->qlock);
                        kbd.ctl++;
                        qunlock(&(&kbd)->qlock);
@@ -629,9 +629,9 @@ static struct chan *consopen(struct chan *c, int omode)
                                qunlock(&(&kbd)->qlock);
                                c->flag &= ~COPEN;
                                if (kscanq)
                                qunlock(&(&kbd)->qlock);
                                c->flag &= ~COPEN;
                                if (kscanq)
-                                       error(Einuse);
+                                       error(EBUSY, NULL);
                                else
                                else
-                                       error(Ebadarg);
+                                       error(EINVAL, NULL);
                        }
                        kscanq = qopen(256, 0, NULL, NULL);
                        qunlock(&(&kbd)->qlock);
                        }
                        kscanq = qopen(256, 0, NULL, NULL);
                        qunlock(&(&kbd)->qlock);
@@ -642,12 +642,12 @@ static struct chan *consopen(struct chan *c, int omode)
                                wlock(&(&kprintq)->rwlock);
                                if (kprintq.q != NULL) {
                                        wunlock(&(&kprintq)->rwlock);
                                wlock(&(&kprintq)->rwlock);
                                if (kprintq.q != NULL) {
                                        wunlock(&(&kprintq)->rwlock);
-                                       error(Einuse);
+                                       error(EBUSY, NULL);
                                }
                                kprintq.q = qopen(32 * 1024, Qcoalesce, NULL, NULL);
                                if (kprintq.q == NULL) {
                                        wunlock(&(&kprintq)->rwlock);
                                }
                                kprintq.q = qopen(32 * 1024, Qcoalesce, NULL, NULL);
                                if (kprintq.q == NULL) {
                                        wunlock(&(&kprintq)->rwlock);
-                                       error(Enomem);
+                                       error(ENOMEM, NULL);
                                }
                                qdropoverflow(kprintq.q, 1);
                                wunlock(&(&kprintq)->rwlock);
                                }
                                qdropoverflow(kprintq.q, 1);
                                wunlock(&(&kprintq)->rwlock);
@@ -832,7 +832,7 @@ static long consread(struct chan *c, void *buf, long n, int64_t offset)
                case Qdrivers:
                        p = kzmalloc(READSTR, 0);
                        if (p == NULL)
                case Qdrivers:
                        p = kzmalloc(READSTR, 0);
                        if (p == NULL)
-                               error(Enomem);
+                               error(ENOMEM, NULL);
                        l = 0;
                        for (i = 0; &devtab[i] < __devtabend; i++)
                                l += snprintf(p + l, READSTR - l, "#%s\n", devtab[i].name);
                        l = 0;
                        for (i = 0; &devtab[i] < __devtabend; i++)
                                l += snprintf(p + l, READSTR - l, "#%s\n", devtab[i].name);
@@ -874,7 +874,7 @@ static long consread(struct chan *c, void *buf, long n, int64_t offset)
 #endif
                default:
                        printd("consread %llu\n", c->qid.path);
 #endif
                default:
                        printd("consread %llu\n", c->qid.path);
-                       error(Egreg);
+                       error(EINVAL, NULL);
        }
        return -1;      /* never reached */
 }
        }
        return -1;      /* never reached */
 }
@@ -952,15 +952,15 @@ static long conswrite(struct chan *c, void *va, long n, int64_t offset)
 
                case Qhostowner:
                        if (!iseve())
 
                case Qhostowner:
                        if (!iseve())
-                               error(Eperm);
+                               error(EPERM, NULL);
                        if (offset != 0 || n >= sizeof(buf))
                        if (offset != 0 || n >= sizeof(buf))
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        memmove(buf, a, n);
                        buf[n] = '\0';
                        if (n > 0 && buf[n - 1] == '\n')
                                buf[--n] = 0;
                        if (n <= 0)
                        memmove(buf, a, n);
                        buf[n] = '\0';
                        if (n > 0 && buf[n - 1] == '\n')
                                buf[--n] = 0;
                        if (n <= 0)
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        renameuser(eve, buf);
                        renameproguser(eve, buf);
                        kstrdup(&eve, buf);
                        renameuser(eve, buf);
                        renameproguser(eve, buf);
                        kstrdup(&eve, buf);
@@ -969,11 +969,11 @@ static long conswrite(struct chan *c, void *va, long n, int64_t offset)
 
                case Quser:
                        if (!iseve())
 
                case Quser:
                        if (!iseve())
-                               error(Eperm);
+                               error(EPERM, NULL);
                        if (offset != 0)
                        if (offset != 0)
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        if (n <= 0 || n >= sizeof(buf))
                        if (n <= 0 || n >= sizeof(buf))
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        strncpy(buf, a, n);
                        buf[n] = 0;
                        if (buf[n - 1] == '\n')
                        strncpy(buf, a, n);
                        buf[n] = 0;
                        if (buf[n - 1] == '\n')
@@ -988,7 +988,7 @@ static long conswrite(struct chan *c, void *va, long n, int64_t offset)
                        buf[n] = '\0';
                        x = atoi(buf);
                        if (x < 0 || x > 9)
                        buf[n] = '\0';
                        x = atoi(buf);
                        if (x < 0 || x > 9)
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        cflag = x;
                        return n;
 
                        cflag = x;
                        return n;
 
@@ -997,9 +997,9 @@ static long conswrite(struct chan *c, void *va, long n, int64_t offset)
 
                case Qsysname:
                        if (offset != 0)
 
                case Qsysname:
                        if (offset != 0)
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        if (n <= 0 || n >= sizeof(buf))
                        if (n <= 0 || n >= sizeof(buf))
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        strncpy(buf, a, n);
                        buf[n] = 0;
                        if (buf[n - 1] == '\n')
                        strncpy(buf, a, n);
                        buf[n] = 0;
                        if (buf[n - 1] == '\n')
@@ -1008,7 +1008,7 @@ static long conswrite(struct chan *c, void *va, long n, int64_t offset)
                        break;
 #endif
                case Qsysctl:
                        break;
 #endif
                case Qsysctl:
-                       //if (!iseve()) error(Eperm);
+                       //if (!iseve()) error(EPERM, NULL);
                        cb = parsecmd(a, n);
                        if (cb->nf > 1) 
                        printd("cons sysctl cmd %s\n", cb->f[0]);
                        cb = parsecmd(a, n);
                        if (cb->nf > 1) 
                        printd("cons sysctl cmd %s\n", cb->f[0]);
@@ -1049,7 +1049,7 @@ static long conswrite(struct chan *c, void *va, long n, int64_t offset)
                        break;
                default:
                        printd("conswrite: %llu\n", c->qid.path);
                        break;
                default:
                        printd("conswrite: %llu\n", c->qid.path);
-                       error(Egreg);
+                       error(EINVAL, NULL);
        }
        return n;
 }
        }
        return n;
 }
index d33e2ea..b45ee98 100644 (file)
@@ -44,15 +44,15 @@ struct chan *etherattach(char *spec)
                /* somebody interpret this for me. */
                if (((ctlrno == 0) && (p == spec)) ||
                        (ctlrno >= MaxEther) || ((*p) && (*p != '.')))
                /* somebody interpret this for me. */
                if (((ctlrno == 0) && (p == spec)) ||
                        (ctlrno >= MaxEther) || ((*p) && (*p != '.')))
-                       error(Ebadarg);
+                       error(EINVAL, NULL);
                if (*p == '.') {        /* vlan */
                        vlanid = strtoul(p + 1, &p, 0);
                        if (vlanid <= 0 || vlanid > 0xFFF || *p)
                if (*p == '.') {        /* vlan */
                        vlanid = strtoul(p + 1, &p, 0);
                        if (vlanid <= 0 || vlanid > 0xFFF || *p)
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                }
        }
        if ((ether = etherxx[ctlrno]) == 0)
                }
        }
        if ((ether = etherxx[ctlrno]) == 0)
-               error(Enodev);
+               error(ENODEV, NULL);
        rlock(&ether->rwlock);
        if (waserror()) {
                runlock(&ether->rwlock);
        rlock(&ether->rwlock);
        if (waserror()) {
                runlock(&ether->rwlock);
@@ -60,7 +60,7 @@ struct chan *etherattach(char *spec)
        }
        if (vlanid) {
                if (ether->maxmtu < ETHERMAXTU + 4)
        }
        if (vlanid) {
                if (ether->maxmtu < ETHERMAXTU + 4)
-                       error("interface cannot support 802.1 tags");
+                       error(EFAIL, "interface cannot support 802.1 tags");
                vlan = vlanalloc(ether, vlanid);
                chan = devattach(devname(), spec);
                chan->dev = ctlrno + (vlanid << 8);
                vlan = vlanalloc(ether, vlanid);
                chan = devattach(devname(), spec);
                chan->dev = ctlrno + (vlanid << 8);
@@ -443,7 +443,7 @@ static long etherwrite(struct chan *chan, void *buf, long n, int64_t unused)
                cb = parsecmd(buf, n);
                if (cb->nf < 1) {
                        kfree(cb);
                cb = parsecmd(buf, n);
                if (cb->nf < 1) {
                        kfree(cb);
-                       error("short control request");
+                       error(EFAIL, "short control request");
                }
                if (strcmp(cb->f[0], "nonblocking") == 0) {
                        if (cb->nf <= 1)
                }
                if (strcmp(cb->f[0], "nonblocking") == 0) {
                        if (cb->nf <= 1)
@@ -460,11 +460,11 @@ static long etherwrite(struct chan *chan, void *buf, long n, int64_t unused)
                        l = ether->ctl(ether, buf, n);
                        goto out;
                }
                        l = ether->ctl(ether, buf, n);
                        goto out;
                }
-               error(Ebadctl);
+               error(EINVAL, NULL);
        }
 
        if (n > ether->maxmtu + ETHERHDRSIZE)
        }
 
        if (n > ether->maxmtu + ETHERHDRSIZE)
-               error(Etoobig);
+               error(E2BIG, NULL);
        bp = allocb(n);
        if (waserror()) {
                freeb(bp);
        bp = allocb(n);
        if (waserror()) {
                freeb(bp);
@@ -507,7 +507,7 @@ static long etherbwrite(struct chan *chan, struct block *bp, uint32_t unused)
        }
        if (n > ether->maxmtu + ETHERHDRSIZE && (bp->flag & Btso) == 0) {
                freeb(bp);
        }
        if (n > ether->maxmtu + ETHERHDRSIZE && (bp->flag & Btso) == 0) {
                freeb(bp);
-               error(Etoobig);
+               error(E2BIG, NULL);
        }
        n = etheroq(ether, bp);
        poperror();
        }
        n = etheroq(ether, bp);
        poperror();
@@ -548,7 +548,7 @@ static long vlanctl(struct ether *ether, void *buf, long n)
                return 0;
        }
        kfree(cb);
                return 0;
        }
        kfree(cb);
-       error(Ebadctl);
+       error(EINVAL, NULL);
        return -1;      /* not reached */
 }
 
        return -1;      /* not reached */
 }
 
@@ -576,13 +576,13 @@ static struct ether *vlanalloc(struct ether *ether, int id)
                        fid = i;
        }
        if (fid < 0)
                        fid = i;
        }
        if (fid < 0)
-               error(Enoifc);
+               error(ENOENT, NULL);
        snprintf(name, sizeof(name), "ether%d.%d", ether->ctlrno, id);
        vlan = ether->vlans[fid];
        if (vlan == NULL) {
                vlan = kzmalloc(sizeof(struct ether), 1);
                if (vlan == NULL)
        snprintf(name, sizeof(name), "ether%d.%d", ether->ctlrno, id);
        vlan = ether->vlans[fid];
        if (vlan == NULL) {
                vlan = kzmalloc(sizeof(struct ether), 1);
                if (vlan == NULL)
-                       error(Enovmem);
+                       error(ENOMEM, NULL);
                rwinit(&vlan->rwlock);
                qlock_init(&vlan->vlq);
                netifinit(vlan, name, Ntypes, ether->limit);
                rwinit(&vlan->rwlock);
                qlock_init(&vlan->vlq);
                netifinit(vlan, name, Ntypes, ether->limit);
index 395eaa0..e914cdd 100644 (file)
@@ -163,7 +163,7 @@ static unsigned long efd_read_efd(struct eventfd *efd, struct chan *c)
                if (!old_count) {
                        if (c->flag & O_NONBLOCK) {
                                set_errno(EAGAIN);
                if (!old_count) {
                        if (c->flag & O_NONBLOCK) {
                                set_errno(EAGAIN);
-                               error("Would block on #%s read", devname());
+                               error(EFAIL, "Would block on #%s read", devname());
                        }
                        rendez_sleep(&efd->rv_readers, has_counts, efd);
                } else {
                        }
                        rendez_sleep(&efd->rv_readers, has_counts, efd);
                } else {
@@ -221,7 +221,7 @@ static void efd_write_efd(struct eventfd *efd, unsigned long add_to,
                if (new_count > EFD_MAX_VAL) {
                        if (c->flag & O_NONBLOCK) {
                                set_errno(EAGAIN);
                if (new_count > EFD_MAX_VAL) {
                        if (c->flag & O_NONBLOCK) {
                                set_errno(EAGAIN);
-                               error("Would block on #%s write", devname());
+                               error(EFAIL, "Would block on #%s write", devname());
                        }
                        rendez_sleep(&efd->rv_writers, has_room, efd);
                } else {
                        }
                        rendez_sleep(&efd->rv_writers, has_room, efd);
                } else {
@@ -244,20 +244,19 @@ static long efd_write(struct chan *c, void *ubuf, long n, int64_t offset)
                case Qctl:
                        /* If we want to allow runtime changing of settings, we can do it
                         * here. */
                case Qctl:
                        /* If we want to allow runtime changing of settings, we can do it
                         * here. */
-                       error("No #%s ctl commands supported", devname());
+                       error(EFAIL, "No #%s ctl commands supported", devname());
                        break;
                case Qefd:
                        /* We want to give strtoul a null-terminated buf (can't handle
                         * arbitrary user strings).  Ignoring the chan offset too. */
                        break;
                case Qefd:
                        /* We want to give strtoul a null-terminated buf (can't handle
                         * arbitrary user strings).  Ignoring the chan offset too. */
-                       if (n > sizeof(num64)) {
-                               set_errno(EINVAL);
-                               error("attempted to write %d chars, max %d", n, sizeof(num64));
-                       }
+                       if (n > sizeof(num64))
+                               error(EAGAIN, "attempted to write %d chars, max %d", n,
+                                         sizeof(num64));
                        memcpy(num64, ubuf, n);
                        num64[n] = 0;   /* enforce trailing 0 */
                        write_val = strtoul(num64, 0, 0);
                        if (write_val == (unsigned long)(-1))
                        memcpy(num64, ubuf, n);
                        num64[n] = 0;   /* enforce trailing 0 */
                        write_val = strtoul(num64, 0, 0);
                        if (write_val == (unsigned long)(-1))
-                               error("Eventfd write must not be -1");
+                               error(EFAIL, "Eventfd write must not be -1");
                        efd_write_efd(efd, write_val, c);
                        break;
                default:
                        efd_write_efd(efd, write_val, c);
                        break;
                default:
index 9ac7b27..250b633 100644 (file)
@@ -113,7 +113,7 @@ kprofattach(char *spec)
 {
        // Did we initialise completely?
        if ( !(oprof_alarms && kprof.buf && kprof.systrace) )
 {
        // Did we initialise completely?
        if ( !(oprof_alarms && kprof.buf && kprof.systrace) )
-               error(Enomem);
+               error(ENOMEM, NULL);
 
        return devattach(devname(), spec);
 }
 
        return devattach(devname(), spec);
 }
@@ -191,7 +191,7 @@ static void kprofinit(void)
        oprof_alarms = kzmalloc(sizeof(struct alarm_waiter) * num_cores,
                                KMALLOC_WAIT);
        if (!oprof_alarms)
        oprof_alarms = kzmalloc(sizeof(struct alarm_waiter) * num_cores,
                                KMALLOC_WAIT);
        if (!oprof_alarms)
-               error(Enomem);
+               error(ENOMEM, NULL);
 
        for (int i = 0; i < num_cores; i++)
                init_awaiter_irq(&oprof_alarms[i], oprof_alarm_handler);
 
        for (int i = 0; i < num_cores; i++)
                init_awaiter_irq(&oprof_alarms[i], oprof_alarm_handler);
@@ -239,7 +239,7 @@ kprofopen(struct chan *c, int omode)
 {
        if(c->qid.type & QTDIR){
                if(openmode(omode) != O_READ)
 {
        if(c->qid.type & QTDIR){
                if(openmode(omode) != O_READ)
-                       error(Eperm);
+                       error(EPERM, NULL);
        }
        c->mode = openmode(omode);
        c->flag |= COPEN;
        }
        c->mode = openmode(omode);
        c->flag |= COPEN;
@@ -417,7 +417,7 @@ kprofread(struct chan *c, void *va, long n, int64_t off)
                        else
                                n = 0;
                } else
                        else
                                n = 0;
                } else
-                       error("no systrace queue");
+                       error(EFAIL, "no systrace queue");
                break;
        case Kprintxqid:
                n = readstr(offset, va, n, printx_on ? "on" : "off");
                break;
        case Kprintxqid:
                n = readstr(offset, va, n, printx_on ? "on" : "off");
@@ -457,7 +457,7 @@ static void manage_oprof_timer(int coreid, struct cmdbuf *cb)
                 * is fine. */
                unset_alarm(tchain, waiter);
        } else {
                 * is fine. */
                unset_alarm(tchain, waiter);
        } else {
-               error("optimer needs on|off");
+               error(EFAIL, "optimer needs on|off");
        }
 }
 
        }
 }
 
@@ -478,7 +478,7 @@ kprofwrite(struct chan *c, void *a, long n, int64_t unused)
        switch((int)(c->qid.path)){
        case Kprofctlqid:
                if (cb->nf < 1)
        switch((int)(c->qid.path)){
        case Kprofctlqid:
                if (cb->nf < 1)
-                       error(ctlstring);
+                       error(EFAIL, ctlstring);
 
                /* Kprof: a "which kaddr are we at when the timer goes off".  not used
                 * much anymore */
 
                /* Kprof: a "which kaddr are we at when the timer goes off".  not used
                 * much anymore */
@@ -498,7 +498,7 @@ kprofwrite(struct chan *c, void *a, long n, int64_t unused)
                /* oprof: samples and traces using oprofile */
                } else if (!strcmp(cb->f[0], "optimer")) {
                        if (cb->nf < 3)
                /* oprof: samples and traces using oprofile */
                } else if (!strcmp(cb->f[0], "optimer")) {
                        if (cb->nf < 3)
-                               error("optimer [<0|1|..|n|all> <on|off>] [period USEC]");
+                               error(EFAIL, "optimer [<0|1|..|n|all> <on|off>] [period USEC]");
                        if (!strcmp(cb->f[1], "period")) {
                                oprof_timer_period = strtoul(cb->f[2], 0, 10);
                        } else if (!strcmp(cb->f[1], "all")) {
                        if (!strcmp(cb->f[1], "period")) {
                                oprof_timer_period = strtoul(cb->f[2], 0, 10);
                        } else if (!strcmp(cb->f[1], "all")) {
@@ -507,7 +507,7 @@ kprofwrite(struct chan *c, void *a, long n, int64_t unused)
                        } else {
                                int pcoreid = strtoul(cb->f[1], 0, 10);
                                if (pcoreid >= num_cores)
                        } else {
                                int pcoreid = strtoul(cb->f[1], 0, 10);
                                if (pcoreid >= num_cores)
-                                       error("no such coreid %d", pcoreid);
+                                       error(EFAIL, "no such coreid %d", pcoreid);
                                manage_oprof_timer(pcoreid, cb);
                        }
                } else if (!strcmp(cb->f[0], "opstart")) {
                                manage_oprof_timer(pcoreid, cb);
                        }
                } else if (!strcmp(cb->f[0], "opstart")) {
@@ -515,7 +515,7 @@ kprofwrite(struct chan *c, void *a, long n, int64_t unused)
                } else if (!strcmp(cb->f[0], "opstop")) {
                        oprofile_control_trace(0);
                } else {
                } else if (!strcmp(cb->f[0], "opstop")) {
                        oprofile_control_trace(0);
                } else {
-                       error(ctlstring);
+                       error(EFAIL, ctlstring);
                }
                break;
 
                }
                break;
 
@@ -534,12 +534,12 @@ kprofwrite(struct chan *c, void *a, long n, int64_t unused)
                else if (!strncmp(a, "toggle", 6))      /* why not. */
                        set_printx(2);
                else
                else if (!strncmp(a, "toggle", 6))      /* why not. */
                        set_printx(2);
                else
-                       error("invalid option to Kprintx %s\n", a);
+                       error(EFAIL, "invalid option to Kprintx %s\n", a);
                break;
        case Kmpstatqid:
        case Kmpstatrawqid:
                if (cb->nf < 1)
                break;
        case Kmpstatqid:
        case Kmpstatrawqid:
                if (cb->nf < 1)
-                       error("mpstat bad option (reset|ipi|on|off)");
+                       error(EFAIL, "mpstat bad option (reset|ipi|on|off)");
                if (!strcmp(cb->f[0], "reset")) {
                        for (int i = 0; i < num_cores; i++)
                                reset_cpu_state_ticks(i);
                if (!strcmp(cb->f[0], "reset")) {
                        for (int i = 0; i < num_cores; i++)
                                reset_cpu_state_ticks(i);
@@ -549,19 +549,19 @@ kprofwrite(struct chan *c, void *a, long n, int64_t unused)
                        /* TODO: disable the ticks */ ;
                } else if (!strcmp(cb->f[0], "ipi")) {
                        if (cb->nf < 2)
                        /* TODO: disable the ticks */ ;
                } else if (!strcmp(cb->f[0], "ipi")) {
                        if (cb->nf < 2)
-                               error("need another arg: ipi [on|off]");
+                               error(EFAIL, "need another arg: ipi [on|off]");
                        if (!strcmp(cb->f[1], "on"))
                                kprof.mpstat_ipi = TRUE;
                        else if (!strcmp(cb->f[1], "off"))
                                kprof.mpstat_ipi = FALSE;
                        else
                        if (!strcmp(cb->f[1], "on"))
                                kprof.mpstat_ipi = TRUE;
                        else if (!strcmp(cb->f[1], "off"))
                                kprof.mpstat_ipi = FALSE;
                        else
-                               error("ipi [on|off]");
+                               error(EFAIL, "ipi [on|off]");
                } else {
                } else {
-                       error("mpstat bad option (reset|ipi|on|off)");
+                       error(EFAIL, "mpstat bad option (reset|ipi|on|off)");
                }
                break;
        default:
                }
                break;
        default:
-               error(Ebadusefd);
+               error(EBADFD, NULL);
        }
        kfree(cb);
        poperror();
        }
        kfree(cb);
        poperror();
index 7a1c11e..013ca3b 100644 (file)
@@ -97,9 +97,6 @@ void mountrpc(struct mnt *, struct mntrpc *);
 int rpcattn(void *);
 struct chan *mntchan(void);
 
 int rpcattn(void *);
 struct chan *mntchan(void);
 
-char Esbadstat[] = "invalid directory entry received from server";
-char Enoversion[] = "version not established for mount channel";
-
 void (*mntstats) (int unused_int, struct chan *, uint64_t, uint32_t);
 
 static void mntinit(void)
 void (*mntstats) (int unused_int, struct chan *, uint64_t, uint32_t);
 
 static void mntinit(void)
@@ -145,9 +142,9 @@ long mntversion(struct chan *c, char *version, int msize, int returnlen)
 
        /* validity */
        if (msize < 0)
 
        /* validity */
        if (msize < 0)
-               error("bad iounit in version call");
+               error(EFAIL, "bad iounit in version call");
        if (strncmp(v, VERSION9P, strlen(VERSION9P)) != 0)
        if (strncmp(v, VERSION9P, strlen(VERSION9P)) != 0)
-               error("bad 9P version specification");
+               error(EFAIL, "bad 9P version specification");
 
        m = c->mux;
 
 
        m = c->mux;
 
@@ -160,11 +157,11 @@ long mntversion(struct chan *c, char *version, int msize, int returnlen)
                if (strncmp(buf, v, k) != 0) {
                        snprintf(buf, sizeof buf, "incompatible 9P versions %s %s",
                                         m->version, v);
                if (strncmp(buf, v, k) != 0) {
                        snprintf(buf, sizeof buf, "incompatible 9P versions %s %s",
                                         m->version, v);
-                       error(buf);
+                       error(EFAIL, buf);
                }
                if (returnlen > 0) {
                        if (returnlen < k)
                }
                if (returnlen > 0) {
                        if (returnlen < k)
-                               error(Eshort);
+                               error(ENAMETOOLONG, NULL);
                        memmove(version, buf, k);
                }
                return k;
                        memmove(version, buf, k);
                }
                return k;
@@ -183,7 +180,7 @@ long mntversion(struct chan *c, char *version, int msize, int returnlen)
        }
        k = convS2M(&f, msg, 8192 + IOHDRSZ);
        if (k == 0)
        }
        k = convS2M(&f, msg, 8192 + IOHDRSZ);
        if (k == 0)
-               error("bad fversion conversion on send");
+               error(EFAIL, "bad fversion conversion on send");
 
        spin_lock(&c->lock);
        oo = c->offset;
 
        spin_lock(&c->lock);
        oo = c->offset;
@@ -196,13 +193,13 @@ long mntversion(struct chan *c, char *version, int msize, int returnlen)
                spin_lock(&c->lock);
                c->offset -= k - l;
                spin_unlock(&c->lock);
                spin_lock(&c->lock);
                c->offset -= k - l;
                spin_unlock(&c->lock);
-               error("short write in fversion");
+               error(EFAIL, "short write in fversion");
        }
 
        /* message sent; receive and decode reply */
        k = devtab[c->type].read(c, msg, 8192 + IOHDRSZ, c->offset);
        if (k <= 0)
        }
 
        /* message sent; receive and decode reply */
        k = devtab[c->type].read(c, msg, 8192 + IOHDRSZ, c->offset);
        if (k <= 0)
-               error("EOF receiving fversion reply");
+               error(EFAIL, "EOF receiving fversion reply");
 
        spin_lock(&c->lock);
        c->offset += k;
 
        spin_lock(&c->lock);
        c->offset += k;
@@ -210,18 +207,18 @@ long mntversion(struct chan *c, char *version, int msize, int returnlen)
 
        l = convM2S(msg, k, &f);
        if (l != k)
 
        l = convM2S(msg, k, &f);
        if (l != k)
-               error("bad fversion conversion on reply");
+               error(EFAIL, "bad fversion conversion on reply");
        if (f.type != Rversion) {
                if (f.type == Rerror)
        if (f.type != Rversion) {
                if (f.type == Rerror)
-                       error(f.ename);
-               error("unexpected reply type in fversion");
+                       error(EFAIL, f.ename);
+               error(EFAIL, "unexpected reply type in fversion");
        }
        if (f.msize > msize)
        }
        if (f.msize > msize)
-               error("server tries to increase msize in fversion");
+               error(EFAIL, "server tries to increase msize in fversion");
        if (f.msize < 256 || f.msize > 1024 * 1024)
        if (f.msize < 256 || f.msize > 1024 * 1024)
-               error("nonsense value of msize in fversion");
+               error(EFAIL, "nonsense value of msize in fversion");
        if (strncmp(f.version, v, strlen(f.version)) != 0)
        if (strncmp(f.version, v, strlen(f.version)) != 0)
-               error("bad 9P version returned from server");
+               error(EFAIL, "bad 9P version returned from server");
 
        /* now build Mnt associated with this connection */
        spin_lock(&mntalloc.l);
 
        /* now build Mnt associated with this connection */
        spin_lock(&mntalloc.l);
@@ -261,7 +258,7 @@ long mntversion(struct chan *c, char *version, int msize, int returnlen)
        k = strlen(f.version);
        if (returnlen > 0) {
                if (returnlen < k)
        k = strlen(f.version);
        if (returnlen > 0) {
                if (returnlen < k)
-                       error(Eshort);
+                       error(ENAMETOOLONG, NULL);
                memmove(version, f.version, k);
        }
 
                memmove(version, f.version, k);
        }
 
@@ -280,7 +277,7 @@ struct chan *mntauth(struct chan *c, char *spec)
                mntversion(c, VERSION9P, MAXRPC, 0);
                m = c->mux;
                if (m == NULL)
                mntversion(c, VERSION9P, MAXRPC, 0);
                m = c->mux;
                if (m == NULL)
-                       error(Enoversion);
+                       error(EINVAL, NULL);
        }
 
        c = mntchan();
        }
 
        c = mntchan();
@@ -342,7 +339,7 @@ static struct chan *mntattach(char *muxattach)
                mntversion(c, NULL, 0, 0);
                m = c->mux;
                if (m == NULL)
                mntversion(c, NULL, 0, 0);
                m = c->mux;
                if (m == NULL)
-                       error(Enoversion);
+                       error(EINVAL, NULL);
        }
 
        c = mntchan();
        }
 
        c = mntchan();
@@ -413,7 +410,7 @@ static struct walkqid *mntwalk(struct chan *c, struct chan *nc, char **name,
        if (nc != NULL)
                printd("mntwalk: nc != NULL\n");
        if (nname > MAXWELEM)
        if (nc != NULL)
                printd("mntwalk: nc != NULL\n");
        if (nname > MAXWELEM)
-               error("devmnt: too many name elements");
+               error(EFAIL, "devmnt: too many name elements");
        alloc = 0;
        wq = kzmalloc(sizeof(struct walkqid) + nname * sizeof(struct qid),
                                  KMALLOC_WAIT);
        alloc = 0;
        wq = kzmalloc(sizeof(struct walkqid) + nname * sizeof(struct qid),
                                  KMALLOC_WAIT);
@@ -451,7 +448,7 @@ static struct walkqid *mntwalk(struct chan *c, struct chan *nc, char **name,
        mountrpc(m, r);
 
        if (r->reply.nwqid > nname)
        mountrpc(m, r);
 
        if (r->reply.nwqid > nname)
-               error("too many QIDs returned by walk");
+               error(EFAIL, "too many QIDs returned by walk");
        if (r->reply.nwqid < nname) {
                if (alloc)
                        cclose(nc);
        if (r->reply.nwqid < nname) {
                if (alloc)
                        cclose(nc);
@@ -491,7 +488,7 @@ static int mntstat(struct chan *c, uint8_t * dp, int n)
        struct mntrpc *r;
 
        if (n < BIT16SZ)
        struct mntrpc *r;
 
        if (n < BIT16SZ)
-               error(Eshortstat);
+               error(EINVAL, NULL);
        m = mntchk(c);
        r = mntralloc(c, m->msize);
        if (waserror()) {
        m = mntchk(c);
        r = mntralloc(c, m->msize);
        if (waserror()) {
@@ -794,13 +791,14 @@ void mountrpc(struct mnt *m, struct mntrpc *r)
                                isxdigit(e[1]) &&
                                isxdigit(e[2]) &&
                                isxdigit(e[3])) {
                                isxdigit(e[1]) &&
                                isxdigit(e[2]) &&
                                isxdigit(e[3])) {
+
                                int errno = strtoul(e, NULL, 16);
                                int errno = strtoul(e, NULL, 16);
-                               set_errno(errno);
-                               error(&r->reply.ename[5]);
+
+                               error(errno, &r->reply.ename[5]);
                        } else
                        } else
-                               error(r->reply.ename);
+                               error(EFAIL, r->reply.ename);
                case Rflush:
                case Rflush:
-                       error(Eintr);
+                       error(EINTR, NULL);
                default:
                        if (t == r->request.type + 1)
                                break;
                default:
                        if (t == r->request.type + 1)
                                break;
@@ -814,7 +812,7 @@ void mountrpc(struct mnt *m, struct mntrpc *r)
                                ("mnt: proc %s %lu: mismatch from %s %s rep 0x%p tag %d fid %d T%d R%d rp %d\n",
                                 "current->text", "current->pid", sn, cn, r, r->request.tag,
                                 r->request.fid, r->request.type, r->reply.type, r->reply.tag);
                                ("mnt: proc %s %lu: mismatch from %s %s rep 0x%p tag %d fid %d T%d R%d rp %d\n",
                                 "current->text", "current->pid", sn, cn, r, r->request.tag,
                                 r->request.fid, r->request.type, r->reply.type, r->reply.tag);
-                       error(Emountrpc);
+                       error(EPROTO, NULL);
        }
 }
 
        }
 }
 
@@ -854,7 +852,7 @@ void mountio(struct mnt *m, struct mntrpc *r)
        if (n < 0)
                panic("bad message type in mountio");
        if (devtab[m->c->type].write(m->c, r->rpc, n, 0) != n)
        if (n < 0)
                panic("bad message type in mountio");
        if (devtab[m->c->type].write(m->c, r->rpc, n, 0) != n)
-               error(Emountrpc);
+               error(EIO, NULL);
 /*     r->stime = fastticks(NULL); */
        r->reqlen = n;
 
 /*     r->stime = fastticks(NULL); */
        r->reqlen = n;
 
@@ -875,7 +873,7 @@ void mountio(struct mnt *m, struct mntrpc *r)
        spin_unlock(&m->lock);
        while (r->done == 0) {
                if (mntrpcread(m, r) < 0)
        spin_unlock(&m->lock);
        while (r->done == 0) {
                if (mntrpcread(m, r) < 0)
-                       error(Emountrpc);
+                       error(EIO, NULL);
                mountmux(m, r);
        }
        mntgate(m);
                mountmux(m, r);
        }
        mntgate(m);
index 50b7562..cc05780 100644 (file)
@@ -297,7 +297,7 @@ static void nixinit(void)
 static struct chan *nixattach(char *spec)
 {
        if (!nixok)
 static struct chan *nixattach(char *spec)
 {
        if (!nixok)
-               error("No NIXs available");
+               error(EFAIL, "No NIXs available");
        struct chan *c = devattach(devname(), spec);
        mkqid(&c->qid, Qtopdir, 0, QTDIR);
        return c;
        struct chan *c = devattach(devname(), spec);
        mkqid(&c->qid, Qtopdir, 0, QTDIR);
        return c;
@@ -327,16 +327,16 @@ static struct chan *nixopen(struct chan *c, int omode)
        case Qtopdir:
        case Qnixdir:
                if (omode & O_REMCLO)
        case Qtopdir:
        case Qnixdir:
                if (omode & O_REMCLO)
-                       error(Eperm);
+                       error(EPERM, NULL);
                if (omode & O_WRITE)
                if (omode & O_WRITE)
-                       error(Eisdir);
+                       error(EISDIR, NULL);
                break;
        case Qclone:
                spin_lock_irqsave(&nixlock);
                if (nnix >= 1) {
                        spin_unlock_irqsave(&nixlock);
                        set_errno(EBUSY);
                break;
        case Qclone:
                spin_lock_irqsave(&nixlock);
                if (nnix >= 1) {
                        spin_unlock_irqsave(&nixlock);
                        set_errno(EBUSY);
-                       error("Already have 1 nix, we don't support more");
+                       error(EFAIL, "Already have 1 nix, we don't support more");
                }
                nixs = krealloc(nixs, sizeof(nixs[0]) * (nnix + 1), 0);
                v = &nixs[nnix];
                }
                nixs = krealloc(nixs, sizeof(nixs[0]) * (nnix + 1), 0);
                v = &nixs[nnix];
@@ -371,17 +371,17 @@ static struct chan *nixopen(struct chan *c, int omode)
 
 static void nixcreate(struct chan *c, char *name, int omode, uint32_t perm)
 {
 
 static void nixcreate(struct chan *c, char *name, int omode, uint32_t perm)
 {
-       error(Eperm);
+       error(EPERM, NULL);
 }
 
 static void nixremove(struct chan *c)
 {
 }
 
 static void nixremove(struct chan *c)
 {
-       error(Eperm);
+       error(EPERM, NULL);
 }
 
 static int nixwstat(struct chan *c, uint8_t * dp, int n)
 {
 }
 
 static int nixwstat(struct chan *c, uint8_t * dp, int n)
 {
-       error("No nixwstat");
+       error(EFAIL, "No nixwstat");
        return 0;
 }
 
        return 0;
 }
 
@@ -447,7 +447,7 @@ static long nixwrite(struct chan *c, void *ubuf, long n, int64_t off)
        case Qtopdir:
        case Qnixdir:
        case Qstat:
        case Qtopdir:
        case Qnixdir:
        case Qstat:
-               error(Eperm);
+               error(EPERM, NULL);
        case Qctl:
                nix = c->aux;
                cb = parsecmd(ubuf, n);
        case Qctl:
                nix = c->aux;
                cb = parsecmd(ubuf, n);
@@ -457,38 +457,38 @@ static long nixwrite(struct chan *c, void *ubuf, long n, int64_t off)
                        nexterror();
                }
                if (cb->nf < 1)
                        nexterror();
                }
                if (cb->nf < 1)
-                       error("short control request");
+                       error(EFAIL, "short control request");
                if (!strcmp(cb->f[0], "run")) {
                        int core;
                        uintptr_t ip;
                        if (cb->nf != 3)
                if (!strcmp(cb->f[0], "run")) {
                        int core;
                        uintptr_t ip;
                        if (cb->nf != 3)
-                               error("usage: run core entry");
+                               error(EFAIL, "usage: run core entry");
                        core = strtoul(cb->f[1], 0, 0);
                        ip = strtoul(cb->f[2], 0, 0);
                        if (!test_bit(core, nix->cpus))
                        core = strtoul(cb->f[1], 0, 0);
                        ip = strtoul(cb->f[2], 0, 0);
                        if (!test_bit(core, nix->cpus))
-                               error("Bad core %d", core);
+                               error(EFAIL, "Bad core %d", core);
                        send_kernel_message(core, nixwrapper, (long)ip, 0, 0, KMSG_ROUTINE);
                } else if (!strcmp(cb->f[0], "test")) {
                        int core;
                        if (cb->nf != 2)
                        send_kernel_message(core, nixwrapper, (long)ip, 0, 0, KMSG_ROUTINE);
                } else if (!strcmp(cb->f[0], "test")) {
                        int core;
                        if (cb->nf != 2)
-                               error("usage: test core");
+                               error(EFAIL, "usage: test core");
                        core = strtoul(cb->f[1], 0, 0);
                        if (!test_bit(core, nix->cpus))
                        core = strtoul(cb->f[1], 0, 0);
                        if (!test_bit(core, nix->cpus))
-                               error("Bad core %d", core);
+                               error(EFAIL, "Bad core %d", core);
                        send_kernel_message(core, nixwrapper, (long)nixtest, 0, 0,
                                            KMSG_ROUTINE);
                } else if (!strcmp(cb->f[0], "reserve")) {
                        int core;
                        if (cb->nf != 2)
                        send_kernel_message(core, nixwrapper, (long)nixtest, 0, 0,
                                            KMSG_ROUTINE);
                } else if (!strcmp(cb->f[0], "reserve")) {
                        int core;
                        if (cb->nf != 2)
-                               error("Usage: reserve core (-1 for any)");
+                               error(EFAIL, "Usage: reserve core (-1 for any)");
                        core = strtol(cb->f[1], 0, 0);
                        if (core == -1) {
                                core = get_any_idle_core();
                                if (core < 0)
                        core = strtol(cb->f[1], 0, 0);
                        if (core == -1) {
                                core = get_any_idle_core();
                                if (core < 0)
-                                       error("No free idle cores!");
+                                       error(EFAIL, "No free idle cores!");
                        } else {
                                if (get_specific_idle_core(core) < 0)
                        } else {
                                if (get_specific_idle_core(core) < 0)
-                                       error("Failed to reserve core %d\n", core);
+                                       error(EFAIL, "Failed to reserve core %d\n", core);
                        }
                        set_bit(core, nix->cpus);
                } else if (!strcmp(cb->f[0], "check")) {
                        }
                        set_bit(core, nix->cpus);
                } else if (!strcmp(cb->f[0], "check")) {
@@ -499,23 +499,23 @@ static long nixwrite(struct chan *c, void *ubuf, long n, int64_t off)
                                printk("Core %d is available to nix%d\n", i, nix->id);
                        }
                } else if (!strcmp(cb->f[0], "stop")) {
                                printk("Core %d is available to nix%d\n", i, nix->id);
                        }
                } else if (!strcmp(cb->f[0], "stop")) {
-                       error("can't stop a nix yet");
+                       error(EFAIL, "can't stop a nix yet");
                } else {
                } else {
-                       error("%s: not implemented", cb->f[0]);
+                       error(EFAIL, "%s: not implemented", cb->f[0]);
                }
                kfree(cb);
                poperror();
                break;
        case Qimage:
                if (off < 0)
                }
                kfree(cb);
                poperror();
                break;
        case Qimage:
                if (off < 0)
-                       error("offset < 0!");
+                       error(EFAIL, "offset < 0!");
 
                if (off + n > v->imagesize) {
                        n = v->imagesize - off;
                }
 
                if (memcpy_from_user_errno(current, v->image + off, ubuf, n) < 0)
 
                if (off + n > v->imagesize) {
                        n = v->imagesize - off;
                }
 
                if (memcpy_from_user_errno(current, v->image + off, ubuf, n) < 0)
-                       error("%s: bad user addr %p", __FUNCTION__, ubuf);
+                       error(EFAIL, "%s: bad user addr %p", __FUNCTION__, ubuf);
                break;
 
        default:
                break;
 
        default:
index 8ca0e6e..c28c8ce 100644 (file)
@@ -158,7 +158,7 @@ static long pciread(struct chan *c, void *va, long n, int64_t offset)
                        tbdf = MKBUS(BusPCI, 0, 0, 0) | BUSBDF((uint32_t) c->qid.path);
                        p = pcimatchtbdf(tbdf);
                        if (p == NULL)
                        tbdf = MKBUS(BusPCI, 0, 0, 0) | BUSBDF((uint32_t) c->qid.path);
                        p = pcimatchtbdf(tbdf);
                        if (p == NULL)
-                               error(Egreg);
+                               error(EINVAL, NULL);
                        ebuf = buf + sizeof buf - 1;    /* -1 for newline */
                        w = seprintf(buf, ebuf, "%.2x.%.2x.%.2x %.4x/%.4x %3d",
                                                 p->ccrb, p->ccru, p->ccrp, p->vid, p->did, p->intl);
                        ebuf = buf + sizeof buf - 1;    /* -1 for newline */
                        w = seprintf(buf, ebuf, "%.2x.%.2x.%.2x %.4x/%.4x %3d",
                                                 p->ccrb, p->ccru, p->ccrp, p->vid, p->did, p->intl);
@@ -175,7 +175,7 @@ static long pciread(struct chan *c, void *va, long n, int64_t offset)
                        tbdf = MKBUS(BusPCI, 0, 0, 0) | BUSBDF((uint32_t) c->qid.path);
                        p = pcimatchtbdf(tbdf);
                        if (p == NULL)
                        tbdf = MKBUS(BusPCI, 0, 0, 0) | BUSBDF((uint32_t) c->qid.path);
                        p = pcimatchtbdf(tbdf);
                        if (p == NULL)
-                               error(Egreg);
+                               error(EINVAL, NULL);
                        if (n + offset > 256)
                                n = 256 - offset;
                        if (n < 0)
                        if (n + offset > 256)
                                n = 256 - offset;
                        if (n < 0)
@@ -199,7 +199,7 @@ static long pciread(struct chan *c, void *va, long n, int64_t offset)
                        }
                        return i;
                default:
                        }
                        return i;
                default:
-                       error(Egreg);
+                       error(EINVAL, NULL);
        }
        return n;
 }
        }
        return n;
 }
@@ -223,7 +223,7 @@ static long pciwrite(struct chan *c, void *va, long n, int64_t offset)
                        tbdf = MKBUS(BusPCI, 0, 0, 0) | BUSBDF((uint32_t) c->qid.path);
                        p = pcimatchtbdf(tbdf);
                        if (p == NULL)
                        tbdf = MKBUS(BusPCI, 0, 0, 0) | BUSBDF((uint32_t) c->qid.path);
                        p = pcimatchtbdf(tbdf);
                        if (p == NULL)
-                               error(Egreg);
+                               error(EINVAL, NULL);
                        if (offset > 256)
                                return 0;
                        if (n + offset > 256)
                        if (offset > 256)
                                return 0;
                        if (n + offset > 256)
@@ -247,7 +247,7 @@ static long pciwrite(struct chan *c, void *va, long n, int64_t offset)
                        }
                        return i;
                default:
                        }
                        return i;
                default:
-                       error(Egreg);
+                       error(EINVAL, NULL);
        }
        return n;
 }
        }
        return n;
 }
index 6c63cb2..495a614 100644 (file)
@@ -85,14 +85,14 @@ static struct chan *pipeattach(char *spec)
        c = devattach(devname(), spec);
        p = kzmalloc(sizeof(Pipe), 0);
        if (p == 0)
        c = devattach(devname(), spec);
        p = kzmalloc(sizeof(Pipe), 0);
        if (p == 0)
-               error(Enomem);
+               error(ENOMEM, NULL);
        if (waserror()) {
                freepipe(p);
                nexterror();
        }
        p->pipedir = kzmalloc(sizeof(pipedir), 0);
        if (p->pipedir == 0)
        if (waserror()) {
                freepipe(p);
                nexterror();
        }
        p->pipedir = kzmalloc(sizeof(pipedir), 0);
        if (p->pipedir == 0)
-               error(Enomem);
+               error(ENOMEM, NULL);
        memmove(p->pipedir, pipedir, sizeof(pipedir));
        kstrdup(&p->user, current->user);
        kref_init(&p->ref, pipe_release, 1);
        memmove(p->pipedir, pipedir, sizeof(pipedir));
        kstrdup(&p->user, current->user);
        kref_init(&p->ref, pipe_release, 1);
@@ -100,10 +100,10 @@ static struct chan *pipeattach(char *spec)
 
        p->q[0] = qopen(pipealloc.pipeqsize, Qcoalesce, 0, 0);
        if (p->q[0] == 0)
 
        p->q[0] = qopen(pipealloc.pipeqsize, Qcoalesce, 0, 0);
        if (p->q[0] == 0)
-               error(Enomem);
+               error(ENOMEM, NULL);
        p->q[1] = qopen(pipealloc.pipeqsize, Qcoalesce, 0, 0);
        if (p->q[1] == 0)
        p->q[1] = qopen(pipealloc.pipeqsize, Qcoalesce, 0, 0);
        if (p->q[1] == 0)
-               error(Enomem);
+               error(ENOMEM, NULL);
        poperror();
 
        spin_lock(&(&pipealloc)->lock);
        poperror();
 
        spin_lock(&(&pipealloc)->lock);
@@ -206,7 +206,7 @@ static int pipestat(struct chan *c, uint8_t * db, int n)
        }
        n = convD2M(&dir, db, n);
        if (n < BIT16SZ)
        }
        n = convD2M(&dir, db, n);
        if (n < BIT16SZ)
-               error(Eshortstat);
+               error(ENODATA, NULL);
        return n;
 }
 
        return n;
 }
 
@@ -220,7 +220,7 @@ static struct chan *pipeopen(struct chan *c, int omode)
 
        if (c->qid.type & QTDIR) {
                if (omode & O_WRITE)
 
        if (c->qid.type & QTDIR) {
                if (omode & O_WRITE)
-                       error("Can only open directories O_READ, mode is %o oct", omode);
+                       error(EFAIL, "Can only open directories O_READ, mode is %o oct", omode);
                c->mode = openmode(omode);
                c->flag |= COPEN;
                c->offset = 0;
                c->mode = openmode(omode);
                c->flag |= COPEN;
                c->offset = 0;
@@ -422,10 +422,10 @@ static int pipewstat(struct chan *c, uint8_t * dp, int n)
        int d1;
 
        if (c->qid.type & QTDIR)
        int d1;
 
        if (c->qid.type & QTDIR)
-               error(Eperm);
+               error(EPERM, NULL);
        p = c->aux;
        if (strcmp(current->user, p->user) != 0)
        p = c->aux;
        if (strcmp(current->user, p->user) != 0)
-               error(Eperm);
+               error(EPERM, NULL);
        d = kzmalloc(sizeof(*d) + n, 0);
        if (waserror()) {
                kfree(d);
        d = kzmalloc(sizeof(*d) + n, 0);
        if (waserror()) {
                kfree(d);
@@ -433,14 +433,14 @@ static int pipewstat(struct chan *c, uint8_t * dp, int n)
        }
        n = convM2D(dp, n, d, (char *)&d[1]);
        if (n == 0)
        }
        n = convM2D(dp, n, d, (char *)&d[1]);
        if (n == 0)
-               error(Eshortstat);
+               error(ENODATA, NULL);
        d1 = NETTYPE(c->qid.path) == Qdata1;
        if (!emptystr(d->name)) {
                validwstatname(d->name);
                if (strlen(d->name) >= KNAMELEN)
        d1 = NETTYPE(c->qid.path) == Qdata1;
        if (!emptystr(d->name)) {
                validwstatname(d->name);
                if (strlen(d->name) >= KNAMELEN)
-                       error(Efilename);
+                       error(ENAMETOOLONG, NULL);
                if (strcmp(p->pipedir[1 + !d1].name, d->name) == 0)
                if (strcmp(p->pipedir[1 + !d1].name, d->name) == 0)
-                       error(Eexist);
+                       error(EEXIST, NULL);
                strncpy(p->pipedir[1 + d1].name, d->name,
                                MIN(KNAMELEN, sizeof(p->pipedir[1 + d1].name, d->name)));
        }
                strncpy(p->pipedir[1 + d1].name, d->name,
                                MIN(KNAMELEN, sizeof(p->pipedir[1 + d1].name, d->name)));
        }
index 5976644..2266137 100644 (file)
@@ -398,7 +398,7 @@ static void nonone(struct proc *p)
                return;
        if (iseve())
                return;
                return;
        if (iseve())
                return;
-       error(Eperm);
+       error(EPERM, NULL);
 #endif
 }
 
 #endif
 }
 
@@ -414,28 +414,28 @@ static struct chan *procopen(struct chan *c, int omode)
                return devopen(c, omode, 0, 0, procgen);
 
        if (QID(c->qid) == Qtrace) {
                return devopen(c, omode, 0, 0, procgen);
 
        if (QID(c->qid) == Qtrace) {
-               error("proc: Qtrace: not yet");
+               error(ENOSYS, NULL);
 #if 0
                if (omode != OREAD)
 #if 0
                if (omode != OREAD)
-                       error(Eperm);
+                       error(EPERM, NULL);
                lock(&tlock);
                if (waserror()) {
                        unlock(&tlock);
                        nexterror();
                }
                if (topens > 0)
                lock(&tlock);
                if (waserror()) {
                        unlock(&tlock);
                        nexterror();
                }
                if (topens > 0)
-                       error("already open");
+                       error(EFAIL, "already open");
                topens++;
                if (tevents == NULL) {
                        tevents = (Traceevent *) kzmalloc(sizeof(Traceevent) * Nevents,
                                                                                          KMALLOC_WAIT);
                        if (tevents == NULL)
                topens++;
                if (tevents == NULL) {
                        tevents = (Traceevent *) kzmalloc(sizeof(Traceevent) * Nevents,
                                                                                          KMALLOC_WAIT);
                        if (tevents == NULL)
-                               error(Enomem);
+                               error(ENOMEM, NULL);
                        tpids = kzmalloc(Ntracedpids * 20, KMALLOC_WAIT);
                        if (tpids == NULL) {
                                kfree(tpids);
                                tpids = NULL;
                        tpids = kzmalloc(Ntracedpids * 20, KMALLOC_WAIT);
                        if (tpids == NULL) {
                                kfree(tpids);
                                tpids = NULL;
-                               error(Enomem);
+                               error(ENOMEM, NULL);
                        }
                        tpidsc = tpids;
                        tpidse = tpids + Ntracedpids * 20;
                        }
                        tpidsc = tpids;
                        tpidse = tpids + Ntracedpids * 20;
@@ -453,10 +453,10 @@ static struct chan *procopen(struct chan *c, int omode)
 #endif
        }
        if (QID(c->qid) == Qtracepids) {
 #endif
        }
        if (QID(c->qid) == Qtracepids) {
-               error("Proc: Qtracepids: not yet");
+               error(ENOSYS, NULL);
 #if 0
                if (omode != OREAD)
 #if 0
                if (omode != OREAD)
-                       error(Eperm);
+                       error(EPERM, NULL);
                c->mode = openmode(omode);
                c->flag |= COPEN;
                c->offset = 0;
                c->mode = openmode(omode);
                c->flag |= COPEN;
                c->offset = 0;
@@ -464,7 +464,7 @@ static struct chan *procopen(struct chan *c, int omode)
 #endif
        }
        if ((p = pid2proc(SLOT(c->qid))) == NULL)
 #endif
        }
        if ((p = pid2proc(SLOT(c->qid))) == NULL)
-               error(Eprocdied);
+               error(ESRCH, NULL);
        //qlock(&p->debug);
        if (waserror()) {
                //qunlock(&p->debug);
        //qlock(&p->debug);
        if (waserror()) {
                //qunlock(&p->debug);
@@ -473,16 +473,16 @@ static struct chan *procopen(struct chan *c, int omode)
        }
        pid = PID(c->qid);
        if (p->pid != pid)
        }
        pid = PID(c->qid);
        if (p->pid != pid)
-               error(Eprocdied);
+               error(ESRCH, NULL);
 
        omode = openmode(omode);
 
        switch (QID(c->qid)) {
                case Qtext:
 
        omode = openmode(omode);
 
        switch (QID(c->qid)) {
                case Qtext:
-                       error("notyet");
+                       error(ENOSYS, NULL);
 /*
                        if (omode != OREAD)
 /*
                        if (omode != OREAD)
-                               error(Eperm);
+                               error(EPERM, NULL);
                        tc = proctext(c, p);
                        tc->offset = 0;
                        poperror();
                        tc = proctext(c, p);
                        tc->offset = 0;
                        poperror();
@@ -496,17 +496,17 @@ static struct chan *procopen(struct chan *c, int omode)
                case Qprofile:
                case Qfd:
                        if (omode != O_READ)
                case Qprofile:
                case Qfd:
                        if (omode != O_READ)
-                               error(Eperm);
+                               error(EPERM, NULL);
                        break;
 
                case Qnote:
 //          if (p->privatemem)
                        break;
 
                case Qnote:
 //          if (p->privatemem)
-                       error(Eperm);
+                       error(EPERM, NULL);
                        break;
 
                case Qmem:
 //          if (p->privatemem)
                        break;
 
                case Qmem:
 //          if (p->privatemem)
-                       error(Eperm);
+                       error(EPERM, NULL);
                        //nonone(p);
                        break;
 
                        //nonone(p);
                        break;
 
@@ -523,21 +523,21 @@ static struct chan *procopen(struct chan *c, int omode)
 
                case Qns:
                        if (omode != O_READ)
 
                case Qns:
                        if (omode != O_READ)
-                               error(Eperm);
+                               error(EPERM, NULL);
                        c->aux = kzmalloc(sizeof(struct mntwalk), KMALLOC_WAIT);
                        break;
                case Qstatus:
                case Qctl:
                        break;
                case Qnotepg:
                        c->aux = kzmalloc(sizeof(struct mntwalk), KMALLOC_WAIT);
                        break;
                case Qstatus:
                case Qctl:
                        break;
                case Qnotepg:
-                       error("not yet");
+                       error(ENOSYS, NULL);
 #if 0
                        nonone(p);
                        pg = p->pgrp;
                        if (pg == NULL)
 #if 0
                        nonone(p);
                        pg = p->pgrp;
                        if (pg == NULL)
-                               error(Eprocdied);
+                               error(ESRCH, NULL);
                        if (omode != OWRITE || pg->pgrpid == 1)
                        if (omode != OWRITE || pg->pgrpid == 1)
-                               error(Eperm);
+                               error(EPERM, NULL);
                        c->pgrpid.path = pg->pgrpid + 1;
                        c->pgrpid.vers = p->noteid;
 #endif
                        c->pgrpid.path = pg->pgrpid + 1;
                        c->pgrpid.vers = p->noteid;
 #endif
@@ -548,7 +548,7 @@ static struct chan *procopen(struct chan *c, int omode)
                        //qunlock(&p->debug);
                        kref_put(&p->p_kref);
                        printk("procopen %#llux\n", c->qid.path);
                        //qunlock(&p->debug);
                        kref_put(&p->p_kref);
                        printk("procopen %#llux\n", c->qid.path);
-                       error(Egreg);
+                       error(EINVAL, NULL);
        }
 
        /* Affix pid to qid */
        }
 
        /* Affix pid to qid */
@@ -559,7 +559,7 @@ static struct chan *procopen(struct chan *c, int omode)
        /* TODO: think about what we really want here.  In akaros, we wouldn't have
         * our pid changed like that. */
        if (p->pid != pid)
        /* TODO: think about what we really want here.  In akaros, we wouldn't have
         * our pid changed like that. */
        if (p->pid != pid)
-               error(Eprocdied);
+               error(ESRCH, NULL);
 
        tc = devopen(c, omode, 0, 0, procgen);
        poperror();
 
        tc = devopen(c, omode, 0, 0, procgen);
        poperror();
@@ -571,19 +571,19 @@ static struct chan *procopen(struct chan *c, int omode)
 static int procwstat(struct chan *c, uint8_t * db, int n)
 {
        ERRSTACK(2);
 static int procwstat(struct chan *c, uint8_t * db, int n)
 {
        ERRSTACK(2);
-       error("procwwstat: not yet");
+       error(ENOSYS, NULL);
 #if 0
        struct proc *p;
        struct dir *d;
 
        if (c->qid.type & QTDIR)
 #if 0
        struct proc *p;
        struct dir *d;
 
        if (c->qid.type & QTDIR)
-               error(Eperm);
+               error(EPERM, NULL);
 
        if (QID(c->qid) == Qtrace)
                return devwstat(c, db, n);
 
        if ((p = pid2proc(SLOT(c->qid))) == NULL)
 
        if (QID(c->qid) == Qtrace)
                return devwstat(c, db, n);
 
        if ((p = pid2proc(SLOT(c->qid))) == NULL)
-               error(Eprocdied);
+               error(ESRCH, NULL);
        nonone(p);
        d = NULL;
        qlock(&p->debug);
        nonone(p);
        d = NULL;
        qlock(&p->debug);
@@ -595,18 +595,18 @@ static int procwstat(struct chan *c, uint8_t * db, int n)
        }
 
        if (p->pid != PID(c->qid))
        }
 
        if (p->pid != PID(c->qid))
-               error(Eprocdied);
+               error(ESRCH, NULL);
 
        if (strcmp(current->user, p->user) != 0 && strcmp(current->user, eve) != 0)
 
        if (strcmp(current->user, p->user) != 0 && strcmp(current->user, eve) != 0)
-               error(Eperm);
+               error(EPERM, NULL);
 
        d = kzmalloc(sizeof(struct dir) + n, KMALLOC_WAIT);
        n = convM2D(db, n, &d[0], (char *)&d[1]);
        if (n == 0)
 
        d = kzmalloc(sizeof(struct dir) + n, KMALLOC_WAIT);
        n = convM2D(db, n, &d[0], (char *)&d[1]);
        if (n == 0)
-               error(Eshortstat);
+               error(ENOENT, NULL);
        if (!emptystr(d->uid) && strcmp(d->uid, p->user) != 0) {
                if (strcmp(current->user, eve) != 0)
        if (!emptystr(d->uid) && strcmp(d->uid, p->user) != 0) {
                if (strcmp(current->user, eve) != 0)
-                       error(Eperm);
+                       error(EPERM, NULL);
                else
                        kstrdup(&p->user, d->uid);
        }
                else
                        kstrdup(&p->user, d->uid);
        }
@@ -849,10 +849,10 @@ static long procread(struct chan *c, void *va, long n, int64_t off)
                        return readstr(off, va, n, tpids);
 #endif
        if ((p = pid2proc(SLOT(c->qid))) == NULL)
                        return readstr(off, va, n, tpids);
 #endif
        if ((p = pid2proc(SLOT(c->qid))) == NULL)
-               error(Eprocdied);
+               error(ESRCH, NULL);
        if (p->pid != PID(c->qid)) {
                kref_put(&p->p_kref);
        if (p->pid != PID(c->qid)) {
                kref_put(&p->p_kref);
-               error(Eprocdied);
+               error(ESRCH, NULL);
        }
        switch (QID(c->qid)) {
                default:
        }
        switch (QID(c->qid)) {
                default:
@@ -898,7 +898,7 @@ static long procread(struct chan *c, void *va, long n, int64_t off)
 
                        if (!iseve()) {
                                kref_put(&p->p_kref);
 
                        if (!iseve()) {
                                kref_put(&p->p_kref);
-                               error(Eperm);
+                               error(EPERM, NULL);
                        }
 
                        /* validate kernel addresses */
                        }
 
                        /* validate kernel addresses */
@@ -921,12 +921,12 @@ static long procread(struct chan *c, void *va, long n, int64_t off)
                                }
                        }
                        kref_put(&p->p_kref);
                                }
                        }
                        kref_put(&p->p_kref);
-                       error(Ebadarg);
+                       error(EINVAL, NULL);
 
                case Qprofile:
                        s = p->seg[TSEG];
                        if (s == 0 || s->profile == 0)
 
                case Qprofile:
                        s = p->seg[TSEG];
                        if (s == 0 || s->profile == 0)
-                               error("profile is off");
+                               error(EFAIL, "profile is off");
                        i = (s->top - s->base) >> LRESPROF;
                        i *= sizeof(*s->profile);
                        if (offset >= i) {
                        i = (s->top - s->base) >> LRESPROF;
                        i *= sizeof(*s->profile);
                        if (offset >= i) {
@@ -947,9 +947,9 @@ static long procread(struct chan *c, void *va, long n, int64_t off)
                                nexterror();
                        }
                        if (p->pid != PID(c->qid))
                                nexterror();
                        }
                        if (p->pid != PID(c->qid))
-                               error(Eprocdied);
+                               error(ESRCH, NULL);
                        if (n < 1)      /* must accept at least the '\0' */
                        if (n < 1)      /* must accept at least the '\0' */
-                               error(Etoosmall);
+                               error(ENAMETOOLONG, NULL);
                        if (p->nnote == 0)
                                n = 0;
                        else {
                        if (p->nnote == 0)
                                n = 0;
                        else {
@@ -987,7 +987,7 @@ static long procread(struct chan *c, void *va, long n, int64_t off)
 regread:
                        if (rptr == 0) {
                                kref_put(&p->p_kref);
 regread:
                        if (rptr == 0) {
                                kref_put(&p->p_kref);
-                               error(Enoreg);
+                               error(ENODATA, NULL);
                        }
                        if (offset >= rsize) {
                                kref_put(&p->p_kref);
                        }
                        if (offset >= rsize) {
                                kref_put(&p->p_kref);
@@ -1088,7 +1088,7 @@ regread:
                case Qwait:
                        if (!canqlock(&p->qwaitr)) {
                                kref_put(&p->p_kref);
                case Qwait:
                        if (!canqlock(&p->qwaitr)) {
                                kref_put(&p->p_kref);
-                               error(Einuse);
+                               error(EBUSY, NULL);
                        }
 
                        if (waserror()) {
                        }
 
                        if (waserror()) {
@@ -1100,14 +1100,14 @@ regread:
                        lock(&p->exl);
                        if (up == p && p->nchild == 0 && p->waitq == 0) {
                                unlock(&p->exl);
                        lock(&p->exl);
                        if (up == p && p->nchild == 0 && p->waitq == 0) {
                                unlock(&p->exl);
-                               error(Enochild);
+                               error(ECHILD, NULL);
                        }
                        pid = p->pid;
                        while (p->waitq == 0) {
                                unlock(&p->exl);
                                rendez_sleep(&p->waitr, haswaitq, p);
                                if (p->pid != pid)
                        }
                        pid = p->pid;
                        while (p->waitq == 0) {
                                unlock(&p->exl);
                                rendez_sleep(&p->waitr, haswaitq, p);
                                if (p->pid != pid)
-                                       error(Eprocdied);
+                                       error(ESRCH, NULL);
                                lock(&p->exl);
                        }
                        wq = p->waitq;
                                lock(&p->exl);
                        }
                        wq = p->waitq;
@@ -1144,7 +1144,7 @@ regread:
                                nexterror();
                        }
                        if (p->pgrp == NULL || p->pid != PID(c->qid))
                                nexterror();
                        }
                        if (p->pgrp == NULL || p->pid != PID(c->qid))
-                               error(Eprocdied);
+                               error(ESRCH, NULL);
                        mw = c->aux;
                        if (mw->cddone) {
                                poperror();
                        mw = c->aux;
                        if (mw->cddone) {
                                poperror();
@@ -1188,7 +1188,7 @@ regread:
 #endif
        }
 
 #endif
        }
 
-       error(Egreg);
+       error(EINVAL, NULL);
        return 0;       /* not reached */
 }
 
        return 0;       /* not reached */
 }
 
@@ -1237,17 +1237,17 @@ static long procwrite(struct chan *c, void *va, long n, int64_t off)
        uintptr_t offset;
 
        if (c->qid.type & QTDIR)
        uintptr_t offset;
 
        if (c->qid.type & QTDIR)
-               error(Eisdir);
+               error(EISDIR, NULL);
 
        if ((p = pid2proc(SLOT(c->qid))) == NULL)
 
        if ((p = pid2proc(SLOT(c->qid))) == NULL)
-               error(Eprocdied);
+               error(ESRCH, NULL);
 
        if (waserror()) {
                kref_put(&p->p_kref);
                nexterror();
        }
        if (p->pid != PID(c->qid))
 
        if (waserror()) {
                kref_put(&p->p_kref);
                nexterror();
        }
        if (p->pid != PID(c->qid))
-               error(Eprocdied);
+               error(ESRCH, NULL);
 
        offset = off;
 
 
        offset = off;
 
@@ -1255,13 +1255,13 @@ static long procwrite(struct chan *c, void *va, long n, int64_t off)
 #if 0
                case Qargs:
                        if (n == 0)
 #if 0
                case Qargs:
                        if (n == 0)
-                               error(Eshort);
+                               error(EINVAL, NULL);
                        if (n >= sizeof buf - strlen(p->text) - 1)
                        if (n >= sizeof buf - strlen(p->text) - 1)
-                               error(Etoobig);
+                               error(E2BIG, NULL);
                        l = snprintf(buf, sizeof buf, "%s [%s]", p->text, (char *)va);
                        args = kzmalloc(l + 1, KMALLOC_WAIT);
                        if (args == NULL)
                        l = snprintf(buf, sizeof buf, "%s [%s]", p->text, (char *)va);
                        args = kzmalloc(l + 1, KMALLOC_WAIT);
                        if (args == NULL)
-                               error(Enomem);
+                               error(ENOMEM, NULL);
                        memmove(args, buf, l);
                        args[l] = 0;
                        kfree(p->args);
                        memmove(args, buf, l);
                        args[l] = 0;
                        kfree(p->args);
@@ -1272,7 +1272,7 @@ static long procwrite(struct chan *c, void *va, long n, int64_t off)
 
                case Qmem:
                        if (p->state != Stopped)
 
                case Qmem:
                        if (p->state != Stopped)
-                               error(Ebadctl);
+                               error(EINVAL, NULL);
 
                        n = procctlmemio(p, offset, n, va, 0);
                        break;
 
                        n = procctlmemio(p, offset, n, va, 0);
                        break;
@@ -1283,7 +1283,7 @@ static long procwrite(struct chan *c, void *va, long n, int64_t off)
                        else if (offset + n > sizeof(Ureg))
                                n = sizeof(Ureg) - offset;
                        if (p->dbgreg == 0)
                        else if (offset + n > sizeof(Ureg))
                                n = sizeof(Ureg) - offset;
                        if (p->dbgreg == 0)
-                               error(Enoreg);
+                               error(ENODATA, NULL);
                        setregisters(p->dbgreg, (char *)(p->dbgreg) + offset, va, n);
                        break;
 
                        setregisters(p->dbgreg, (char *)(p->dbgreg) + offset, va, n);
                        break;
 
@@ -1298,7 +1298,7 @@ static long procwrite(struct chan *c, void *va, long n, int64_t off)
                default:
                        poperror();
                        kref_put(&p->p_kref);
                default:
                        poperror();
                        kref_put(&p->p_kref);
-                       error("unknown qid %#llux in procwrite\n", c->qid.path);
+                       error(EFAIL, "unknown qid %#llux in procwrite\n", c->qid.path);
        }
        poperror();
        kref_put(&p->p_kref);
        }
        poperror();
        kref_put(&p->p_kref);
@@ -1338,15 +1338,15 @@ static struct chan *proctext(struct chan *c, struct proc *p)
 
        s = p->seg[TSEG];
        if (s == 0)
 
        s = p->seg[TSEG];
        if (s == 0)
-               error(Enonexist);
+               error(ENOENT, NULL);
        if (p->state == Dead)
        if (p->state == Dead)
-               error(Eprocdied);
+               error(ESRCH, NULL);
 
        lock(s);
        i = s->image;
        if (i == 0) {
                unlock(s);
 
        lock(s);
        i = s->image;
        if (i == 0) {
                unlock(s);
-               error(Eprocdied);
+               error(ESRCH, NULL);
        }
        unlock(s);
 
        }
        unlock(s);
 
@@ -1358,19 +1358,19 @@ static struct chan *proctext(struct chan *c, struct proc *p)
 
        tc = i->c;
        if (tc == 0)
 
        tc = i->c;
        if (tc == 0)
-               error(Eprocdied);
+               error(ESRCH, NULL);
 
        /* TODO: what do you want here?  you can't get a kref and have the new val
         * be 1.  Here is the old code: if (kref_get(&tc->ref, 1) == 1 || ... ) */
        if (kref_refcnt(&tc->ref, 1) == 1 || (tc->flag & COPEN) == 0
                || tc->mode != OREAD) {
                cclose(tc);
 
        /* TODO: what do you want here?  you can't get a kref and have the new val
         * be 1.  Here is the old code: if (kref_get(&tc->ref, 1) == 1 || ... ) */
        if (kref_refcnt(&tc->ref, 1) == 1 || (tc->flag & COPEN) == 0
                || tc->mode != OREAD) {
                cclose(tc);
-               error(Eprocdied);
+               error(ESRCH, NULL);
        }
 
        if (p->pid != PID(c->qid)) {
                cclose(tc);
        }
 
        if (p->pid != PID(c->qid)) {
                cclose(tc);
-               error(Eprocdied);
+               error(ESRCH, NULL);
        }
 
        poperror();
        }
 
        poperror();
@@ -1387,7 +1387,7 @@ void procstopwait(struct proc *p, int ctl)
        int pid;
 
        if (p->pdbg)
        int pid;
 
        if (p->pdbg)
-               error(Einuse);
+               error(EBUSY, NULL);
        if (procstopped(p) || p->state == Broken)
                return;
 
        if (procstopped(p) || p->state == Broken)
                return;
 
@@ -1406,7 +1406,7 @@ void procstopwait(struct proc *p, int ctl)
        poperror();
        qlock(&p->debug);
        if (p->pid != pid)
        poperror();
        qlock(&p->debug);
        if (p->pid != pid)
-               error(Eprocdied);
+               error(ESRCH, NULL);
 }
 
 #endif
 }
 
 #endif
@@ -1462,7 +1462,7 @@ static void procctlreq(struct proc *p, char *va, int n)
                case CMvmstart:
                case CMvmkill:
                default:
                case CMvmstart:
                case CMvmkill:
                default:
-                       error("nope\n");
+                       error(EFAIL, "nope\n");
                        break;
                case CMtrace:
                        systrace_trace_pid(p);
                        break;
                case CMtrace:
                        systrace_trace_pid(p);
@@ -1480,7 +1480,7 @@ static void procctlreq(struct proc *p, char *va, int n)
                case CMkill:
                        p = pid2proc(strtol(cb->f[1], 0, 0));
                        if (!p)
                case CMkill:
                        p = pid2proc(strtol(cb->f[1], 0, 0));
                        if (!p)
-                               error("No such proc\n");
+                               error(EFAIL, "No such proc\n");
 
                        enable_irqsave(&irq_state);
                        proc_destroy(p);
 
                        enable_irqsave(&irq_state);
                        proc_destroy(p);
@@ -1519,7 +1519,7 @@ procctlmemio(struct proc *p, uintptr_t offset, int n, void *va, int read)
        for (;;) {
                s = seg(p, offset, 1);
                if (s == 0)
        for (;;) {
                s = seg(p, offset, 1);
                if (s == 0)
-                       error(Ebadarg);
+                       error(EINVAL, NULL);
 
                if (offset + n >= s->top)
                        n = s->top - offset;
 
                if (offset + n >= s->top)
                        n = s->top - offset;
index 9956633..274e678 100644 (file)
@@ -95,7 +95,7 @@ regressopen(struct chan *c, int omode)
 {
        if(c->qid.type & QTDIR){
                if(openmode(omode) != O_READ)
 {
        if(c->qid.type & QTDIR){
                if(openmode(omode) != O_READ)
-                       error(Eperm);
+                       error(EPERM, NULL);
        }
        c->mode = openmode(omode);
        c->flag |= COPEN;
        }
        c->mode = openmode(omode);
        c->flag |= COPEN;
@@ -134,7 +134,7 @@ regressread(struct chan *c, void *va, long n, int64_t off)
                        else
                                n = 0;
                } else
                        else
                                n = 0;
                } else
-                       error("no monitor queue");
+                       error(EFAIL, "no monitor queue");
                break;
        default:
                n = 0;
                break;
        default:
                n = 0;
@@ -161,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 {
                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;
 
                }
                break;
 
@@ -170,7 +170,7 @@ regresswrite(struct chan *c, void *a, long n, int64_t unused)
                        n = -1;
                break;
        default:
                        n = -1;
                break;
        default:
-               error(Ebadusefd);
+               error(EBADFD, NULL);
        }
        kfree(cb);
        poperror();
        }
        kfree(cb);
        poperror();
index 40217ed..e2b66cc 100644 (file)
@@ -154,7 +154,7 @@ static int newentry(int parent)
        int n = findempty();
        int sib;
        if (n < 0)
        int n = findempty();
        int sib;
        if (n < 0)
-               error("#root. No more");
+               error(EFAIL, "#root. No more");
        printd("new entry is %d\n", n);
        /* add the new one to the head of the linked list.  vers is 'next' */
        roottab[n].qid.vers = rootdata[parent].child;
        printd("new entry is %d\n", n);
        /* add the new one to the head of the linked list.  vers is 'next' */
        roottab[n].qid.vers = rootdata[parent].child;
@@ -203,7 +203,7 @@ static struct chan *rootattach(char *spec)
 {
        struct chan *c;
        if (*spec)
 {
        struct chan *c;
        if (*spec)
-               error(Ebadspec);
+               error(EINVAL, NULL);
        c = devattach(devname(), spec);
        mkqid(&c->qid, roottab[0].qid.path, roottab[0].qid.vers, QTDIR);
        return c;
        c = devattach(devname(), spec);
        mkqid(&c->qid, roottab[0].qid.path, roottab[0].qid.vers, QTDIR);
        return c;
@@ -398,19 +398,20 @@ static long rootwrite(struct chan *c, void *a, long n, int64_t off)
        struct dirtab *r = &roottab[c->qid.path];
 
        if (off < 0)
        struct dirtab *r = &roottab[c->qid.path];
 
        if (off < 0)
-               error("rootwrite: offset < 0!");
+               error(EFAIL, "rootwrite: offset < 0!");
 
        if (off + n > rd->size){
                void *p;
                p = krealloc(rd->ptr, off + n, KMALLOC_WAIT);
                if (! p)
 
        if (off + n > rd->size){
                void *p;
                p = krealloc(rd->ptr, off + n, KMALLOC_WAIT);
                if (! p)
-                       error("rootwrite: could not grow the file to %d bytes", off + n);
+                       error(EFAIL, "rootwrite: could not grow the file to %d bytes",
+                                 off + n);
                rd->ptr = p;
                rd->size = off + n;
        }
        assert(current);
        if (memcpy_from_user_errno(current, rd->ptr + off, a, n) < 0)
                rd->ptr = p;
                rd->size = off + n;
        }
        assert(current);
        if (memcpy_from_user_errno(current, rd->ptr + off, a, n) < 0)
-               error("%s: bad user addr %p", __FUNCTION__, a);
+               error(EFAIL, "%s: bad user addr %p", __FUNCTION__, a);
 
        return n;
 }
 
        return n;
 }
@@ -430,7 +431,7 @@ static int rootwstat(struct chan *c, uint8_t *m_buf, int m_buf_sz)
        m_sz = convM2D(m_buf, m_buf_sz, &dir[0], (char*)&dir[1]);
        if (!m_sz) {
                kfree(dir);
        m_sz = convM2D(m_buf, m_buf_sz, &dir[0], (char*)&dir[1]);
        if (!m_sz) {
                kfree(dir);
-               error(Eshortstat);
+               error(ENODATA, NULL);
        }
        /* TODO: handle more things than just the mode */
        if (!emptystr(dir->name))
        }
        /* TODO: handle more things than just the mode */
        if (!emptystr(dir->name))
index 6349bb3..704b6a1 100644 (file)
@@ -190,7 +190,7 @@ static struct chan *srvopen(struct chan *c, int omode)
        openmode(omode);        /* used as an error checker in plan9, does little now */
        if (c->qid.type & QTDIR) {
                if (omode & O_WRITE)
        openmode(omode);        /* used as an error checker in plan9, does little now */
        if (c->qid.type & QTDIR) {
                if (omode & O_WRITE)
-                       error(Eisdir);
+                       error(EISDIR, NULL);
                c->mode = openmode(omode);
                c->flag |= COPEN;
                c->offset = 0;
                c->mode = openmode(omode);
                c->flag |= COPEN;
                c->offset = 0;
@@ -198,7 +198,7 @@ static struct chan *srvopen(struct chan *c, int omode)
        }
        srv = c->aux;
        if (!grab_ref(srv))
        }
        srv = c->aux;
        if (!grab_ref(srv))
-               error("Unable to open srv file, concurrent removal");
+               error(EFAIL, "Unable to open srv file, concurrent removal");
        if (waserror()) {
                kref_put(&srv->ref);
                nexterror();
        if (waserror()) {
                kref_put(&srv->ref);
                nexterror();
@@ -208,16 +208,16 @@ static struct chan *srvopen(struct chan *c, int omode)
 #if 0
        if (omode & ORCLOSE) {
                if (strcmp(srv->user, up->env->user) != 0)
 #if 0
        if (omode & ORCLOSE) {
                if (strcmp(srv->user, up->env->user) != 0)
-                       error(Eperm);
+                       error(EPERM, NULL);
                else
                        srv->flags |= SORCLOSE;
        }
 #endif
        if ((srv->perm & DMEXCL) && atomic_read(&srv->opens))
                else
                        srv->flags |= SORCLOSE;
        }
 #endif
        if ((srv->perm & DMEXCL) && atomic_read(&srv->opens))
-               error(Einuse);
+               error(EBUSY, NULL);
        /* srv->chan is write-once, so we don't need to sync. */
        if (!srv->chan)
        /* srv->chan is write-once, so we don't need to sync. */
        if (!srv->chan)
-               error("srv file has no chan yet");
+               error(EFAIL, "srv file has no chan yet");
        /* this is more than just the ref - 1, since there will be refs in flight
         * as gens work their way through the list */
        atomic_inc(&srv->opens);
        /* this is more than just the ref - 1, since there will be refs in flight
         * as gens work their way through the list */
        atomic_inc(&srv->opens);
@@ -251,7 +251,7 @@ static void srvcreate(struct chan *c, char *name, int omode, uint32_t perm)
 
 static int srvwstat(struct chan *c, uint8_t * dp, int n)
 {
 
 static int srvwstat(struct chan *c, uint8_t * dp, int n)
 {
-       error("srvwstat not supported yet");
+       error(ENOSYS, NULL);
        return -1;
 }
 
        return -1;
 }
 
@@ -297,16 +297,16 @@ static long srvwrite(struct chan *c, void *va, long count, int64_t offset)
        int fd;
 
        if (c->qid.type & QTDIR)
        int fd;
 
        if (c->qid.type & QTDIR)
-               error(Eperm);
+               error(EPERM, NULL);
        srv = c->aux;
        if (!grab_ref(srv))
        srv = c->aux;
        if (!grab_ref(srv))
-               error("Unable to write srv file, concurrent removal");
+               error(EFAIL, "Unable to write srv file, concurrent removal");
        if (waserror()) {
                kref_put(&srv->ref);
                nexterror();
        }
        if (srv->chan)
        if (waserror()) {
                kref_put(&srv->ref);
                nexterror();
        }
        if (srv->chan)
-               error("srv file already has a stored chan!");
+               error(EFAIL, "srv file already has a stored chan!");
        if (waserror()) {
                kfree(kbuf);
                nexterror();
        if (waserror()) {
                kfree(kbuf);
                nexterror();
@@ -321,7 +321,7 @@ static long srvwrite(struct chan *c, void *va, long count, int64_t offset)
        /* fdtochan already increffed for us */
        if (!__sync_bool_compare_and_swap(&srv->chan, 0, new_chan)) {
                cclose(new_chan);
        /* fdtochan already increffed for us */
        if (!__sync_bool_compare_and_swap(&srv->chan, 0, new_chan)) {
                cclose(new_chan);
-               error("srv file already has a stored chan!");
+               error(EFAIL, "srv file already has a stored chan!");
        }
        poperror();
        kfree(kbuf);
        }
        poperror();
        kfree(kbuf);
index a989290..f149546 100644 (file)
@@ -60,7 +60,7 @@ static long bnx2x_ifstat(struct ether *edev, void *a, long n, uint32_t offset)
        p = kzmalloc(READSTR, 0);
        if (p == NULL) {
                qunlock(&ctlr->slock);
        p = kzmalloc(READSTR, 0);
        if (p == NULL) {
                qunlock(&ctlr->slock);
-               error(Enomem);
+               error(ENOMEM, NULL);
        }
        l = 0;
        for (i = 0; i < Nstatistics; i++) {
        }
        l = 0;
        for (i = 0; i < Nstatistics; i++) {
@@ -101,14 +101,14 @@ static long bnx2x_ctl(struct ether *edev, void *buf, long n)
        struct cmdtab *ct;
 
        if ((ctlr = edev->ctlr) == NULL)
        struct cmdtab *ct;
 
        if ((ctlr = edev->ctlr) == NULL)
-               error(Enonexist);
+               error(ENODEV, NULL);
        cb = parsecmd(buf, n);
        if (waserror()) {
                kfree(cb);
                nexterror();
        }
        if (cb->nf < 1)
        cb = parsecmd(buf, n);
        if (waserror()) {
                kfree(cb);
                nexterror();
        }
        if (cb->nf < 1)
-               error("short control request");
+               error(EFAIL, "short control request");
 
        /* TODO: handle ctl command somehow.  igbe did the following: */
        //ct = lookupcmd(cb, igbectlmsg, ARRAY_SIZE(igbectlmsg));
 
        /* TODO: handle ctl command somehow.  igbe did the following: */
        //ct = lookupcmd(cb, igbectlmsg, ARRAY_SIZE(igbectlmsg));
@@ -418,7 +418,7 @@ static void bnx2x_pci(void)
 
                ctlr = kzmalloc(sizeof(struct bnx2x), 0);
                if (ctlr == NULL)
 
                ctlr = kzmalloc(sizeof(struct bnx2x), 0);
                if (ctlr == NULL)
-                       error(Enomem);
+                       error(ENOMEM, NULL);
 
                spinlock_init_irqsave(&ctlr->imlock);
                spinlock_init_irqsave(&ctlr->tlock);
 
                spinlock_init_irqsave(&ctlr->imlock);
                spinlock_init_irqsave(&ctlr->tlock);
index f3aea84..be650b8 100644 (file)
@@ -513,7 +513,7 @@ rtl8169ifstat(struct ether* edev, void* a, long n, uint32_t offset)
                udelay(1000*1);
        }
        if(csr32r(ctlr, Dtccr) & Cmd)
                udelay(1000*1);
        }
        if(csr32r(ctlr, Dtccr) & Cmd)
-               error(Eio);
+               error(EIO, NULL);
        dtcc = ctlr->dtcc;
 
        edev->oerrs = dtcc->txer;
        dtcc = ctlr->dtcc;
 
        edev->oerrs = dtcc->txer;
@@ -529,7 +529,7 @@ rtl8169ifstat(struct ether* edev, void* a, long n, uint32_t offset)
        }
 
        if((alloc = kzmalloc(READSTR, 0)) == NULL)
        }
 
        if((alloc = kzmalloc(READSTR, 0)) == NULL)
-               error(Enomem);
+               error(ENOMEM, NULL);
        e = alloc+READSTR;
 
        p = seprintf(alloc, e, "TxOk: %llu\n", dtcc->txok);
        e = alloc+READSTR;
 
        p = seprintf(alloc, e, "TxOk: %llu\n", dtcc->txok);
index 8ce14da..cc3d49e 100644 (file)
@@ -1362,7 +1362,7 @@ static void i82563attach(struct ether *edev)
                kzmalloc(ctlr->nrd * sizeof(Rd) + ctlr->ntd * sizeof(Td) + 255, 0);
        if (ctlr->alloc == NULL) {
                qunlock(&ctlr->alock);
                kzmalloc(ctlr->nrd * sizeof(Rd) + ctlr->ntd * sizeof(Td) + 255, 0);
        if (ctlr->alloc == NULL) {
                qunlock(&ctlr->alock);
-               error(Enomem);
+               error(ENOMEM, NULL);
        }
        ctlr->rdba = (Rd *) ROUNDUP((uintptr_t) ctlr->alloc, 256);
        ctlr->tdba = (Td *) (ctlr->rdba + ctlr->nrd);
        }
        ctlr->rdba = (Rd *) ROUNDUP((uintptr_t) ctlr->alloc, 256);
        ctlr->tdba = (Td *) (ctlr->rdba + ctlr->nrd);
@@ -1693,7 +1693,7 @@ static long i82563ctl(struct ether *edev, void *buf, long n)
        struct cmdtab *ct;
 
        if ((ctlr = edev->ctlr) == NULL)
        struct cmdtab *ct;
 
        if ((ctlr = edev->ctlr) == NULL)
-               error(Enonexist);
+               error(ENODEV, NULL);
 
        cb = parsecmd(buf, n);
        if (waserror()) {
 
        cb = parsecmd(buf, n);
        if (waserror()) {
@@ -1706,14 +1706,14 @@ static long i82563ctl(struct ether *edev, void *buf, long n)
                case CMrdtr:
                        v = strtoul(cb->f[1], &p, 0);
                        if (*p || v > 0xffff)
                case CMrdtr:
                        v = strtoul(cb->f[1], &p, 0);
                        if (*p || v > 0xffff)
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        ctlr->rdtr = v;
                        csr32w(ctlr, Rdtr, v);
                        break;
                case CMradv:
                        v = strtoul(cb->f[1], &p, 0);
                        if (*p || v > 0xffff)
                        ctlr->rdtr = v;
                        csr32w(ctlr, Rdtr, v);
                        break;
                case CMradv:
                        v = strtoul(cb->f[1], &p, 0);
                        if (*p || v > 0xffff)
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        ctlr->radv = v;
                        csr32w(ctlr, Radv, v);
                        break;
                        ctlr->radv = v;
                        csr32w(ctlr, Radv, v);
                        break;
index ef111aa..5346d99 100644 (file)
@@ -639,7 +639,7 @@ igbeifstat(struct ether* edev, void* a, long n, uint32_t offset)
        p = kzmalloc(READSTR, 0);
        if(p == NULL) {
                qunlock(&ctlr->slock);
        p = kzmalloc(READSTR, 0);
        if(p == NULL) {
                qunlock(&ctlr->slock);
-               error(Enomem);
+               error(ENOMEM, NULL);
        }
        l = 0;
        for(i = 0; i < Nstatistics; i++){
        }
        l = 0;
        for(i = 0; i < Nstatistics; i++){
@@ -730,7 +730,7 @@ igbectl(struct ether* edev, void* buf, long n)
        struct cmdtab *ct;
 
        if((ctlr = edev->ctlr) == NULL)
        struct cmdtab *ct;
 
        if((ctlr = edev->ctlr) == NULL)
-               error(Enonexist);
+               error(ENODEV, NULL);
 
        cb = parsecmd(buf, n);
        if(waserror()){
 
        cb = parsecmd(buf, n);
        if(waserror()){
@@ -743,7 +743,7 @@ igbectl(struct ether* edev, void* buf, long n)
        case CMrdtr:
                v = strtol(cb->f[1], &p, 0);
                if(v < 0 || p == cb->f[1] || v > 0xFFFF)
        case CMrdtr:
                v = strtol(cb->f[1], &p, 0);
                if(v < 0 || p == cb->f[1] || v > 0xFFFF)
-                       error(Ebadarg);
+                       error(EINVAL, NULL);
                ctlr->rdtr = v;
                csr32w(ctlr, Rdtr, Fpd|v);
                break;
                ctlr->rdtr = v;
                csr32w(ctlr, Rdtr, Fpd|v);
                break;
@@ -1245,7 +1245,7 @@ igbeattach(struct ether* edev)
        ctlr->alloc = kzmalloc(ctlr->nrd * sizeof(Rd) + ctlr->ntd * sizeof(Td) + 127, 0);
        if(ctlr->alloc == NULL) {
                printd("igbe: can't allocate ctlr->alloc\n");
        ctlr->alloc = kzmalloc(ctlr->nrd * sizeof(Rd) + ctlr->ntd * sizeof(Td) + 127, 0);
        if(ctlr->alloc == NULL) {
                printd("igbe: can't allocate ctlr->alloc\n");
-               error(Enomem);
+               error(ENOMEM, NULL);
        }
        ctlr->rdba = (Rd*)ROUNDUP((uintptr_t)ctlr->alloc, 128);
        ctlr->tdba = (Td*)(ctlr->rdba+ctlr->nrd);
        }
        ctlr->rdba = (Rd*)ROUNDUP((uintptr_t)ctlr->alloc, 128);
        ctlr->tdba = (Td*)(ctlr->rdba+ctlr->nrd);
@@ -1254,7 +1254,7 @@ igbeattach(struct ether* edev)
        ctlr->tb = kzmalloc(ctlr->ntd * sizeof(struct block *), 0);
        if (ctlr->rb == NULL || ctlr->tb == NULL) {
                printd("igbe: can't allocate ctlr->rb or ctlr->tb\n");
        ctlr->tb = kzmalloc(ctlr->ntd * sizeof(struct block *), 0);
        if (ctlr->rb == NULL || ctlr->tb == NULL) {
                printd("igbe: can't allocate ctlr->rb or ctlr->tb\n");
-               error(Enomem);
+               error(ENOMEM, NULL);
        }
 
        /* the ktasks should free these names, if they ever exit */
        }
 
        /* the ktasks should free these names, if they ever exit */
@@ -1997,7 +1997,7 @@ igbepci(void)
                ctlr = kzmalloc(sizeof(struct ctlr), 0);
                if(ctlr == NULL) {
                        vunmap_vmem((uintptr_t)mem, pcidev->bar[0].mmio_sz);
                ctlr = kzmalloc(sizeof(struct ctlr), 0);
                if(ctlr == NULL) {
                        vunmap_vmem((uintptr_t)mem, pcidev->bar[0].mmio_sz);
-                       error(Enomem);
+                       error(ENOMEM, NULL);
                }
                spinlock_init_irqsave(&ctlr->imlock);
                spinlock_init_irqsave(&ctlr->tlock);
                }
                spinlock_init_irqsave(&ctlr->imlock);
                spinlock_init_irqsave(&ctlr->tlock);
index 37fd8e5..b2c5fd0 100644 (file)
@@ -11,8 +11,9 @@
 #define waserror() (errpush(errstack, ARRAY_SIZE(errstack), &curindex,         \
                             &prev_errbuf) ||                                   \
                     setjmp(&(get_cur_errbuf()->jmpbuf)))
 #define waserror() (errpush(errstack, ARRAY_SIZE(errstack), &curindex,         \
                             &prev_errbuf) ||                                   \
                     setjmp(&(get_cur_errbuf()->jmpbuf)))
-#define error(x,...) do {set_errstr(x, ##__VA_ARGS__);                         \
-                            longjmp(&get_cur_errbuf()->jmpbuf, 1);} while(0)
+#define error(e, x,...) do {set_errstr(x, ##__VA_ARGS__);                              \
+                                                       set_errno(e);                                                           \
+                                                       longjmp(&get_cur_errbuf()->jmpbuf, 1);} while(0)
 #define nexterror() do {errpop(errstack, ARRAY_SIZE(errstack), &curindex,      \
                             prev_errbuf);                                      \
                      longjmp(&(get_cur_errbuf())->jmpbuf, 1);} while (0)
 #define nexterror() do {errpop(errstack, ARRAY_SIZE(errstack), &curindex,      \
                             prev_errbuf);                                      \
                      longjmp(&(get_cur_errbuf())->jmpbuf, 1);} while (0)
index 7bcd98a..d0d2d83 100644 (file)
@@ -6,12 +6,11 @@
 #include <ros/errno.h>
 
 typedef int error_t;
 #include <ros/errno.h>
 
 typedef int error_t;
+extern const char *const errno_strings[];
+extern const int MAX_ERRNO;
 
 #define ERR_PTR(err)  ((void *)((uintptr_t)(err)))
 #define PTR_ERR(ptr)  ((uintptr_t)(ptr))
 
 #define ERR_PTR(err)  ((void *)((uintptr_t)(err)))
 #define PTR_ERR(ptr)  ((uintptr_t)(ptr))
-#define IS_ERR(ptr)   ((uintptr_t)-(uintptr_t)(ptr) < 512)
-
-extern const char *const errno_strings[];
-extern const int MAX_ERRNO;
+#define IS_ERR(ptr)   ((uintptr_t)-(uintptr_t)(ptr) <= MAX_ERRNO)
 
 #endif // !ROS_INC_ERROR_H */
 
 #endif // !ROS_INC_ERROR_H */
index 4f3b6b3..e73e0c6 100644 (file)
@@ -3,7 +3,8 @@
 
 /* If you edit this file, be careful of tabs vs spaces.  This is processed by
  * scripts/make_errlist.c, which you need to run if you want glibc strerrno() to
 
 /* If you edit this file, be careful of tabs vs spaces.  This is processed by
  * scripts/make_errlist.c, which you need to run if you want glibc strerrno() to
- * know about your changes. */
+ * know about your changes.
+ * Keep this header with definitions ordered ascending. */
 
 // See below for the rest of the new error codes for ROS
 #define        ESUCCESS        0       /* Success */
 
 // See below for the rest of the new error codes for ROS
 #define        ESUCCESS        0       /* Success */
index c1a2ffa..845cbe1 100644 (file)
@@ -45,8 +45,6 @@ struct arp {
        struct block *dropf, *dropl;
 };
 
        struct block *dropf, *dropl;
 };
 
-char *Ebadarp = "bad arp";
-
 #define haship(s) ((s)[IPaddrlen-1]%NHASH)
 
 int ReTransTimer = RETRANS_TIMER;
 #define haship(s) ((s)[IPaddrlen-1]%NHASH)
 
 int ReTransTimer = RETRANS_TIMER;
@@ -424,7 +422,7 @@ int arpwrite(struct Fs *fs, char *s, int len)
        arp = fs->arp;
 
        if (len == 0)
        arp = fs->arp;
 
        if (len == 0)
-               error(Ebadarp);
+               error(EINVAL, NULL);
        if (len >= sizeof(buf))
                len = sizeof(buf) - 1;
        strncpy(buf, s, len);
        if (len >= sizeof(buf))
                len = sizeof(buf) - 1;
        strncpy(buf, s, len);
@@ -456,7 +454,7 @@ int arpwrite(struct Fs *fs, char *s, int len)
        } else if (strcmp(f[0], "add") == 0) {
                switch (n) {
                        default:
        } else if (strcmp(f[0], "add") == 0) {
                switch (n) {
                        default:
-                               error(Ebadarg);
+                               error(EINVAL, NULL);
                        case 3:
                                parseip(ip, f[1]);
                                if (isv4(ip))
                        case 3:
                                parseip(ip, f[1]);
                                if (isv4(ip))
@@ -464,26 +462,26 @@ int arpwrite(struct Fs *fs, char *s, int len)
                                else
                                        r = v6lookup(fs, ip, NULL);
                                if (r == NULL)
                                else
                                        r = v6lookup(fs, ip, NULL);
                                if (r == NULL)
-                                       error("Destination unreachable");
+                                       error(EFAIL, "Destination unreachable");
                                m = r->rt.ifc->m;
                                n = parsemac(mac, f[2], m->maclen);
                                break;
                        case 4:
                                m = ipfindmedium(f[1]);
                                if (m == NULL)
                                m = r->rt.ifc->m;
                                n = parsemac(mac, f[2], m->maclen);
                                break;
                        case 4:
                                m = ipfindmedium(f[1]);
                                if (m == NULL)
-                                       error(Ebadarp);
+                                       error(EINVAL, NULL);
                                parseip(ip, f[2]);
                                n = parsemac(mac, f[3], m->maclen);
                                break;
                }
 
                if (m->ares == NULL)
                                parseip(ip, f[2]);
                                n = parsemac(mac, f[3], m->maclen);
                                break;
                }
 
                if (m->ares == NULL)
-                       error(Ebadarp);
+                       error(EINVAL, NULL);
 
                m->ares(fs, V6, ip, mac, n, 0);
        } else if (strcmp(f[0], "del") == 0) {
                if (n != 2)
 
                m->ares(fs, V6, ip, mac, n, 0);
        } else if (strcmp(f[0], "del") == 0) {
                if (n != 2)
-                       error(Ebadarg);
+                       error(EINVAL, NULL);
 
                parseip(ip, f[1]);
                qlock(&arp->qlock);
 
                parseip(ip, f[1]);
                qlock(&arp->qlock);
@@ -518,7 +516,7 @@ int arpwrite(struct Fs *fs, char *s, int len)
                }
                qunlock(&arp->qlock);
        } else
                }
                qunlock(&arp->qlock);
        } else
-               error(Ebadarp);
+               error(EINVAL, NULL);
 
        return len;
 }
 
        return len;
 }
index 4e0149b..92d89f8 100644 (file)
@@ -331,7 +331,7 @@ static struct chan *ipattach(char *spec)
 
        dev = atoi(spec);
        if (dev >= Nfs)
 
        dev = atoi(spec);
        if (dev >= Nfs)
-               error("bad specification");
+               error(EFAIL, "bad specification");
 
        ipgetfs(dev);
        c = devattach(devname(), spec);
 
        ipgetfs(dev);
        c = devattach(devname(), spec);
@@ -387,7 +387,7 @@ static struct chan *ipopen(struct chan *c, int omode)
                        break;
                case Qndb:
                        if (omode & (O_WRITE | O_TRUNC) && !iseve())
                        break;
                case Qndb:
                        if (omode & (O_WRITE | O_TRUNC) && !iseve())
-                               error(Eperm);
+                               error(EPERM, NULL);
                        if ((omode & (O_WRITE | O_TRUNC)) == (O_WRITE | O_TRUNC))
                                f->ndb[0] = 0;
                        break;
                        if ((omode & (O_WRITE | O_TRUNC)) == (O_WRITE | O_TRUNC))
                                f->ndb[0] = 0;
                        break;
@@ -409,15 +409,15 @@ static struct chan *ipopen(struct chan *c, int omode)
                case Qbootp:
                case Qipselftab:
                        if (omode & O_WRITE)
                case Qbootp:
                case Qipselftab:
                        if (omode & O_WRITE)
-                               error(Eperm);
+                               error(EPERM, NULL);
                        break;
                case Qsnoop:
                        if (omode & O_WRITE)
                        break;
                case Qsnoop:
                        if (omode & O_WRITE)
-                               error(Eperm);
+                               error(EPERM, NULL);
                        p = f->p[PROTO(c->qid)];
                        cv = p->conv[CONV(c->qid)];
                        if (strcmp(ATTACHER(c), cv->owner) != 0 && !iseve())
                        p = f->p[PROTO(c->qid)];
                        cv = p->conv[CONV(c->qid)];
                        if (strcmp(ATTACHER(c), cv->owner) != 0 && !iseve())
-                               error(Eperm);
+                               error(EPERM, NULL);
                        atomic_inc(&cv->snoopers);
                        break;
                case Qclone:
                        atomic_inc(&cv->snoopers);
                        break;
                case Qclone:
@@ -431,7 +431,7 @@ static struct chan *ipopen(struct chan *c, int omode)
                        qunlock(&p->qlock);
                        poperror();
                        if (cv == NULL) {
                        qunlock(&p->qlock);
                        poperror();
                        if (cv == NULL) {
-                               error(Enodev);
+                               error(ENODEV, NULL);
                                break;
                        }
                        /* we only honor nonblock on a clone */
                                break;
                        }
                        /* we only honor nonblock on a clone */
@@ -453,9 +453,9 @@ static struct chan *ipopen(struct chan *c, int omode)
                        }
                        if ((perm & (cv->perm >> 6)) != perm) {
                                if (strcmp(ATTACHER(c), cv->owner) != 0)
                        }
                        if ((perm & (cv->perm >> 6)) != perm) {
                                if (strcmp(ATTACHER(c), cv->owner) != 0)
-                                       error(Eperm);
+                                       error(EPERM, NULL);
                                if ((perm & cv->perm) != perm)
                                if ((perm & cv->perm) != perm)
-                                       error(Eperm);
+                                       error(EPERM, NULL);
 
                        }
                        cv->inuse++;
 
                        }
                        cv->inuse++;
@@ -487,14 +487,14 @@ static struct chan *ipopen(struct chan *c, int omode)
                        }
                        if ((perm & (cv->perm >> 6)) != perm) {
                                if (strcmp(ATTACHER(c), cv->owner) != 0)
                        }
                        if ((perm & (cv->perm >> 6)) != perm) {
                                if (strcmp(ATTACHER(c), cv->owner) != 0)
-                                       error(Eperm);
+                                       error(EPERM, NULL);
                                if ((perm & cv->perm) != perm)
                                if ((perm & cv->perm) != perm)
-                                       error(Eperm);
+                                       error(EPERM, NULL);
 
                        }
 
                        if (cv->state != Announced)
 
                        }
 
                        if (cv->state != Announced)
-                               error("not announced");
+                               error(EFAIL, "not announced");
 
                        if (waserror()) {
                                closeconv(cv);
 
                        if (waserror()) {
                                closeconv(cv);
@@ -508,7 +508,7 @@ static struct chan *ipopen(struct chan *c, int omode)
                        while (nc == NULL) {
                                /* give up if we got a hangup */
                                if (qisclosed(cv->rq))
                        while (nc == NULL) {
                                /* give up if we got a hangup */
                                if (qisclosed(cv->rq))
-                                       error("listen hungup");
+                                       error(EFAIL, "listen hungup");
 
                                qlock(&cv->listenq);
                                if (waserror()) {
 
                                qlock(&cv->listenq);
                                if (waserror()) {
@@ -518,10 +518,8 @@ static struct chan *ipopen(struct chan *c, int omode)
                                /* we can peek at incall without grabbing the cv qlock.  if
                                 * anything is there, it'll remain there until we dequeue it.
                                 * no one else can, since we hold the listenq lock */
                                /* we can peek at incall without grabbing the cv qlock.  if
                                 * anything is there, it'll remain there until we dequeue it.
                                 * no one else can, since we hold the listenq lock */
-                               if (cv->nonblock && !cv->incall) {
-                                       set_errno(EAGAIN);
-                                       error("listen queue empty");
-                               }
+                               if (cv->nonblock && !cv->incall)
+                                       error(EAGAIN, "listen queue empty");
                                /* wait for a connect */
                                rendez_sleep(&cv->listenr, should_wake, cv);
 
                                /* wait for a connect */
                                rendez_sleep(&cv->listenr, should_wake, cv);
 
@@ -564,7 +562,7 @@ static int ipwstat(struct chan *c, uint8_t * dp, int n)
        f = ipfs[c->dev];
        switch (TYPE(c->qid)) {
                default:
        f = ipfs[c->dev];
        switch (TYPE(c->qid)) {
                default:
-                       error(Eperm);
+                       error(EPERM, NULL);
                        break;
                case Qctl:
                case Qdata:
                        break;
                case Qctl:
                case Qdata:
@@ -578,11 +576,11 @@ static int ipwstat(struct chan *c, uint8_t * dp, int n)
        }
        n = convM2D(dp, n, d, (char *)&d[1]);
        if (n == 0)
        }
        n = convM2D(dp, n, d, (char *)&d[1]);
        if (n == 0)
-               error(Eshortstat);
+               error(ENODATA, NULL);
        p = f->p[PROTO(c->qid)];
        cv = p->conv[CONV(c->qid)];
        if (!iseve() && strcmp(ATTACHER(c), cv->owner) != 0)
        p = f->p[PROTO(c->qid)];
        cv = p->conv[CONV(c->qid)];
        if (!iseve() && strcmp(ATTACHER(c), cv->owner) != 0)
-               error(Eperm);
+               error(EPERM, NULL);
        if (!emptystr(d->uid))
                kstrdup(&cv->owner, d->uid);
        if (d->mode != ~0UL)
        if (!emptystr(d->uid))
                kstrdup(&cv->owner, d->uid);
        if (d->mode != ~0UL)
@@ -722,7 +720,7 @@ static long ipread(struct chan *ch, void *a, long n, int64_t off)
        p = a;
        switch (TYPE(ch->qid)) {
                default:
        p = a;
        switch (TYPE(ch->qid)) {
                default:
-                       error(Eperm);
+                       error(EPERM, NULL);
                case Qtopdir:
                case Qprotodir:
                case Qconvdir:
                case Qtopdir:
                case Qprotodir:
                case Qconvdir:
@@ -795,7 +793,7 @@ static long ipread(struct chan *ch, void *a, long n, int64_t off)
                case Qstats:
                        x = f->p[PROTO(ch->qid)];
                        if (x->stats == NULL)
                case Qstats:
                        x = f->p[PROTO(ch->qid)];
                        if (x->stats == NULL)
-                               error("stats not implemented");
+                               error(EFAIL, "stats not implemented");
                        buf = kzmalloc(Statelen, 0);
                        (*x->stats) (x, buf, Statelen);
                        rv = readstr(offset, p, n, buf);
                        buf = kzmalloc(Statelen, 0);
                        (*x->stats) (x, buf, Statelen);
                        rv = readstr(offset, p, n, buf);
@@ -954,7 +952,7 @@ static char *setladdrport(struct conv *c, char *str, int announcing)
        /* one process can get all connections */
        if (announcing && strcmp(p, "*") == 0) {
                if (!iseve())
        /* one process can get all connections */
        if (announcing && strcmp(p, "*") == 0) {
                if (!iseve())
-                       error(Eperm);
+                       error(EPERM, NULL);
                return setluniqueport(c, 0);
        }
 
                return setluniqueport(c, 0);
        }
 
@@ -1034,14 +1032,14 @@ static void connectctlmsg(struct Proto *x, struct conv *c, struct cmdbuf *cb)
        char *p;
 
        if (c->state != 0)
        char *p;
 
        if (c->state != 0)
-               error(Econinuse);
+               error(EBUSY, NULL);
        c->state = Connecting;
        c->cerr[0] = '\0';
        if (x->connect == NULL)
        c->state = Connecting;
        c->cerr[0] = '\0';
        if (x->connect == NULL)
-               error("connect not supported");
+               error(EFAIL, "connect not supported");
        p = x->connect(c, cb->f, cb->nf);
        if (p != NULL)
        p = x->connect(c, cb->f, cb->nf);
        if (p != NULL)
-               error(p);
+               error(EFAIL, p);
 
        qunlock(&c->qlock);
        if (waserror()) {
 
        qunlock(&c->qlock);
        if (waserror()) {
@@ -1053,7 +1051,7 @@ static void connectctlmsg(struct Proto *x, struct conv *c, struct cmdbuf *cb)
        poperror();
 
        if (c->cerr[0] != '\0')
        poperror();
 
        if (c->cerr[0] != '\0')
-               error(c->cerr);
+               error(EFAIL, c->cerr);
 }
 
 /*
 }
 
 /*
@@ -1085,14 +1083,14 @@ static void announcectlmsg(struct Proto *x, struct conv *c, struct cmdbuf *cb)
        char *p;
 
        if (c->state != 0)
        char *p;
 
        if (c->state != 0)
-               error(Econinuse);
+               error(EBUSY, NULL);
        c->state = Announcing;
        c->cerr[0] = '\0';
        if (x->announce == NULL)
        c->state = Announcing;
        c->cerr[0] = '\0';
        if (x->announce == NULL)
-               error("announce not supported");
+               error(EFAIL, "announce not supported");
        p = x->announce(c, cb->f, cb->nf);
        if (p != NULL)
        p = x->announce(c, cb->f, cb->nf);
        if (p != NULL)
-               error(p);
+               error(EFAIL, p);
 
        qunlock(&c->qlock);
        if (waserror()) {
 
        qunlock(&c->qlock);
        if (waserror()) {
@@ -1104,7 +1102,7 @@ static void announcectlmsg(struct Proto *x, struct conv *c, struct cmdbuf *cb)
        poperror();
 
        if (c->cerr[0] != '\0')
        poperror();
 
        if (c->cerr[0] != '\0')
-               error(c->cerr);
+               error(EFAIL, c->cerr);
 }
 
 /*
 }
 
 /*
@@ -1136,7 +1134,7 @@ static void bindctlmsg(struct Proto *x, struct conv *c, struct cmdbuf *cb)
        else
                p = x->bind(c, cb->f, cb->nf);
        if (p != NULL)
        else
                p = x->bind(c, cb->f, cb->nf);
        if (p != NULL)
-               error(p);
+               error(EFAIL, p);
 }
 
 static void nonblockctlmsg(struct conv *c, struct cmdbuf *cb)
 }
 
 static void nonblockctlmsg(struct conv *c, struct cmdbuf *cb)
@@ -1151,8 +1149,7 @@ static void nonblockctlmsg(struct conv *c, struct cmdbuf *cb)
                goto err;
        return;
 err:
                goto err;
        return;
 err:
-       set_errno(EINVAL);
-       error("nonblock [on|off]");
+       error(EINVAL, "nonblock [on|off]");
 }
 
 static void tosctlmsg(struct conv *c, struct cmdbuf *cb)
 }
 
 static void tosctlmsg(struct conv *c, struct cmdbuf *cb)
@@ -1187,7 +1184,7 @@ static long ipwrite(struct chan *ch, void *v, long n, int64_t off)
 
        switch (TYPE(ch->qid)) {
                default:
 
        switch (TYPE(ch->qid)) {
                default:
-                       error(Eperm);
+                       error(EPERM, NULL);
                case Qdata:
                        x = f->p[PROTO(ch->qid)];
                        c = x->conv[CONV(ch->qid)];
                case Qdata:
                        x = f->p[PROTO(ch->qid)];
                        c = x->conv[CONV(ch->qid)];
@@ -1214,7 +1211,7 @@ static long ipwrite(struct chan *ch, void *v, long n, int64_t off)
                                nexterror();
                        }
                        if (cb->nf < 1)
                                nexterror();
                        }
                        if (cb->nf < 1)
-                               error("short control request");
+                               error(EFAIL, "short control request");
                        if (strcmp(cb->f[0], "connect") == 0)
                                connectctlmsg(x, c, cb);
                        else if (strcmp(cb->f[0], "announce") == 0)
                        if (strcmp(cb->f[0], "connect") == 0)
                                connectctlmsg(x, c, cb);
                        else if (strcmp(cb->f[0], "announce") == 0)
@@ -1231,32 +1228,32 @@ static long ipwrite(struct chan *ch, void *v, long n, int64_t off)
                                c->ignoreadvice = 1;
                        else if (strcmp(cb->f[0], "addmulti") == 0) {
                                if (cb->nf < 2)
                                c->ignoreadvice = 1;
                        else if (strcmp(cb->f[0], "addmulti") == 0) {
                                if (cb->nf < 2)
-                                       error("addmulti needs interface address");
+                                       error(EFAIL, "addmulti needs interface address");
                                if (cb->nf == 2) {
                                        if (!ipismulticast(c->raddr))
                                if (cb->nf == 2) {
                                        if (!ipismulticast(c->raddr))
-                                               error("addmulti for a non multicast address");
+                                               error(EFAIL, "addmulti for a non multicast address");
                                        parseip(ia, cb->f[1]);
                                        ipifcaddmulti(c, c->raddr, ia);
                                } else {
                                        parseip(ma, cb->f[2]);
                                        if (!ipismulticast(ma))
                                        parseip(ia, cb->f[1]);
                                        ipifcaddmulti(c, c->raddr, ia);
                                } else {
                                        parseip(ma, cb->f[2]);
                                        if (!ipismulticast(ma))
-                                               error("addmulti for a non multicast address");
+                                               error(EFAIL, "addmulti for a non multicast address");
                                        parseip(ia, cb->f[1]);
                                        ipifcaddmulti(c, ma, ia);
                                }
                        } else if (strcmp(cb->f[0], "remmulti") == 0) {
                                if (cb->nf < 2)
                                        parseip(ia, cb->f[1]);
                                        ipifcaddmulti(c, ma, ia);
                                }
                        } else if (strcmp(cb->f[0], "remmulti") == 0) {
                                if (cb->nf < 2)
-                                       error("remmulti needs interface address");
+                                       error(EFAIL, "remmulti needs interface address");
                                if (!ipismulticast(c->raddr))
                                if (!ipismulticast(c->raddr))
-                                       error("remmulti for a non multicast address");
+                                       error(EFAIL, "remmulti for a non multicast address");
                                parseip(ia, cb->f[1]);
                                ipifcremmulti(c, c->raddr, ia);
                        } else if (x->ctl != NULL) {
                                p = x->ctl(c, cb->f, cb->nf);
                                if (p != NULL)
                                parseip(ia, cb->f[1]);
                                ipifcremmulti(c, c->raddr, ia);
                        } else if (x->ctl != NULL) {
                                p = x->ctl(c, cb->f, cb->nf);
                                if (p != NULL)
-                                       error(p);
+                                       error(EFAIL, p);
                        } else
                        } else
-                               error("unknown control request");
+                               error(EFAIL, "unknown control request");
                        qunlock(&c->qlock);
                        kfree(cb);
                        poperror();
                        qunlock(&c->qlock);
                        kfree(cb);
                        poperror();
@@ -1480,7 +1477,7 @@ retry:
                if (c == NULL) {
                        c = kzmalloc(sizeof(struct conv), 0);
                        if (c == NULL)
                if (c == NULL) {
                        c = kzmalloc(sizeof(struct conv), 0);
                        if (c == NULL)
-                               error(Enomem);
+                               error(ENOMEM, NULL);
                        qlock_init(&c->qlock);
                        qlock_init(&c->listenq);
                        rendez_init(&c->cr);
                        qlock_init(&c->qlock);
                        qlock_init(&c->listenq);
                        rendez_init(&c->cr);
@@ -1495,7 +1492,7 @@ retry:
                                c->ptcl = kzmalloc(p->ptclsize, 0);
                                if (c->ptcl == NULL) {
                                        kfree(c);
                                c->ptcl = kzmalloc(p->ptclsize, 0);
                                if (c->ptcl == NULL) {
                                        kfree(c);
-                                       error(Enomem);
+                                       error(ENOMEM, NULL);
                                }
                        }
                        *pp = c;
                                }
                        }
                        *pp = c;
@@ -1633,9 +1630,9 @@ struct conv *Fsnewcall(struct conv *c, uint8_t * raddr, uint16_t rport,
 static long ndbwrite(struct Fs *f, char *a, uint32_t off, int n)
 {
        if (off > strlen(f->ndb))
 static long ndbwrite(struct Fs *f, char *a, uint32_t off, int n)
 {
        if (off > strlen(f->ndb))
-               error(Eio);
+               error(EIO, NULL);
        if (off + n >= sizeof(f->ndb) - 1)
        if (off + n >= sizeof(f->ndb) - 1)
-               error(Eio);
+               error(EIO, NULL);
        memmove(f->ndb + off, a, n);
        f->ndb[off + n] = 0;
        f->ndbvers++;
        memmove(f->ndb + off, a, n);
        f->ndb[off + n] = 0;
        f->ndbvers++;
index 8cda86c..a149497 100644 (file)
@@ -153,7 +153,7 @@ static void etherbind(struct Ipifc *ifc, int argc, char **argv)
        Etherrock *er;
 
        if (argc < 2)
        Etherrock *er;
 
        if (argc < 2)
-               error(Ebadarg);
+               error(EINVAL, NULL);
 
        addr = kmalloc(Maxpath, KMALLOC_WAIT);  //char addr[2*KNAMELEN];
        dir = kmalloc(Maxpath, KMALLOC_WAIT);   //char addr[2*KNAMELEN];
 
        addr = kmalloc(Maxpath, KMALLOC_WAIT);  //char addr[2*KNAMELEN];
        dir = kmalloc(Maxpath, KMALLOC_WAIT);   //char addr[2*KNAMELEN];
@@ -186,7 +186,7 @@ static void etherbind(struct Ipifc *ifc, int argc, char **argv)
        snprintf(addr, Maxpath, "%s!0x800", argv[2]);
        fd = kdial(addr, NULL, dir, &cfd);
        if (fd < 0)
        snprintf(addr, Maxpath, "%s!0x800", argv[2]);
        fd = kdial(addr, NULL, dir, &cfd);
        if (fd < 0)
-               error("dial 0x800 failed: %s", get_cur_errbuf());
+               error(EFAIL, "dial 0x800 failed: %s", get_cur_errbuf());
        mchan4 = commonfdtochan(fd, O_RDWR, 0, 1);
        cchan4 = commonfdtochan(cfd, O_RDWR, 0, 1);
        sysclose(fd);
        mchan4 = commonfdtochan(fd, O_RDWR, 0, 1);
        cchan4 = commonfdtochan(cfd, O_RDWR, 0, 1);
        sysclose(fd);
@@ -203,18 +203,18 @@ static void etherbind(struct Ipifc *ifc, int argc, char **argv)
        snprintf(addr, Maxpath, "%s/stats", dir);
        fd = sysopen(addr, O_READ);
        if (fd < 0)
        snprintf(addr, Maxpath, "%s/stats", dir);
        fd = sysopen(addr, O_READ);
        if (fd < 0)
-               error("can't open ether stats: %s", get_cur_errbuf());
+               error(EFAIL, "can't open ether stats: %s", get_cur_errbuf());
 
        buf = kzmalloc(512, 0);
        n = sysread(fd, buf, 511);
        sysclose(fd);
        if (n <= 0)
 
        buf = kzmalloc(512, 0);
        n = sysread(fd, buf, 511);
        sysclose(fd);
        if (n <= 0)
-               error(Eio);
+               error(EIO, NULL);
        buf[n] = 0;
 
        ptr = strstr(buf, "addr: ");
        if (!ptr)
        buf[n] = 0;
 
        ptr = strstr(buf, "addr: ");
        if (!ptr)
-               error(Eio);
+               error(EIO, NULL);
        ptr += 6;
        parsemac(ifc->mac, ptr, 6);
 
        ptr += 6;
        parsemac(ifc->mac, ptr, 6);
 
@@ -239,7 +239,7 @@ static void etherbind(struct Ipifc *ifc, int argc, char **argv)
        snprintf(addr, Maxpath, "%s!0x806", argv[2]);
        fd = kdial(addr, NULL, NULL, NULL);
        if (fd < 0)
        snprintf(addr, Maxpath, "%s!0x806", argv[2]);
        fd = kdial(addr, NULL, NULL, NULL);
        if (fd < 0)
-               error("dial 0x806 failed: %s", get_cur_errbuf());
+               error(EFAIL, "dial 0x806 failed: %s", get_cur_errbuf());
        achan = commonfdtochan(fd, O_RDWR, 0, 1);
        sysclose(fd);
 
        achan = commonfdtochan(fd, O_RDWR, 0, 1);
        sysclose(fd);
 
@@ -252,7 +252,7 @@ static void etherbind(struct Ipifc *ifc, int argc, char **argv)
        snprintf(addr, Maxpath, "%s!0x86DD", argv[2]);
        fd = kdial(addr, NULL, dir, &cfd);
        if (fd < 0)
        snprintf(addr, Maxpath, "%s!0x86DD", argv[2]);
        fd = kdial(addr, NULL, dir, &cfd);
        if (fd < 0)
-               error("dial 0x86DD failed: %s", get_cur_errbuf());
+               error(EFAIL, "dial 0x86DD failed: %s", get_cur_errbuf());
        mchan6 = commonfdtochan(fd, O_RDWR, 0, 1);
        cchan6 = commonfdtochan(cfd, O_RDWR, 0, 1);
        sysclose(fd);
        mchan6 = commonfdtochan(fd, O_RDWR, 0, 1);
        cchan6 = commonfdtochan(cfd, O_RDWR, 0, 1);
        sysclose(fd);
index 7fe5d72..a6d7d12 100644 (file)
@@ -206,7 +206,7 @@ static char *ipifcunbind(struct Ipifc *ifc)
        while (ifc->lifc) {
                err = ipifcremlifc(ifc, ifc->lifc);
                if (err)
        while (ifc->lifc) {
                err = ipifcremlifc(ifc, ifc->lifc);
                if (err)
-                       error(err);
+                       error(EFAIL, err);
        }
 
        ifc->m = NULL;
        }
 
        ifc->m = NULL;
@@ -684,7 +684,7 @@ static char *ipifcconnect(struct conv *c, char **argv, int argc)
        while (ifc->lifc) {
                err = ipifcremlifc(ifc, ifc->lifc);
                if (err)
        while (ifc->lifc) {
                err = ipifcremlifc(ifc, ifc->lifc);
                if (err)
-                       error(err);
+                       error(EFAIL, err);
        }
        wunlock(&ifc->rwlock);
        poperror();
        }
        wunlock(&ifc->rwlock);
        poperror();
index 27db012..fed2487 100644 (file)
@@ -794,7 +794,7 @@ long routewrite(struct Fs *f, struct chan *c, char *p, int n)
                nexterror();
        }
        if (cb->nf < 1)
                nexterror();
        }
        if (cb->nf < 1)
-               error("short control request");
+               error(EFAIL, "short control request");
 
        if (strcmp(cb->f[0], "flush") == 0) {
                tag = cb->f[1];
 
        if (strcmp(cb->f[0], "flush") == 0) {
                tag = cb->f[1];
@@ -812,7 +812,7 @@ long routewrite(struct Fs *f, struct chan *c, char *p, int n)
                        }
        } else if (strcmp(cb->f[0], "remove") == 0) {
                if (cb->nf < 3)
                        }
        } else if (strcmp(cb->f[0], "remove") == 0) {
                if (cb->nf < 3)
-                       error(Ebadarg);
+                       error(EINVAL, NULL);
                parseip(addr, cb->f[1]);
                parseipmask(mask, cb->f[2]);
                if (memcmp(addr, v4prefix, IPv4off) == 0)
                parseip(addr, cb->f[1]);
                parseipmask(mask, cb->f[2]);
                if (memcmp(addr, v4prefix, IPv4off) == 0)
@@ -821,7 +821,7 @@ long routewrite(struct Fs *f, struct chan *c, char *p, int n)
                        v6delroute(f, addr, mask, 1);
        } else if (strcmp(cb->f[0], "add") == 0) {
                if (cb->nf < 4)
                        v6delroute(f, addr, mask, 1);
        } else if (strcmp(cb->f[0], "add") == 0) {
                if (cb->nf < 4)
-                       error(Ebadarg);
+                       error(EINVAL, NULL);
                parseip(addr, cb->f[1]);
                parseipmask(mask, cb->f[2]);
                parseip(gate, cb->f[3]);
                parseip(addr, cb->f[1]);
                parseipmask(mask, cb->f[2]);
                parseip(gate, cb->f[3]);
@@ -837,7 +837,7 @@ long routewrite(struct Fs *f, struct chan *c, char *p, int n)
                        v6addroute(f, tag, addr, mask, gate, 0);
        } else if (strcmp(cb->f[0], "tag") == 0) {
                if (cb->nf < 2)
                        v6addroute(f, tag, addr, mask, gate, 0);
        } else if (strcmp(cb->f[0], "tag") == 0) {
                if (cb->nf < 2)
-                       error(Ebadarg);
+                       error(EINVAL, NULL);
 
                a = c->aux;
                na = newipaux(a->owner, cb->f[1]);
 
                a = c->aux;
                na = newipaux(a->owner, cb->f[1]);
index 79fbf1f..0ac853c 100644 (file)
@@ -204,7 +204,7 @@ struct chan *netifopen(struct ether *nif, struct chan *c, int omode)
        id = 0;
        if (c->qid.type & QTDIR) {
                if (omode & O_WRITE)
        id = 0;
        if (c->qid.type & QTDIR) {
                if (omode & O_WRITE)
-                       error(Eperm);
+                       error(EPERM, NULL);
        } else {
                switch (NETTYPE(c->qid.path)) {
                        case Ndataqid:
        } else {
                switch (NETTYPE(c->qid.path)) {
                        case Ndataqid:
@@ -218,14 +218,14 @@ struct chan *netifopen(struct ether *nif, struct chan *c, int omode)
                                break;
                        default:
                                if (omode & O_WRITE)
                                break;
                        default:
                                if (omode & O_WRITE)
-                                       error(Ebadarg);
+                                       error(EINVAL, NULL);
                }
                switch (NETTYPE(c->qid.path)) {
                        case Ndataqid:
                        case Nctlqid:
                                f = nif->f[id];
                                if (netown(f, current->user, omode & 7) < 0)
                }
                switch (NETTYPE(c->qid.path)) {
                        case Ndataqid:
                        case Nctlqid:
                                f = nif->f[id];
                                if (netown(f, current->user, omode & 7) < 0)
-                                       error(Eperm);
+                                       error(EPERM, NULL);
                                break;
                }
        }
                                break;
                }
        }
@@ -310,7 +310,7 @@ netifread(struct ether *nif, struct chan *c, void *a, long n,
                case Nifstatqid:
                        return 0;
        }
                case Nifstatqid:
                        return 0;
        }
-       error(Ebadarg);
+       error(EINVAL, NULL);
        return -1;      /* not reached */
 }
 
        return -1;      /* not reached */
 }
 
@@ -356,7 +356,7 @@ long netifwrite(struct ether *nif, struct chan *c, void *a, long n)
        uint8_t binaddr[Nmaxaddr];
 
        if (NETTYPE(c->qid.path) != Nctlqid)
        uint8_t binaddr[Nmaxaddr];
 
        if (NETTYPE(c->qid.path) != Nctlqid)
-               error(Eperm);
+               error(EPERM, NULL);
 
        if (n >= sizeof(buf))
                n = sizeof(buf) - 1;
 
        if (n >= sizeof(buf))
                n = sizeof(buf) - 1;
@@ -373,7 +373,7 @@ long netifwrite(struct ether *nif, struct chan *c, void *a, long n)
        if ((p = matchtoken(buf, "connect")) != 0) {
                type = strtol(p, 0, 0); /* allows any base, though usually hex */
                if (typeinuse(nif, type))
        if ((p = matchtoken(buf, "connect")) != 0) {
                type = strtol(p, 0, 0); /* allows any base, though usually hex */
                if (typeinuse(nif, type))
-                       error(Einuse);
+                       error(EBUSY, NULL);
                f->type = type;
                if (f->type < 0)
                        nif->all++;
                f->type = type;
                if (f->type < 0)
                        nif->all++;
@@ -401,16 +401,16 @@ long netifwrite(struct ether *nif, struct chan *c, void *a, long n)
                f->headersonly = 1;
        } else if ((p = matchtoken(buf, "addmulti")) != 0) {
                if (parseaddr(binaddr, p, nif->alen) < 0)
                f->headersonly = 1;
        } else if ((p = matchtoken(buf, "addmulti")) != 0) {
                if (parseaddr(binaddr, p, nif->alen) < 0)
-                       error("bad address");
+                       error(EFAIL, "bad address");
                p = netmulti(nif, f, binaddr, 1);
                if (p)
                p = netmulti(nif, f, binaddr, 1);
                if (p)
-                       error(p);
+                       error(EFAIL, p);
        } else if ((p = matchtoken(buf, "remmulti")) != 0) {
                if (parseaddr(binaddr, p, nif->alen) < 0)
        } else if ((p = matchtoken(buf, "remmulti")) != 0) {
                if (parseaddr(binaddr, p, nif->alen) < 0)
-                       error("bad address");
+                       error(EFAIL, "bad address");
                p = netmulti(nif, f, binaddr, 0);
                if (p)
                p = netmulti(nif, f, binaddr, 0);
                if (p)
-                       error(p);
+                       error(EFAIL, p);
        } else
                n = -1;
        qunlock(&nif->qlock);
        } else
                n = -1;
        qunlock(&nif->qlock);
@@ -427,17 +427,17 @@ int netifwstat(struct ether *nif, struct chan *c, uint8_t * db, int n)
        f = nif->f[NETID(c->qid.path)];
        if (f == 0) {
                set_errno(ENOENT);
        f = nif->f[NETID(c->qid.path)];
        if (f == 0) {
                set_errno(ENOENT);
-               error(Enonexist);
+               error(ENODEV, NULL);
        }
 
        if (netown(f, current->user, O_WRITE) < 0)
        }
 
        if (netown(f, current->user, O_WRITE) < 0)
-               error(Eperm);
+               error(EPERM, NULL);
 
        dir = kzmalloc(sizeof(struct dir) + n, 0);
        m = convM2D(db, n, &dir[0], (char *)&dir[1]);
        if (m == 0) {
                kfree(dir);
 
        dir = kzmalloc(sizeof(struct dir) + n, 0);
        m = convM2D(db, n, &dir[0], (char *)&dir[1]);
        if (m == 0) {
                kfree(dir);
-               error(Eshortstat);
+               error(ENODATA, NULL);
        }
        if (!emptystr(dir[0].uid))
                strncpy(f->owner, dir[0].uid, KNAMELEN);
        }
        if (!emptystr(dir[0].uid))
                strncpy(f->owner, dir[0].uid, KNAMELEN);
@@ -551,7 +551,7 @@ static int openfile(struct ether *nif, int id)
        if (id >= 0) {
                f = nif->f[id];
                if (f == 0)
        if (id >= 0) {
                f = nif->f[id];
                if (f == 0)
-                       error(Enodev);
+                       error(ENODEV, NULL);
                qlock(&f->qlock);
                qreopen(f->in);
                f->inuse++;
                qlock(&f->qlock);
                qreopen(f->in);
                f->inuse++;
@@ -595,7 +595,7 @@ static int openfile(struct ether *nif, int id)
                poperror();
                return fp - nif->f;
        }
                poperror();
                return fp - nif->f;
        }
-       error(Enodev);
+       error(ENODEV, NULL);
        return -1;      /* not reached */
 }
 
        return -1;      /* not reached */
 }
 
index 6ae53f1..f014199 100644 (file)
@@ -60,8 +60,6 @@ static Netlogflag flags[] = {
        {NULL, 0,},
 };
 
        {NULL, 0,},
 };
 
-char Ebadnetctl[] = "too few arguments for netlog control message";
-
 enum {
        CMset,
        CMclear,
 enum {
        CMset,
        CMclear,
@@ -185,7 +183,7 @@ void netlogctl(struct Fs *f, char *s, int n)
        }
 
        if (cb->nf < 2)
        }
 
        if (cb->nf < 2)
-               error(Ebadnetctl);
+               error(EINVAL, NULL);
 
        ct = lookupcmd(cb, routecmd, ARRAY_SIZE(routecmd));
 
 
        ct = lookupcmd(cb, routecmd, ARRAY_SIZE(routecmd));
 
index 88e7244..4a175e8 100644 (file)
@@ -16,7 +16,7 @@
 static void
 nullbind(struct Ipifc *unused_ipifc, int unused_int, char **unused_char_pp_t)
 {
 static void
 nullbind(struct Ipifc *unused_ipifc, int unused_int, char **unused_char_pp_t)
 {
-       error("cannot bind null device");
+       error(EFAIL, "cannot bind null device");
 }
 
 static void nullunbind(struct Ipifc *unused_ipifc)
 }
 
 static void nullunbind(struct Ipifc *unused_ipifc)
@@ -27,7 +27,7 @@ static void
 nullbwrite(struct Ipifc *unused_ipifc, struct block *b, int unused_int,
                   uint8_t * unused_uint8_p_t)
 {
 nullbwrite(struct Ipifc *unused_ipifc, struct block *b, int unused_int,
                   uint8_t * unused_uint8_p_t)
 {
-       error("nullbwrite");
+       error(EFAIL, "nullbwrite");
 }
 
 struct medium nullmedium = {
 }
 
 struct medium nullmedium = {
index 199c061..fe2cc85 100644 (file)
@@ -373,7 +373,7 @@ int cmount(struct chan *new, struct chan *old, int flag, char *spec)
        struct mount *nm, *f, *um, **h;
 
        if (QTDIR & (old->qid.type ^ new->qid.type))
        struct mount *nm, *f, *um, **h;
 
        if (QTDIR & (old->qid.type ^ new->qid.type))
-               error(Emount);
+               error(EINVAL, NULL);
 
        if (old->umh)
                printd("cmount old extra umh\n");
 
        if (old->umh)
                printd("cmount old extra umh\n");
@@ -381,7 +381,7 @@ int cmount(struct chan *new, struct chan *old, int flag, char *spec)
        order = flag & MORDER;
 
        if ((old->qid.type & QTDIR) == 0 && order != MREPL)
        order = flag & MORDER;
 
        if ((old->qid.type & QTDIR) == 0 && order != MREPL)
-               error(Emount);
+               error(EINVAL, NULL);
 
        mh = new->umh;
 
 
        mh = new->umh;
 
@@ -403,7 +403,7 @@ int cmount(struct chan *new, struct chan *old, int flag, char *spec)
         */
        if ((flag & MCREATE) && mh && mh->mount
                && (mh->mount->next || !(mh->mount->mflag & MCREATE)))
         */
        if ((flag & MCREATE) && mh && mh->mount
                && (mh->mount->next || !(mh->mount->mflag & MCREATE)))
-               error(Emount);
+               error(EEXIST, NULL);
 
        pg = current->pgrp;
        wlock(&pg->ns);
 
        pg = current->pgrp;
        wlock(&pg->ns);
@@ -506,7 +506,7 @@ void cunmount(struct chan *mnt, struct chan *mounted)
 
        if (m == 0) {
                wunlock(&pg->ns);
 
        if (m == 0) {
                wunlock(&pg->ns);
-               error(Eunmount);
+               error(ENOENT, NULL);
        }
 
        wlock(&m->lock);
        }
 
        wlock(&m->lock);
@@ -545,7 +545,7 @@ void cunmount(struct chan *mnt, struct chan *mounted)
        }
        wunlock(&m->lock);
        wunlock(&pg->ns);
        }
        wunlock(&m->lock);
        wunlock(&pg->ns);
-       error(Eunion);
+       error(ENOENT, NULL);
 }
 
 struct chan *cclone(struct chan *c)
 }
 
 struct chan *cclone(struct chan *c)
@@ -555,7 +555,7 @@ struct chan *cclone(struct chan *c)
 
        wq = devtab[c->type].walk(c, NULL, NULL, 0);
        if (wq == NULL)
 
        wq = devtab[c->type].walk(c, NULL, NULL, 0);
        if (wq == NULL)
-               error("clone failed");
+               error(EFAIL, "clone failed");
        nc = wq->clone;
        kfree(wq);
        nc->name = c->name;
        nc = wq->clone;
        kfree(wq);
        nc->name = c->name;
@@ -838,7 +838,7 @@ struct chan *createdir(struct chan *c, struct mhead *m)
                        return nc;
                }
        }
                        return nc;
                }
        }
-       error(Enocreate);
+       error(EPERM, NULL);
        poperror();
        return 0;
 }
        poperror();
        return 0;
 }
@@ -1006,21 +1006,21 @@ static struct chan *__namec_from(struct chan *c, char *aname, int amode,
 
                /* don't try to walk the last path element just yet. */
                if (e.ARRAY_SIZEs == 0)
 
                /* don't try to walk the last path element just yet. */
                if (e.ARRAY_SIZEs == 0)
-                       error(Eexist);
+                       error(EEXIST, NULL);
                e.ARRAY_SIZEs--;
        }
 
        if (walk(&c, e.elems, e.ARRAY_SIZEs, can_mount, &npath) < 0) {
                if (npath < 0 || npath > e.ARRAY_SIZEs) {
                        printd("namec %s walk error npath=%d\n", aname, npath);
                e.ARRAY_SIZEs--;
        }
 
        if (walk(&c, e.elems, e.ARRAY_SIZEs, can_mount, &npath) < 0) {
                if (npath < 0 || npath > e.ARRAY_SIZEs) {
                        printd("namec %s walk error npath=%d\n", aname, npath);
-                       error("walk failed");
+                       error(EFAIL, "walk failed");
                }
 NameError:
                if (current_errstr()[0]) {
                        /* errstr is set, we'll just stick with it and error out */
                        longjmp(&get_cur_errbuf()->jmpbuf, 1);
                } else {
                }
 NameError:
                if (current_errstr()[0]) {
                        /* errstr is set, we'll just stick with it and error out */
                        longjmp(&get_cur_errbuf()->jmpbuf, 1);
                } else {
-                       error("Name to chan lookup failed");
+                       error(EFAIL, "Name to chan lookup failed");
                }
                /* brho: skipping the namec custom error string business, since it hides
                 * the underlying failure.  implement this if you want the old stuff. */
                }
                /* brho: skipping the namec custom error string business, since it hides
                 * the underlying failure.  implement this if you want the old stuff. */
@@ -1047,7 +1047,7 @@ NameError:
 
        if ((amode == Aopen) && (omode & O_EXEC) && (c->qid.type & QTDIR)) {
                npath = e.ARRAY_SIZEs;
 
        if ((amode == Aopen) && (omode & O_EXEC) && (c->qid.type & QTDIR)) {
                npath = e.ARRAY_SIZEs;
-               error("cannot exec directory");
+               error(EFAIL, "cannot exec directory");
        }
 
        switch (amode) {
        }
 
        switch (amode) {
@@ -1112,7 +1112,7 @@ Open:
                                         * probably saving mode directly, without passing it through
                                         * openmode. */
                                        if (c->mode & O_TRUNC)
                                         * probably saving mode directly, without passing it through
                                         * openmode. */
                                        if (c->mode & O_TRUNC)
-                                               error("Device %s open failed to clear O_TRUNC",
+                                               error(EFAIL, "Device %s open failed to clear O_TRUNC",
                                                      devtab[c->type].name);
                                        break;
                        }
                                                      devtab[c->type].name);
                                        break;
                        }
@@ -1124,7 +1124,7 @@ Open:
                         * so one may mount on / or . and see the effect.
                         */
                        if (!(c->qid.type & QTDIR))
                         * so one may mount on / or . and see the effect.
                         */
                        if (!(c->qid.type & QTDIR))
-                               error(Enotdir);
+                               error(ENOTDIR, NULL);
                        break;
 
                case Amount:
                        break;
 
                case Amount:
@@ -1151,7 +1151,7 @@ Open:
                        e.ARRAY_SIZEs++;
                        if (walk(&c, e.elems + e.ARRAY_SIZEs - 1, 1, can_mount, NULL) == 0) {
                                if (omode & O_EXCL)
                        e.ARRAY_SIZEs++;
                        if (walk(&c, e.elems + e.ARRAY_SIZEs - 1, 1, can_mount, NULL) == 0) {
                                if (omode & O_EXCL)
-                                       error(Eexist);
+                                       error(EEXIST, NULL);
                                omode |= O_TRUNC;
                                goto Open;
                        }
                                omode |= O_TRUNC;
                                goto Open;
                        }
@@ -1250,7 +1250,8 @@ Open:
                        /* note: we depend that walk does not error */
                        if (walk(&c, e.elems + e.ARRAY_SIZEs - 1, 1, can_mount, NULL) < 0) {
                                set_errno(saved_errno);
                        /* note: we depend that walk does not error */
                        if (walk(&c, e.elems + e.ARRAY_SIZEs - 1, 1, can_mount, NULL) < 0) {
                                set_errno(saved_errno);
-                               error(tmperrbuf);       /* report the error we had originally */
+                               /* Report the error we had originally */
+                               error(EFAIL, tmperrbuf);
                        }
                        strncpy(current_errstr(), tmperrbuf, MAX_ERRSTR_LEN);
                        omode |= O_TRUNC;
                        }
                        strncpy(current_errstr(), tmperrbuf, MAX_ERRSTR_LEN);
                        omode |= O_TRUNC;
@@ -1282,7 +1283,7 @@ struct chan *namec(char *name, int amode, int omode, uint32_t perm)
        int n, devtype;
 
        if (name[0] == '\0')
        int n, devtype;
 
        if (name[0] == '\0')
-               error("empty file name");
+               error(EFAIL, "empty file name");
        validname(name, 1);
        /*
         * Find the starting off point (the current slash, the root of
        validname(name, 1);
        /*
         * Find the starting off point (the current slash, the root of
@@ -1305,7 +1306,7 @@ struct chan *namec(char *name, int amode, int omode, uint32_t perm)
                        name++; /* drop the # */
                        while ((*name != '\0') && (*name != '/')) {
                                if (n >= GENBUF_SZ - 1)
                        name++; /* drop the # */
                        while ((*name != '\0') && (*name != '/')) {
                                if (n >= GENBUF_SZ - 1)
-                                       error(Efilename);
+                                       error(ENAMETOOLONG, NULL);
                                devname[n++] = *name++;
                        }
                        devname[n] = '\0';
                                devname[n++] = *name++;
                        }
                        devname[n] = '\0';
@@ -1319,7 +1320,7 @@ struct chan *namec(char *name, int amode, int omode, uint32_t perm)
                                devspec = &devname[n];
                        }
                        if (!strcmp(devname, "mnt"))
                                devspec = &devname[n];
                        }
                        if (!strcmp(devname, "mnt"))
-                               error(Enoattach);
+                               error(EINVAL, NULL);
                        /* TODO: deal with this "nodevs" business. */
                        #if 0
                        /*
                        /* TODO: deal with this "nodevs" business. */
                        #if 0
                        /*
@@ -1335,11 +1336,11 @@ struct chan *namec(char *name, int amode, int omode, uint32_t perm)
                                ((strchr("|esDa", get_cur_genbuf()[1]) == NULL)
                                 || (get_cur_genbuf()[1] == 's' // || r == 's'
                                         && get_cur_genbuf()[n] != '\0')))
                                ((strchr("|esDa", get_cur_genbuf()[1]) == NULL)
                                 || (get_cur_genbuf()[1] == 's' // || r == 's'
                                         && get_cur_genbuf()[n] != '\0')))
-                               error(Enoattach);
+                               error(EINVAL, NULL);
                        #endif
                        devtype = devno(devname, 1);
                        if (devtype == -1)
                        #endif
                        devtype = devno(devname, 1);
                        if (devtype == -1)
-                               error("Unknown #device %s (spec %s)", devname, devspec);
+                               error(EFAIL, "Unknown #device %s (spec %s)", devname, devspec);
                        c = devtab[devtype].attach(devspec);
                        break;
                default:
                        c = devtab[devtype].attach(devspec);
                        break;
                default:
@@ -1359,7 +1360,7 @@ struct chan *namec_from(struct chan *c, char *name, int amode, int omode,
        if (name[0] == '\0') {
                /* Our responsibility to cclose 'c' on our error */
                cclose(c);
        if (name[0] == '\0') {
                /* Our responsibility to cclose 'c' on our error */
                cclose(c);
-               error("empty file name");
+               error(EFAIL, "empty file name");
        }
        validname(name, 1);
        return __namec_from(c, name, amode, omode, perm, TRUE);
        }
        validname(name, 1);
        return __namec_from(c, name, amode, omode, perm, TRUE);
@@ -1404,7 +1405,7 @@ void validname(char *aname, int slashok)
        ename = memchr(name, 0, (1 << 16));
 
        if (ename == NULL || ename - name >= (1 << 16))
        ename = memchr(name, 0, (1 << 16));
 
        if (ename == NULL || ename - name >= (1 << 16))
-               error("name too long");
+               error(EFAIL, "name too long");
 
        while (*name) {
                /* all characters above '~' are ok */
 
        while (*name) {
                /* all characters above '~' are ok */
@@ -1414,11 +1415,11 @@ void validname(char *aname, int slashok)
                        name += chartorune(&r, name);
 #endif
                if (c >= 0x7f) {
                        name += chartorune(&r, name);
 #endif
                if (c >= 0x7f) {
-                       error("Akaros doesn't do UTF-8");
+                       error(EFAIL, "Akaros doesn't do UTF-8");
                } else {
                        if (isfrog[c])
                                if (!slashok || c != '/') {
                } else {
                        if (isfrog[c])
                                if (!slashok || c != '/') {
-                                       error("%s: %s (%p), at char %c", Ebadchar, aname, aname, c);
+                                       error(EFAIL, "%s: %s (%p), at char %c", Ebadchar, aname, aname, c);
                                }
                        name++;
                }
                                }
                        name++;
                }
@@ -1429,7 +1430,7 @@ void isdir(struct chan *c)
 {
        if (c->qid.type & QTDIR)
                return;
 {
        if (c->qid.type & QTDIR)
                return;
-       error(Enotdir);
+       error(ENOTDIR, NULL);
 }
 
 /*
 }
 
 /*
index 604c65f..f1a4f53 100644 (file)
@@ -185,7 +185,7 @@ struct walkqid *devwalk(struct chan *c,
        for (j = 0; j < nname; j++) {
                if (!(nc->qid.type & QTDIR)) {
                        if (j == 0)
        for (j = 0; j < nname; j++) {
                if (!(nc->qid.type & QTDIR)) {
                        if (j == 0)
-                               error(Enotdir);
+                               error(ENOTDIR, NULL);
                        goto Done;
                }
                n = name[j];
                        goto Done;
                }
                n = name[j];
@@ -218,7 +218,7 @@ Accept:
 Notfound:
                                        set_errno(ENOENT);
                                        if (j == 0)
 Notfound:
                                        set_errno(ENOENT);
                                        if (j == 0)
-                                               error(Enonexist);
+                                               error(ENODEV, NULL);
                                        set_errstr(Enonexist);
                                        goto Done;
                                case 0:
                                        set_errstr(Enonexist);
                                        goto Done;
                                case 0:
@@ -279,13 +279,13 @@ devstat(struct chan *c, uint8_t * db, int n,
                                        devdir(c, c->qid, elem, 0, eve, DMDIR | 0555, &dir);
                                        n = convD2M(&dir, db, n);
                                        if (n == 0)
                                        devdir(c, c->qid, elem, 0, eve, DMDIR | 0555, &dir);
                                        n = convD2M(&dir, db, n);
                                        if (n == 0)
-                                               error(Ebadarg);
+                                               error(EINVAL, NULL);
                                        return n;
                                }
                                printd("DEVSTAT fails:%s %llu\n", devtab[c->type].name,
                                           c->qid.path);
                                set_errno(ENOENT);
                                        return n;
                                }
                                printd("DEVSTAT fails:%s %llu\n", devtab[c->type].name,
                                           c->qid.path);
                                set_errno(ENOENT);
-                               error(Enonexist);
+                               error(ENODEV, NULL);
                        case 0:
                                printd("DEVSTAT got 0\n");
                                break;
                        case 0:
                                printd("DEVSTAT got 0\n");
                                break;
@@ -297,7 +297,7 @@ devstat(struct chan *c, uint8_t * db, int n,
                                                dir.mode |= DMMOUNT;
                                        n = convD2M(&dir, db, n);
                                        if (n == 0)
                                                dir.mode |= DMMOUNT;
                                        n = convD2M(&dir, db, n);
                                        if (n == 0)
-                                               error(Ebadarg);
+                                               error(EINVAL, NULL);
                                        return n;
                                }
                                break;
                                        return n;
                                }
                                break;
@@ -330,7 +330,7 @@ devdirread(struct chan *c, char *d, long n,
                                dsz = convD2M(&dir[0], (uint8_t *) d, n - m);
                                if (dsz <= BIT16SZ) {   /* <= not < because this isn't stat; read is stuck */
                                        if (m == 0)
                                dsz = convD2M(&dir[0], (uint8_t *) d, n - m);
                                if (dsz <= BIT16SZ) {   /* <= not < because this isn't stat; read is stuck */
                                        if (m == 0)
-                                               error(Eshort);
+                                               error(ENODATA, NULL);
                                        return m;
                                }
                                m += dsz;
                                        return m;
                                }
                                m += dsz;
@@ -343,7 +343,7 @@ devdirread(struct chan *c, char *d, long n,
 }
 
 /*
 }
 
 /*
- * error(Eperm) if open permission not granted for up->env->user.
+ * error(EPERM, NULL) if open permission not granted for up->env->user.
  */
 void devpermcheck(char *fileuid, uint32_t perm, int omode)
 {
  */
 void devpermcheck(char *fileuid, uint32_t perm, int omode)
 {
@@ -361,7 +361,7 @@ void devpermcheck(char *fileuid, uint32_t perm, int omode)
         * seem to handle O_EXEC being mixed readable or writable. */
        rwx = omode_to_rwx(omode);
        if ((rwx & perm) != rwx)
         * seem to handle O_EXEC being mixed readable or writable. */
        rwx = omode_to_rwx(omode);
        if ((rwx & perm) != rwx)
-               error("%s: devpermcheck(%s, 0%o, 0%o) failed", Eperm, fileuid, perm,
+               error(EFAIL, "%s: devpermcheck(%s, 0%o, 0%o) failed", Eperm, fileuid, perm,
                          omode);
 }
 
                          omode);
 }
 
@@ -389,7 +389,7 @@ struct chan *devopen(struct chan *c, int omode, struct dirtab *tab, int ntab,
 Return:
        c->offset = 0;
        if ((c->qid.type & QTDIR) && (omode & O_WRITE))
 Return:
        c->offset = 0;
        if ((c->qid.type & QTDIR) && (omode & O_WRITE))
-               error("Tried opening dir with non-read-only mode %o", omode);
+               error(EFAIL, "Tried opening dir with non-read-only mode %o", omode);
        c->mode = openmode(omode);
        c->flag |= COPEN;
        return c;
        c->mode = openmode(omode);
        c->flag |= COPEN;
        return c;
@@ -398,7 +398,7 @@ Return:
 void
 devcreate(struct chan *c, char *unused_char_p_t, int unused_int, uint32_t u)
 {
 void
 devcreate(struct chan *c, char *unused_char_p_t, int unused_int, uint32_t u)
 {
-       error(Eperm);
+       error(EPERM, NULL);
 }
 
 struct block *devbread(struct chan *c, long n, uint32_t offset)
 }
 
 struct block *devbread(struct chan *c, long n, uint32_t offset)
@@ -408,7 +408,7 @@ struct block *devbread(struct chan *c, long n, uint32_t offset)
 
        bp = allocb(n);
        if (bp == 0)
 
        bp = allocb(n);
        if (bp == 0)
-               error(Enomem);
+               error(ENOMEM, NULL);
        if (waserror()) {
                freeb(bp);
                nexterror();
        if (waserror()) {
                freeb(bp);
                nexterror();
@@ -436,24 +436,24 @@ long devbwrite(struct chan *c, struct block *bp, uint32_t offset)
 
 void devremove(struct chan *c)
 {
 
 void devremove(struct chan *c)
 {
-       error(Eperm);
+       error(EPERM, NULL);
 }
 
 int devwstat(struct chan *c, uint8_t * unused_uint8_p_t, int i)
 {
 }
 
 int devwstat(struct chan *c, uint8_t * unused_uint8_p_t, int i)
 {
-       error(Eperm);
+       error(EPERM, NULL);
        return 0;
 }
 
 void devpower(int i)
 {
        return 0;
 }
 
 void devpower(int i)
 {
-       error(Eperm);
+       error(EPERM, NULL);
 }
 
 #if 0
 int devconfig(int unused_int, char *c, DevConf *)
 {
 }
 
 #if 0
 int devconfig(int unused_int, char *c, DevConf *)
 {
-       error(Eperm);
+       error(EPERM, NULL);
        return 0;
 }
 #endif
        return 0;
 }
 #endif
@@ -472,7 +472,7 @@ void validwstatname(char *name)
 {
        validname(name, 0);
        if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
 {
        validname(name, 0);
        if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
-               error(Efilename);
+               error(EINVAL, NULL);
 }
 
 struct dev *devbyname(char *name)
 }
 
 struct dev *devbyname(char *name)
index 7b0acd7..9a0412b 100644 (file)
@@ -56,7 +56,7 @@ struct dev *devtabget(const char *name, int user)
 
        printk("devtabget FAILED %s\n", name);
        set_errno(ENOENT);
 
        printk("devtabget FAILED %s\n", name);
        set_errno(ENOENT);
-       error(Enonexist);
+       error(ENODEV, NULL);
 }
 
 long devtabread(struct chan *c, void *buf, long n, int64_t off)
 }
 
 long devtabread(struct chan *c, void *buf, long n, int64_t off)
@@ -69,7 +69,7 @@ long devtabread(struct chan *c, void *buf, long n, int64_t off)
 
        alloc = kzmalloc(READSTR, KMALLOC_WAIT);
        if (alloc == NULL)
 
        alloc = kzmalloc(READSTR, KMALLOC_WAIT);
        if (alloc == NULL)
-               error(Enomem);
+               error(ENOMEM, NULL);
 
        p = alloc;
        e = p + READSTR;
 
        p = alloc;
        e = p + READSTR;
index 0e4128e..d00d3db 100644 (file)
@@ -91,7 +91,7 @@ void cmderror(struct cmdbuf *cb, char *s)
                p = seprintf(p, e, "%s", cb->f[i]);
        }
        strncpy(p, "\"", sizeof(p));
                p = seprintf(p, e, "%s", cb->f[i]);
        }
        strncpy(p, "\"", sizeof(p));
-       error(get_cur_genbuf());
+       error(EFAIL, get_cur_genbuf());
 }
 
 void debugcmd(struct cmdbuf *cb)
 }
 
 void debugcmd(struct cmdbuf *cb)
@@ -111,7 +111,7 @@ struct cmdtab *lookupcmd(struct cmdbuf *cb, struct cmdtab *ctab, int nctab)
        struct cmdtab *ct;
 
        if (cb->nf == 0)
        struct cmdtab *ct;
 
        if (cb->nf == 0)
-               error("empty control message");
+               error(EFAIL, "empty control message");
 
        for (ct = ctab, i = 0; i < nctab; i++, ct++) {
                if (strcmp(ct->cmd, "*") != 0)  /* wildcard always matches */
 
        for (ct = ctab, i = 0; i < nctab; i++, ct++) {
                if (strcmp(ct->cmd, "*") != 0)  /* wildcard always matches */
index 69922e9..daa1051 100644 (file)
@@ -110,7 +110,7 @@ void pgrpcpy(struct pgrp *to, struct pgrp *from)
                        }
                        mh = newmhead(f->from);
                        if (!mh)
                        }
                        mh = newmhead(f->from);
                        if (!mh)
-                               error(Enomem);
+                               error(ENOMEM, NULL);
                        *l = mh;
                        l = &mh->hash;
                        link = &mh->mount;
                        *l = mh;
                        l = &mh->hash;
                        link = &mh->mount;
index 5e827d8..6f9aee3 100644 (file)
@@ -1269,11 +1269,11 @@ static bool qwait(struct queue *q)
                if (q->state & Qclosed) {
                        if (++q->eof > 3) {
                                spin_unlock_irqsave(&q->lock);
                if (q->state & Qclosed) {
                        if (++q->eof > 3) {
                                spin_unlock_irqsave(&q->lock);
-                               error("multiple reads on a closed queue");
+                               error(EFAIL, "multiple reads on a closed queue");
                        }
                        if (*q->err && strcmp(q->err, Ehungup) != 0) {
                                spin_unlock_irqsave(&q->lock);
                        }
                        if (*q->err && strcmp(q->err, Ehungup) != 0) {
              &