From 039ea723f4f398ef43a33902d9191cf8f20e0bf8 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 21 Apr 2002 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2002-04-21 --- boot/bootauth.c | 2 +- port/devproc.c | 20 +++++++++++++++----- port/qlock.c | 17 ++++++----------- port/sysproc.c | 1 - port/taslock.c | 3 ++- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/boot/bootauth.c b/boot/bootauth.c index 57663a97270043aa06ac3e99726b8bd124cb8912..e7bd1b683b163d573c21b3b0f4431d089b8e1289 100644 --- a/boot/bootauth.c +++ b/boot/bootauth.c @@ -13,7 +13,7 @@ authentication(int cpuflag) char *argv[16], **av; int ac; - if(access("/factotum", 0) < 0){ + if(access("/factotum", 05) < 0){ glenda(); return; } diff --git a/port/devproc.c b/port/devproc.c index ea58901ca7a0bc25fda7d987006d91f48b01cf8d..a0e8e32b20a1c8ef6d0148e6da9aa00448e262ec 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -418,7 +418,14 @@ procfds(Proc *p, char *va, int count, long offset) { Fgrp *f; Chan *c; + char buf[256]; int n, i, w, ww; + char *a; + + /* print to buf to avoid holding fgrp lock while writing to user space */ + if(count > sizeof buf) + count = sizeof buf; + a = buf; qlock(&p->debug); f = p->fgrp; @@ -433,9 +440,9 @@ procfds(Proc *p, char *va, int count, long offset) nexterror(); } - n = readstr(0, va, count, p->dot->name->s); - n += snprint(va+n, count-n, "\n"); - offset = procoffset(offset, va, &n); + n = readstr(0, a, count, p->dot->name->s); + n += snprint(a+n, count-n, "\n"); + offset = procoffset(offset, a, &n); /* compute width of qid.path */ w = 0; for(i = 0; i <= f->maxfd; i++) { @@ -450,13 +457,16 @@ procfds(Proc *p, char *va, int count, long offset) c = f->fd[i]; if(c == nil) continue; - n += procfdprint(c, i, w, va+n, count-n); - offset = procoffset(offset, va, &n); + n += procfdprint(c, i, w, a+n, count-n); + offset = procoffset(offset, a, &n); } unlock(f); qunlock(&p->debug); poperror(); + /* copy result to user space, now that locks are released */ + memmove(va, buf, n); + return n; } diff --git a/port/qlock.c b/port/qlock.c index 70ee44147fbdbd1db3aac9087374b9b0a9c90f3d..1bc6be651a38b26d39be82b5cae123ad96526d2e 100644 --- a/port/qlock.c +++ b/port/qlock.c @@ -13,7 +13,6 @@ struct { ulong qlockq; } rwstats; -int shutup=1; /* RSC: you can take this out, it's just to silence a print in a loop on the dist floppy */ void qlock(QLock *q) { @@ -21,14 +20,10 @@ qlock(QLock *q) if(up == 0) panic("qlock"); - if(m->ilockdepth != 0 && !shutup){ + if(m->ilockdepth != 0) print("qlock: %lux: ilockdepth %d", getcallerpc(&q), m->ilockdepth); - shutup = 1; - } - if(up->nlocks && !shutup){ - print("qlock: %lux: nlocks %d", getcallerpc(&q), up->nlocks); - shutup = 1; - } + if(up->nlocks) + print("qlock: %lux: nlocks %lud", getcallerpc(&q), up->nlocks); lock(&q->use); rwstats.qlock++; @@ -48,7 +43,7 @@ qlock(QLock *q) up->state = Queueing; up->qpc = getcallerpc(&q); unlock(&q->use); - if (isedf(up)) + if(isedf(up)) edfblock(up); sched(); } @@ -74,7 +69,7 @@ qunlock(QLock *q) lock(&q->use); p = q->head; - if(p) { + if(p){ q->head = p->qnext; if(q->head == 0) q->tail = 0; @@ -214,7 +209,7 @@ wunlock(RWlock *q) unlock(&q->use); } -/* same as rlock but punts if there are any readers waiting */ +/* same as rlock but punts if there are any writers waiting */ int canrlock(RWlock *q) { diff --git a/port/sysproc.c b/port/sysproc.c index 385dad33695f3f33a6859adb03c45059cd569f09..55dcde6789f6e855f46939db9ddfb3824b0ad51d 100644 --- a/port/sysproc.c +++ b/port/sysproc.c @@ -14,7 +14,6 @@ Ref sysr1ref; long sysr1(ulong *arg) { - int x; long a; a = *arg; diff --git a/port/taslock.c b/port/taslock.c index a48c9fbe7c97c381d53d67dc25298e752c30f7c6..6a7fc4555522bd7e30ae5c984568a0baa9bbf2f0 100644 --- a/port/taslock.c +++ b/port/taslock.c @@ -96,8 +96,8 @@ ilock(Lock *l) lockstats.locks++; x = splhi(); - m->ilockdepth++; if(tas(&l->key) == 0){ + m->ilockdepth++; if(up) up->lastlock = l; l->sr = x; @@ -120,6 +120,7 @@ ilock(Lock *l) ; x = splhi(); if(tas(&l->key) == 0){ + m->ilockdepth++; if(up) up->lastlock = l; l->sr = x;