~kris/9p

9hist

86b9c733ad0a571390acb42f7bec1305b78a8ada — David du Colombier 32 years ago 8d14e26
Plan 9 from Bell Labs 1994-06-13
4 files changed, 58 insertions(+), 17 deletions(-)

M carrera/l.s
M port/devproc.c
M port/pgrp.c
M port/portdat.h
M carrera/l.s => carrera/l.s +4 -4
@@ 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)

M port/devproc.c => port/devproc.c +6 -6
@@ 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)) {

M port/pgrp.c => port/pgrp.c +46 -7
@@ 74,18 74,42 @@ 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);
}


M port/portdat.h => port/portdat.h +2 -0
@@ 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];