From 86b9c733ad0a571390acb42f7bec1305b78a8ada Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 13 Jun 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-06-13 --- carrera/l.s | 8 ++++---- port/devproc.c | 12 ++++++------ port/pgrp.c | 53 +++++++++++++++++++++++++++++++++++++++++++------- port/portdat.h | 2 ++ 4 files changed, 58 insertions(+), 17 deletions(-) diff --git a/carrera/l.s b/carrera/l.s index 35a02288a6479ac2758ef3e9d938dd5b2c08f576..fb55f251a143a01f787400edfb1940bd68036605 100644 --- a/carrera/l.s +++ b/carrera/l.s @@ -403,6 +403,10 @@ sysrestore: MOVW R26, M(EPC) ERET +TEXT forkret(SB), $0 + MOVW R0, R1 /* Fake out system call return */ + JMP sysrestore + notsys: JAL trap(SB) restore: @@ -432,10 +436,6 @@ waskernel: MOVW R26, M(EPC) ERET -TEXT forkret(SB), $0 - MOVW R0, R1 /* Fake out system call return */ - JMP sysrestore - TEXT saveregs(SB), $-4 MOVV R1, Ureg_r1(SP) MOVV R2, Ureg_r2(SP) diff --git a/port/devproc.c b/port/devproc.c index ac44726a08859487d40a4c4222f9f20d4cc9694e..ab5855016514f4d493b856bbcf5023ae59ad8839 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -483,22 +483,22 @@ mntscan(Mntwalk *mw) { Pgrp *pg; Mount *t; - int nxt; + Mhead *f; + int nxt, i; ulong last, bestmid; - Mhead **h, **he, *f; pg = up->pgrp; rlock(&pg->ns); nxt = 0; - last = 0; bestmid = ~0; + + last = 0; if(mw->mh) last = mw->cm->mountid; - he = &pg->mnthash[MNTHASH]; - for(h = pg->mnthash; h < he; h++) { - for(f = *h; f; f = f->hash) { + for(i = 0; i < MNTHASH; i++) { + for(f = pg->mnthash[i]; f; f = f->hash) { for(t = f->mount; t; t = t->next) { if(mw->mh == 0 || (t->mountid > last && t->mountid < bestmid)) { diff --git a/port/pgrp.c b/port/pgrp.c index a4a518507550b72880e6aabe033613880927b9c1..ffa922401f472118d1b344f4e2b20b6d5a442bce 100644 --- a/port/pgrp.c +++ b/port/pgrp.c @@ -73,19 +73,43 @@ closepgrp(Pgrp *p) } } +void +pgrpinsert(Mount **order, Mount *m) +{ + Mount *f; + + m->order = 0; + if(*order == 0) { + *order = m; + return; + } + for(f = *order; f; f = f->order) { + if(m->mountid < f->mountid) { + m->order = f; + *order = m; + return; + } + order = &f->order; + } + *order = m; +} + +/* + * pgrpcpy MUST preserve the mountid allocation order of the parent group + */ void pgrpcpy(Pgrp *to, Pgrp *from) { - Mhead **h, **e, *f, **tom, **l, *mh; - Mount *n, *m, **link; + int i; + Mount *n, *m, **link, *order; + Mhead *f, **tom, **l, *mh; rlock(&from->ns); - - e = &from->mnthash[MNTHASH]; + order = 0; tom = to->mnthash; - for(h = from->mnthash; h < e; h++) { + for(i = 0; i < MNTHASH; i++) { l = tom++; - for(f = *h; f; f = f->hash) { + for(f = from->mnthash[i]; f; f = f->hash) { mh = smalloc(sizeof(Mhead)); mh->from = f->from; incref(mh->from); @@ -93,12 +117,27 @@ pgrpcpy(Pgrp *to, Pgrp *from) l = &mh->hash; link = &mh->mount; for(m = f->mount; m; m = m->next) { - n = newmount(mh, m->to, m->flag, m->spec); + n = smalloc(sizeof(Mount)); + n->to = m->to; + incref(n->to); + n->head = mh; + n->flag = m->flag; + if(m->spec != 0) + strcpy(n->spec, m->spec); + m->copy = n; + pgrpinsert(&order, m); *link = n; link = &n->next; } } } + /* + * Allocate mount ids in the same sequence as the parent group + */ + lock(&mountid); + for(m = order; m; m = m->order) + m->copy->mountid = mountid.ref++; + unlock(&mountid); runlock(&from->ns); } diff --git a/port/portdat.h b/port/portdat.h index b723f863c4dd30a10dba8161507d814e39b5ce6c..cc1e9529758f5a54f1c4f22ee459224908a6c564 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -216,6 +216,8 @@ struct Mount ulong mountid; Mount* next; Mhead* head; + Mount* copy; + Mount* order; Chan* to; /* channel replacing channel */ int flag; char spec[NAMELEN];