kernel: simplify pgrpnote(); moving the note string copying to procwrite()
keeps handling of devproc's note and notepg files similar and in the same place and reduces stack usage.
This commit is contained in:
parent
f8de863602
commit
24d1fbde27
3 changed files with 8 additions and 10 deletions
|
@ -1164,7 +1164,11 @@ procwrite(Chan *c, void *va, long n, vlong off)
|
|||
* than the process pgrpid
|
||||
*/
|
||||
if(QID(c->qid) == Qnotepg) {
|
||||
pgrpnote(NOTEID(c->pgrpid), va, n, NUser);
|
||||
if(n >= ERRMAX-1)
|
||||
error(Etoobig);
|
||||
memmove(buf, va, n);
|
||||
buf[n] = 0;
|
||||
pgrpnote(NOTEID(c->pgrpid), buf, NUser);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,16 +13,10 @@ static Ref pgrpid;
|
|||
static Ref mountid;
|
||||
|
||||
void
|
||||
pgrpnote(ulong noteid, char *a, long n, int flag)
|
||||
pgrpnote(ulong noteid, char *n, int flag)
|
||||
{
|
||||
Proc *p, *ep;
|
||||
char buf[ERRMAX];
|
||||
|
||||
if(n >= ERRMAX-1)
|
||||
error(Etoobig);
|
||||
|
||||
memmove(buf, a, n);
|
||||
buf[n] = 0;
|
||||
p = proctab(0);
|
||||
for(ep = p+conf.nproc; p < ep; p++) {
|
||||
if(p->state == Dead)
|
||||
|
@ -30,7 +24,7 @@ pgrpnote(ulong noteid, char *a, long n, int flag)
|
|||
if(up != p && p->noteid == noteid && p->kp == 0) {
|
||||
qlock(&p->debug);
|
||||
if(p->noteid == noteid)
|
||||
postnote(p, 0, buf, flag);
|
||||
postnote(p, 0, n, flag);
|
||||
qunlock(&p->debug);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ void pathclose(Path*);
|
|||
ulong perfticks(void);
|
||||
void pexit(char*, int);
|
||||
void pgrpcpy(Pgrp*, Pgrp*);
|
||||
void pgrpnote(ulong, char*, long, int);
|
||||
void pgrpnote(ulong, char*, int);
|
||||
int pidalloc(Proc*);
|
||||
#define poperror() up->nerrlab--
|
||||
void portcountpagerefs(ulong*, int);
|
||||
|
|
Loading…
Reference in a new issue