plan 9 kernel history: overview | file list | diff list

1992/0824/port/pgrp.c (diff list | history)

1990/0227/sys/src/9/port/pgrp.c:122,1281990/0321/sys/src/9/port/pgrp.c:122,129 (short | long)
1990/0227    
{ 
	lock(m); 
	if(m->ref == 1){ 
		close(m->c); 
1990/0321    
		if(m->c) 
			close(m->c); 
1990/0227    
		if(m->next) 
			closemount(m->next); 
		unlock(m); 
1990/0321/sys/src/9/port/pgrp.c:111,1161990/0810/sys/src/9/port/pgrp.c:111,117 (short | long)
1990/0227    
	print("no mounts\n"); 
	if(u == 0) 
		panic("newmount"); 
1990/0810    
	print("%s %s\n", u->p->pgrp->user, u->p->text); 
1990/0227    
	u->p->state = Wakeme; 
	alarm(1000, wakeme, u->p); 
	sched(); 
1990/0810/sys/src/9/port/pgrp.c:27,381990/0825/sys/src/9/port/pgrp.c:27,38 (short | long)
1990/0227    
	pgrpalloc.free = ialloc(conf.npgrp*sizeof(Pgrp), 0); 
 
	p = pgrpalloc.free; 
	for(i=0; i<conf.npgrp-1; i++,p++){ 
1990/0825    
	for(i=0; i<conf.npgrp; i++,p++){ 
1990/0227    
		p->next = p+1; 
		p->mtab = ialloc(conf.nmtab*sizeof(Mtab), 0); 
		p->etab = ialloc(conf.npgenv*sizeof(Envp*), 0); 
	} 
	p->next = 0; 
1990/0825    
	p[-1].next = 0; 
1990/0227    
 
	mountalloc.free = ialloc(conf.nmount*sizeof(Mount), 0); 
 
1990/0810/sys/src/9/port/pgrp.c:111,1171990/0825/sys/src/9/port/pgrp.c:111,116
1990/0227    
	print("no mounts\n"); 
	if(u == 0) 
		panic("newmount"); 
1990/0810    
	print("%s %s\n", u->p->pgrp->user, u->p->text); 
1990/0227    
	u->p->state = Wakeme; 
	alarm(1000, wakeme, u->p); 
	sched(); 
1990/0825/sys/src/9/port/pgrp.c:103,1081990/0928/sys/src/9/port/pgrp.c:103,109 (short | long)
1990/0227    
	if(m = mountalloc.free){		/* assign = */ 
		mountalloc.free = m->next; 
		m->ref = 1; 
1990/0928    
		m->next = 0; 
1990/0227    
		m->mountid = ++mountalloc.mountid; 
		unlock(&mountalloc); 
		return m; 
1990/0928/sys/src/9/port/pgrp.c:7,121990/1110/sys/src/9/port/pgrp.c:7,13 (short | long)
1990/0227    
 
struct{ 
	Lock; 
1990/1110    
	Pgrp	*arena; 
1990/0227    
	Pgrp	*free; 
	ulong	pgrpid; 
}pgrpalloc; 
1990/0928/sys/src/9/port/pgrp.c:24,331990/1110/sys/src/9/port/pgrp.c:25,36
1990/0227    
	Pgrp *p; 
	Mount *m; 
 
	pgrpalloc.free = ialloc(conf.npgrp*sizeof(Pgrp), 0); 
1990/1110    
	pgrpalloc.arena = ialloc(conf.npgrp*sizeof(Pgrp), 0); 
	pgrpalloc.free = pgrpalloc.arena; 
1990/0227    
 
	p = pgrpalloc.free; 
1990/0825    
	for(i=0; i<conf.npgrp; i++,p++){ 
1990/1110    
		p->index = i; 
1990/0227    
		p->next = p+1; 
		p->mtab = ialloc(conf.nmtab*sizeof(Mtab), 0); 
		p->etab = ialloc(conf.npgenv*sizeof(Envp*), 0); 
1990/0928/sys/src/9/port/pgrp.c:43,481990/1110/sys/src/9/port/pgrp.c:46,88
1990/0227    
} 
 
Pgrp* 
1990/1110    
pgrptab(int i) 
{ 
	return &pgrpalloc.arena[i]; 
} 
 
void 
pgrpnote(Pgrp *pg, char *a, long n, int flag) 
{ 
	int i; 
	Proc *p; 
	char buf[ERRLEN]; 
 
	if(n >= ERRLEN-1) 
		error(0, Etoobig); 
	if(n>=4 && strncmp(a, "sys:", 4)==0) 
		error(0, Ebadarg); 
	memcpy(buf, a, n); 
	buf[n] = 0; 
	p = proctab(0); 
	for(i=0; i<conf.nproc; i++, p++){ 
		if(p->pgrp == pg){ 
			lock(&p->debug); 
			if(p->pid==0 || p->pgrp!=pg){ 
				unlock(&p->debug); 
				continue; 
			} 
			if(waserror()){ 
				unlock(&p->debug); 
				continue; 
			} 
			postnote(p, 0, buf, flag); 
			unlock(&p->debug); 
		} 
	} 
} 
 
Pgrp* 
1990/0227    
newpgrp(void) 
{ 
	Pgrp *p; 
1990/0928/sys/src/9/port/pgrp.c:76,811990/1110/sys/src/9/port/pgrp.c:116,123
1990/0227    
	Envp *ep; 
 
	if(decref(p) == 0){ 
1990/1110    
		lock(&p->debug); 
		p->pgrpid = -1; 
1990/0227    
		m = p->mtab; 
		for(i=0; i<p->nmtab; i++,m++) 
			if(m->c){ 
1990/0928/sys/src/9/port/pgrp.c:89,941990/1110/sys/src/9/port/pgrp.c:131,137
1990/0227    
		lock(&pgrpalloc); 
		p->next = pgrpalloc.free; 
		pgrpalloc.free = p; 
1990/1110    
		unlock(&p->debug); 
1990/0227    
		unlock(&pgrpalloc); 
	} 
} 
1990/1110/sys/src/9/port/pgrp.c:59,671990/11211/sys/src/9/port/pgrp.c:59,67 (short | long)
1990/1110    
	char buf[ERRLEN]; 
 
	if(n >= ERRLEN-1) 
		error(0, Etoobig); 
1990/11211    
		error(Etoobig); 
1990/1110    
	if(n>=4 && strncmp(a, "sys:", 4)==0) 
		error(0, Ebadarg); 
1990/11211    
		error(Ebadarg); 
1990/1110    
	memcpy(buf, a, n); 
	buf[n] = 0; 
	p = proctab(0); 
1990/11211/sys/src/9/port/pgrp.c:72,821991/0125/sys/src/9/port/pgrp.c:72,81 (short | long)
1990/1110    
				unlock(&p->debug); 
				continue; 
			} 
			if(waserror()){ 
				unlock(&p->debug); 
				continue; 
1991/0125    
			if(!waserror()){ 
				postnote(p, 0, buf, flag); 
				poperror(); 
1990/1110    
			} 
			postnote(p, 0, buf, flag); 
			unlock(&p->debug); 
		} 
	} 
1991/0125/sys/src/9/port/pgrp.c:115,1211991/0212/sys/src/9/port/pgrp.c:115,121 (short | long)
1990/0227    
	Envp *ep; 
 
	if(decref(p) == 0){ 
1990/1110    
		lock(&p->debug); 
1991/0212    
		qlock(&p->debug); 
1990/1110    
		p->pgrpid = -1; 
1990/0227    
		m = p->mtab; 
		for(i=0; i<p->nmtab; i++,m++) 
1991/0125/sys/src/9/port/pgrp.c:130,1361991/0212/sys/src/9/port/pgrp.c:130,136
1990/0227    
		lock(&pgrpalloc); 
		p->next = pgrpalloc.free; 
		pgrpalloc.free = p; 
1990/1110    
		unlock(&p->debug); 
1991/0212    
		qunlock(&p->debug); 
1990/0227    
		unlock(&pgrpalloc); 
	} 
} 
1991/0212/sys/src/9/port/pgrp.c:62,681991/0318/sys/src/9/port/pgrp.c:62,68 (short | long)
1990/11211    
		error(Etoobig); 
1990/1110    
	if(n>=4 && strncmp(a, "sys:", 4)==0) 
1990/11211    
		error(Ebadarg); 
1990/1110    
	memcpy(buf, a, n); 
1991/0318    
	memmove(buf, a, n); 
1990/1110    
	buf[n] = 0; 
	p = proctab(0); 
	for(i=0; i<conf.nproc; i++, p++){ 
1991/0212/sys/src/9/port/pgrp.c:190,1971991/0318/sys/src/9/port/pgrp.c:190,197
1990/0227    
	Env *e; 
 
	lock(from); 
	memcpy(to->user, from->user, NAMELEN); 
	memcpy(to->mtab, from->mtab, from->nmtab*sizeof(Mtab)); 
1991/0318    
	memmove(to->user, from->user, NAMELEN); 
	memmove(to->mtab, from->mtab, from->nmtab*sizeof(Mtab)); 
1990/0227    
	to->nmtab = from->nmtab; 
	m = to->mtab; 
	for(i=0; i<from->nmtab; i++,m++) 
1991/0318/sys/src/9/port/pgrp.c:182,2071991/0514/sys/src/9/port/pgrp.c:182,194 (short | long)
1990/0227    
} 
 
void 
pgrpcpy(Pgrp *to, Pgrp *from) 
1991/0514    
envcpy(Pgrp *to, Pgrp *from) 
1990/0227    
{ 
	int i; 
	Mtab *m; 
	Envp *ep; 
	Env *e; 
1991/0514    
	int i; 
1990/0227    
 
	lock(from); 
1991/0318    
	memmove(to->user, from->user, NAMELEN); 
	memmove(to->mtab, from->mtab, from->nmtab*sizeof(Mtab)); 
1990/0227    
	to->nmtab = from->nmtab; 
	m = to->mtab; 
	for(i=0; i<from->nmtab; i++,m++) 
		if(m->c){ 
			incref(m->c); 
			lock(m->mnt); 
			m->mnt->ref++; 
			unlock(m->mnt); 
		} 
                 
	to->nenv = from->nenv; 
	ep = to->etab; 
	for(i=0; i<from->nenv; i++,ep++){ 
1991/0318/sys/src/9/port/pgrp.c:231,2351991/0514/sys/src/9/port/pgrp.c:218,244
1990/0227    
			unlock(e); 
		} 
	} 
1991/0514    
	unlock(from); 
} 
 
void 
pgrpcpy(Pgrp *to, Pgrp *from) 
{ 
	int i; 
	Mtab *m; 
 
	lock(from); 
	memmove(to->user, from->user, NAMELEN); 
	memmove(to->mtab, from->mtab, from->nmtab*sizeof(Mtab)); 
	to->nmtab = from->nmtab; 
	m = to->mtab; 
	for(i=0; i<from->nmtab; i++,m++) 
		if(m->c){ 
			incref(m->c); 
			lock(m->mnt); 
			m->mnt->ref++; 
			unlock(m->mnt); 
		} 
 
1990/0227    
	unlock(from); 
} 
1991/0514/sys/src/9/port/pgrp.c:5,111991/0705/sys/src/9/port/pgrp.c:5,12 (short | long)
1990/0227    
#include	"fns.h" 
#include	"errno.h" 
 
struct{ 
1991/0705    
struct 
{ 
1990/0227    
	Lock; 
1990/1110    
	Pgrp	*arena; 
1990/0227    
	Pgrp	*free; 
1991/0514/sys/src/9/port/pgrp.c:12,171991/0705/sys/src/9/port/pgrp.c:13,30
1990/0227    
	ulong	pgrpid; 
}pgrpalloc; 
 
1991/0705    
struct 
{ 
	Lock; 
	Egrp	*free; 
}egrpalloc; 
 
struct 
{ 
	Lock; 
	Fgrp	*free; 
}fgrpalloc; 
 
1990/0227    
struct{ 
	Lock; 
	Mount	*free; 
1991/0514/sys/src/9/port/pgrp.c:19,291991/0705/sys/src/9/port/pgrp.c:32,44
1990/0227    
}mountalloc; 
 
void 
pgrpinit(void) 
1991/0705    
grpinit(void) 
1990/0227    
{ 
	int i; 
	Pgrp *p; 
	Mount *m; 
1991/0705    
	Egrp *e, *ee; 
	Fgrp *f, *fe; 
	Mount *m, *em; 
1990/0227    
 
1990/1110    
	pgrpalloc.arena = ialloc(conf.npgrp*sizeof(Pgrp), 0); 
	pgrpalloc.free = pgrpalloc.arena; 
1991/0514/sys/src/9/port/pgrp.c:33,461991/0705/sys/src/9/port/pgrp.c:48,73
1990/1110    
		p->index = i; 
1990/0227    
		p->next = p+1; 
		p->mtab = ialloc(conf.nmtab*sizeof(Mtab), 0); 
		p->etab = ialloc(conf.npgenv*sizeof(Envp*), 0); 
	} 
1990/0825    
	p[-1].next = 0; 
1990/0227    
 
	mountalloc.free = ialloc(conf.nmount*sizeof(Mount), 0); 
1991/0705    
	egrpalloc.free = ialloc(conf.npgrp*sizeof(Egrp), 0); 
	ee = &egrpalloc.free[conf.npgrp]; 
	for(e = egrpalloc.free; e < ee; e++) { 
		e->next = e+1; 
		e->etab = ialloc(conf.npgenv*sizeof(Envp*), 0); 
	} 
	e[-1].next = 0; 
1990/0227    
 
	m = mountalloc.free; 
	for(i=0; i<conf.nmount-1; i++,m++) 
1991/0705    
	fgrpalloc.free = ialloc(conf.nproc*sizeof(Fgrp), 0); 
	fe = &fgrpalloc.free[conf.nproc-1]; 
	for(f = fgrpalloc.free; f < fe; f++) 
		f->next = f+1; 
	f->next = 0; 
 
	mountalloc.free = ialloc(conf.nmount*sizeof(Mount), 0); 
	em = &mountalloc.free[conf.nmount-1]; 
	for(m = mountalloc.free; m < em; m++) 
1990/0227    
		m->next = m+1; 
	m->next = 0; 
} 
1991/0514/sys/src/9/port/pgrp.c:86,1101991/0705/sys/src/9/port/pgrp.c:113,200
1990/0227    
{ 
	Pgrp *p; 
 
loop: 
	lock(&pgrpalloc); 
	if(p = pgrpalloc.free){		/* assign = */ 
		pgrpalloc.free = p->next; 
		p->ref = 1; 
		p->pgrpid = ++pgrpalloc.pgrpid; 
		p->nmtab = 0; 
		p->nenv = 0; 
1991/0705    
	for(;;) { 
		lock(&pgrpalloc); 
		if(p = pgrpalloc.free){ 
			pgrpalloc.free = p->next; 
			p->ref = 1; 
			p->pgrpid = ++pgrpalloc.pgrpid; 
			p->nmtab = 0; 
			unlock(&pgrpalloc); 
			return p; 
		} 
1990/0227    
		unlock(&pgrpalloc); 
		return p; 
1991/0705    
		resrcwait("no pgrps"); 
1990/0227    
	} 
	unlock(&pgrpalloc); 
	print("no pgrps\n"); 
1991/0705    
} 
 
Egrp* 
newegrp(void) 
{ 
	Egrp *e; 
 
	for(;;) { 
		lock(&egrpalloc); 
		if(e = egrpalloc.free) { 
			egrpalloc.free = e->next; 
			e->ref = 1; 
			e->nenv = 0; 
			unlock(&egrpalloc); 
			return e; 
		} 
		unlock(&egrpalloc); 
		resrcwait("no envgrps"); 
	} 
} 
 
Fgrp* 
newfgrp(void) 
{ 
	Fgrp *f; 
 
	for(;;) { 
		lock(&fgrpalloc); 
		if(f = fgrpalloc.free) { 
			fgrpalloc.free = f->next; 
			f->ref = 1; 
			f->maxfd = 0; 
			memset(f->fd, 0, sizeof(f->fd)); 
			unlock(&fgrpalloc); 
			return f; 
		} 
		unlock(&fgrpalloc); 
		resrcwait("no filegrps"); 
	} 
} 
 
Fgrp* 
dupfgrp(Fgrp *f) 
{ 
	Fgrp *new; 
	Chan *c; 
	int i; 
 
	new = newfgrp(); 
 
	new->maxfd = f->maxfd; 
	for(i = 0; i <= f->maxfd; i++) 
		if(c = f->fd[i]){ 
			incref(c); 
			new->fd[i] = c; 
		} 
 
	return new; 
} 
 
void 
resrcwait(char *reason) 
{ 
	print("%s\n", reason); 
1990/0227    
	if(u == 0) 
		panic("newpgrp"); 
1991/0705    
		panic("resched"); 
1990/0227    
	u->p->state = Wakeme; 
	alarm(1000, wakeme, u->p); 
	sched(); 
	goto loop; 
} 
 
void 
1991/0514/sys/src/9/port/pgrp.c:112,1181991/0705/sys/src/9/port/pgrp.c:202,207
1990/0227    
{ 
	int i; 
	Mtab *m; 
	Envp *ep; 
 
	if(decref(p) == 0){ 
1991/0212    
		qlock(&p->debug); 
1991/0514/sys/src/9/port/pgrp.c:123,1321991/0705/sys/src/9/port/pgrp.c:212,217
1990/0227    
				close(m->c); 
				closemount(m->mnt); 
			} 
		ep = p->etab; 
		for(i=0; i<p->nenv; i++,ep++) 
			if(ep->env) 
				envpgclose(ep->env); 
		lock(&pgrpalloc); 
		p->next = pgrpalloc.free; 
		pgrpalloc.free = p; 
1991/0514/sys/src/9/port/pgrp.c:135,1401991/0705/sys/src/9/port/pgrp.c:220,262
1990/0227    
	} 
} 
 
1991/0705    
void 
closeegrp(Egrp *e) 
{ 
	Envp *ep; 
	int i; 
 
	if(decref(e) == 0) { 
		ep = e->etab; 
		for(i=0; i<e->nenv; i++,ep++) 
			if(ep->env) 
				envpgclose(ep->env); 
		lock(&egrpalloc); 
		e->next = egrpalloc.free; 
		egrpalloc.free = e; 
		unlock(&egrpalloc); 
	} 
} 
 
void 
closefgrp(Fgrp *f) 
{ 
	int i; 
	Chan *c; 
 
	if(decref(f) == 0) { 
		for(i = 0; i <= f->maxfd; i++) 
			if(c = f->fd[i]) 
				close(c); 
 
		lock(&fgrpalloc); 
		f->next = fgrpalloc.free; 
		fgrpalloc.free = f; 
		unlock(&fgrpalloc); 
	} 
} 
 
 
1990/0227    
Mount* 
newmount(void) 
{ 
1991/0514/sys/src/9/port/pgrp.c:182,1881991/0705/sys/src/9/port/pgrp.c:304,310
1990/0227    
} 
 
void 
1991/0514    
envcpy(Pgrp *to, Pgrp *from) 
1991/0705    
envcpy(Egrp *to, Egrp *from) 
1990/0227    
{ 
	Envp *ep; 
	Env *e; 
1991/0705/sys/src/9/port/pgrp.c:189,1971991/0710/sys/src/9/port/pgrp.c:189,198 (short | long)
1991/0705    
void 
resrcwait(char *reason) 
{ 
	print("%s\n", reason); 
1991/0710    
	if(reason) 
		print("%s\n", reason); 
1990/0227    
	if(u == 0) 
1991/0705    
		panic("resched"); 
1991/0710    
		panic("resrcwait"); 
1990/0227    
	u->p->state = Wakeme; 
	alarm(1000, wakeme, u->p); 
	sched(); 
1991/0710/sys/src/9/port/pgrp.c:120,1251991/0806/sys/src/9/port/pgrp.c:120,126 (short | long)
1991/0705    
			p->ref = 1; 
			p->pgrpid = ++pgrpalloc.pgrpid; 
			p->nmtab = 0; 
1991/0806    
			memset(p->rendhash, 0, sizeof(p->rendhash)); 
1991/0705    
			unlock(&pgrpalloc); 
			return p; 
		} 
1991/0806/sys/src/9/port/pgrp.c:28,331991/1011/sys/src/9/port/pgrp.c:28,34 (short | long)
1990/0227    
struct{ 
	Lock; 
	Mount	*free; 
1991/1011    
	Mhead	*mhfree; 
1990/0227    
	ulong	mountid; 
}mountalloc; 
 
1991/0806/sys/src/9/port/pgrp.c:39,531991/1011/sys/src/9/port/pgrp.c:40,54
1991/0705    
	Egrp *e, *ee; 
	Fgrp *f, *fe; 
	Mount *m, *em; 
1991/1011    
	Mhead *hm, *hem; 
1990/0227    
 
1990/1110    
	pgrpalloc.arena = ialloc(conf.npgrp*sizeof(Pgrp), 0); 
	pgrpalloc.free = pgrpalloc.arena; 
1990/0227    
 
	p = pgrpalloc.free; 
1990/0825    
	for(i=0; i<conf.npgrp; i++,p++){ 
1991/1011    
	for(i=0; i<conf.npgrp; i++,p++) { 
1990/1110    
		p->index = i; 
1990/0227    
		p->next = p+1; 
		p->mtab = ialloc(conf.nmtab*sizeof(Mtab), 0); 
	} 
1990/0825    
	p[-1].next = 0; 
1990/0227    
 
1991/0806/sys/src/9/port/pgrp.c:64,751991/1011/sys/src/9/port/pgrp.c:65,70
1991/0705    
	for(f = fgrpalloc.free; f < fe; f++) 
		f->next = f+1; 
	f->next = 0; 
                 
	mountalloc.free = ialloc(conf.nmount*sizeof(Mount), 0); 
	em = &mountalloc.free[conf.nmount-1]; 
	for(m = mountalloc.free; m < em; m++) 
1990/0227    
		m->next = m+1; 
	m->next = 0; 
} 
 
Pgrp* 
1991/0806/sys/src/9/port/pgrp.c:119,1261991/1011/sys/src/9/port/pgrp.c:114,121
1991/0705    
			pgrpalloc.free = p->next; 
			p->ref = 1; 
			p->pgrpid = ++pgrpalloc.pgrpid; 
			p->nmtab = 0; 
1991/0806    
			memset(p->rendhash, 0, sizeof(p->rendhash)); 
1991/1011    
			memset(p->mnthash, 0, sizeof(p->mnthash)); 
1991/0705    
			unlock(&pgrpalloc); 
			return p; 
		} 
1991/0806/sys/src/9/port/pgrp.c:202,2191991/1011/sys/src/9/port/pgrp.c:197,218
1990/0227    
void 
closepgrp(Pgrp *p) 
{ 
	int i; 
	Mtab *m; 
                 
1991/1011    
	Mhead **h, **e, *f, *next; 
	 
1990/0227    
	if(decref(p) == 0){ 
1991/0212    
		qlock(&p->debug); 
1990/1110    
		p->pgrpid = -1; 
1990/0227    
		m = p->mtab; 
		for(i=0; i<p->nmtab; i++,m++) 
			if(m->c){ 
				close(m->c); 
				closemount(m->mnt); 
1991/1011    
 
		e = &p->mnthash[MNTHASH]; 
		for(h = p->mnthash; h < e; h++) { 
			for(f = *h; f; f = next) { 
				close(f->from); 
				mountfree(f->mount); 
				next = f->hash; 
				mntheadfree(f); 
1990/0227    
			} 
1991/1011    
		} 
 
1990/0227    
		lock(&pgrpalloc); 
		p->next = pgrpalloc.free; 
		pgrpalloc.free = p; 
1991/0806/sys/src/9/port/pgrp.c:260,3081991/1011/sys/src/9/port/pgrp.c:259,292
1991/0705    
 
 
1990/0227    
Mount* 
newmount(void) 
1991/1011    
newmount(Mhead *mh, Chan *to) 
1990/0227    
{ 
	Mount *m; 
1991/1011    
	Mount *m, *f, *e; 
1990/0227    
 
loop: 
	lock(&mountalloc); 
	if(m = mountalloc.free){		/* assign = */ 
		mountalloc.free = m->next; 
		m->ref = 1; 
1990/0928    
		m->next = 0; 
1990/0227    
		m->mountid = ++mountalloc.mountid; 
1991/1011    
	for(;;) { 
		lock(&mountalloc); 
		if(m = mountalloc.free){		/* assign = */ 
			mountalloc.free = m->next; 
			m->mountid = ++mountalloc.mountid; 
			unlock(&mountalloc); 
			m->next = 0; 
			m->head = mh; 
			m->to = to; 
			incref(to); 
			return m; 
		} 
1990/0227    
		unlock(&mountalloc); 
		return m; 
	} 
	unlock(&mountalloc); 
	print("no mounts\n"); 
	if(u == 0) 
		panic("newmount"); 
	u->p->state = Wakeme; 
	alarm(1000, wakeme, u->p); 
	sched(); 
	goto loop; 
} 
 
void 
closemount(Mount *m) 
{ 
	lock(m); 
	if(m->ref == 1){ 
1990/0321    
		if(m->c) 
			close(m->c); 
1990/0227    
		if(m->next) 
			closemount(m->next); 
		unlock(m); 
1991/1011    
		m = (Mount*)VA(kmap(newpage(0, 0, 0))); 
		e = &m[(BY2PG/sizeof(Mount))-1]; 
		for(f = m; f < e; f++) 
			f->next = f+1; 
 
1990/0227    
		lock(&mountalloc); 
		m->mountid = 0; 
		m->next = mountalloc.free; 
1991/1011    
		e->next = mountalloc.free; 
1990/0227    
		mountalloc.free = m; 
		unlock(&mountalloc); 
		return; 
	} 
	m->ref--; 
	unlock(m); 
} 
 
void 
1991/0806/sys/src/9/port/pgrp.c:348,3681991/1011/sys/src/9/port/pgrp.c:332,411
1991/0514    
void 
pgrpcpy(Pgrp *to, Pgrp *from) 
{ 
	int i; 
	Mtab *m; 
1991/1011    
	Mhead **h, **e, *f, **l, *mh; 
	Mount *n, *m, **link; 
1991/0514    
 
	lock(from); 
	memmove(to->user, from->user, NAMELEN); 
	memmove(to->mtab, from->mtab, from->nmtab*sizeof(Mtab)); 
	to->nmtab = from->nmtab; 
	m = to->mtab; 
	for(i=0; i<from->nmtab; i++,m++) 
		if(m->c){ 
			incref(m->c); 
			lock(m->mnt); 
			m->mnt->ref++; 
			unlock(m->mnt); 
1991/1011    
 
	rlock(&from->ns); 
 
	e = &from->mnthash[MNTHASH]; 
	for(h = from->mnthash; h < e; h++) { 
		for(f = *h; f; f = f->hash) { 
			mh = newmnthead(); 
			mh->from = f->from; 
			incref(mh->from); 
			l = &MOUNTH(to, mh->from); 
			mh->hash = *l; 
			*l = mh; 
			link = &mh->mount; 
			for(m = f->mount; m; m = m->next) { 
				n = newmount(mh, m->to); 
				*link = n; 
				link = &n->next;	 
			} 
1991/0514    
		} 
1991/1011    
	} 
	runlock(&from->ns); 
} 
1991/0514    
 
1990/0227    
	unlock(from); 
1991/1011    
Mhead * 
newmnthead(void) 
{ 
	Mhead *mh, *f, *e; 
 
	for(;;) { 
		lock(&mountalloc); 
		if(mh = mountalloc.mhfree) {		/* Assign '=' */ 
			mountalloc.mhfree = mh->hash; 
			unlock(&mountalloc); 
			mh->hash = 0; 
			mh->mount = 0; 
			return mh; 
		} 
		unlock(&mountalloc); 
 
		mh = (Mhead*)VA(kmap(newpage(0, 0, 0))); 
		e = &mh[(BY2PG/sizeof(Mhead))-1]; 
		for(f = mh; f < e; f++) 
			f->hash = f+1; 
 
		lock(&mountalloc); 
		e->hash = mountalloc.mhfree; 
		mountalloc.mhfree = mh; 
		unlock(&mountalloc); 
	} 
} 
 
void 
mntheadfree(Mhead *mh) 
{ 
	lock(&mountalloc); 
	mh->hash = mountalloc.mhfree; 
	mountalloc.mhfree = mh; 
	unlock(&mountalloc); 
} 
 
void 
mountfree(Mount *m) 
{ 
	Mount *f; 
 
	for(f = m; f->next; f = f->next) 
		close(f->to); 
	close(f->to); 
	lock(&mountalloc); 
	f->next = mountalloc.free; 
	mountalloc.free = m; 
	unlock(&mountalloc); 
1990/0227    
} 
1991/1011/sys/src/9/port/pgrp.c:56,621991/1018/sys/src/9/port/pgrp.c:56,62 (short | long)
1991/0705    
	ee = &egrpalloc.free[conf.npgrp]; 
	for(e = egrpalloc.free; e < ee; e++) { 
		e->next = e+1; 
		e->etab = ialloc(conf.npgenv*sizeof(Envp*), 0); 
1991/1018    
		e->etab = ialloc(conf.npgenv*sizeof(Env), 0); 
1991/0705    
	} 
	e[-1].next = 0; 
1990/0227    
 
1991/1011/sys/src/9/port/pgrp.c:222,2401991/1018/sys/src/9/port/pgrp.c:222,239
1990/0227    
} 
 
1991/0705    
void 
closeegrp(Egrp *e) 
1991/1018    
closeegrp(Egrp *eg) 
1991/0705    
{ 
	Envp *ep; 
1991/1018    
	Env *e; 
1991/0705    
	int i; 
 
	if(decref(e) == 0) { 
		ep = e->etab; 
		for(i=0; i<e->nenv; i++,ep++) 
			if(ep->env) 
				envpgclose(ep->env); 
1991/1018    
	if(decref(eg) == 0) { 
		e = eg->etab; 
		for(i=0; i<eg->nenv; i++, e++) 
			envpgclose(e); 
1991/0705    
		lock(&egrpalloc); 
		e->next = egrpalloc.free; 
		egrpalloc.free = e; 
1991/1018    
		eg->next = egrpalloc.free; 
		egrpalloc.free = eg; 
1991/0705    
		unlock(&egrpalloc); 
	} 
} 
1991/1011/sys/src/9/port/pgrp.c:292,3321991/1018/sys/src/9/port/pgrp.c:291,307
1990/0227    
void 
1991/0705    
envcpy(Egrp *to, Egrp *from) 
1990/0227    
{ 
	Envp *ep; 
	Env *e; 
1991/0514    
	int i; 
1991/1018    
	Env *te, *fe; 
	int i, nenv; 
1990/0227    
 
	lock(from); 
	to->nenv = from->nenv; 
	ep = to->etab; 
	for(i=0; i<from->nenv; i++,ep++){ 
		ep->chref = 0; 
		e = ep->env = from->etab[i].env; 
		if(e){ 
			lock(e); 
			if(waserror()){ 
				unlock(e); 
				unlock(from); 
				ep->env = 0; 
				nexterror(); 
			} 
			/* 
			 * If pgrp being forked has an open channel 
			 * on this env, it may write it after the fork 
			 * so make a copy now. 
			 * Don't worry about other pgrps, because they 
			 * will copy if they are about to write. 
			 */ 
			if(from->etab[i].chref){ 
				ep->env = copyenv(e, 0); 
				unlock(ep->env); 
			}else 
				e->pgref++; 
			poperror(); 
			unlock(e); 
		} 
	} 
1991/0514    
	unlock(from); 
1991/1018    
	qlock(&from->ev); 
	nenv = from->nenv; 
	to->nenv = nenv; 
	te = to->etab; 
	fe = from->etab; 
	for(i=0; i < nenv; i++, te++, fe++) 
		envpgcopy(te, fe); 
	qunlock(&from->ev); 
1991/0514    
} 
 
void 
1991/1018/sys/src/9/port/pgrp.c:310,3171991/1105/sys/src/9/port/pgrp.c:310,315 (short | long)
1991/1011    
	Mhead **h, **e, *f, **l, *mh; 
	Mount *n, *m, **link; 
1991/0514    
 
	memmove(to->user, from->user, NAMELEN); 
1991/1011    
                 
	rlock(&from->ns); 
 
	e = &from->mnthash[MNTHASH]; 
1991/1105/sys/src/9/port/pgrp.c:185,1971991/1110/sys/src/9/port/pgrp.c:185,203 (short | long)
1991/0705    
void 
resrcwait(char *reason) 
{ 
1991/0710    
	if(reason) 
1991/1110    
	char *p; 
 
	p = u->p->psstate; 
	if(reason) { 
		u->p->psstate = reason; 
1991/0710    
		print("%s\n", reason); 
1991/1110    
	} 
1990/0227    
	if(u == 0) 
1991/0710    
		panic("resrcwait"); 
1990/0227    
	u->p->state = Wakeme; 
	alarm(1000, wakeme, u->p); 
	sched(); 
1991/1110    
	u->p->psstate = p; 
1990/0227    
} 
 
void 
1991/1110/sys/src/9/port/pgrp.c:87,941991/1112/sys/src/9/port/pgrp.c:87,94 (short | long)
1991/0318    
	memmove(buf, a, n); 
1990/1110    
	buf[n] = 0; 
	p = proctab(0); 
	for(i=0; i<conf.nproc; i++, p++){ 
		if(p->pgrp == pg){ 
1991/1112    
	for(i=0; i<conf.nproc; i++, p++) { 
		if(p->pgrp == pg && p->kp == 0) { 
1990/1110    
			lock(&p->debug); 
			if(p->pid==0 || p->pgrp!=pg){ 
				unlock(&p->debug); 
1991/1112/sys/src/9/port/pgrp.c:313,3321991/1113/sys/src/9/port/pgrp.c:313,333 (short | long)
1991/0514    
void 
pgrpcpy(Pgrp *to, Pgrp *from) 
{ 
1991/1011    
	Mhead **h, **e, *f, **l, *mh; 
1991/1113    
	Mhead **h, **e, *f, **tom, **l, *mh; 
1991/1011    
	Mount *n, *m, **link; 
1991/0514    
 
1991/1011    
	rlock(&from->ns); 
 
	e = &from->mnthash[MNTHASH]; 
1991/1113    
	tom = to->mnthash; 
1991/1011    
	for(h = from->mnthash; h < e; h++) { 
1991/1113    
		l = tom++; 
1991/1011    
		for(f = *h; f; f = f->hash) { 
			mh = newmnthead(); 
			mh->from = f->from; 
			incref(mh->from); 
			l = &MOUNTH(to, mh->from); 
			mh->hash = *l; 
			*l = mh; 
1991/1113    
			l = &mh->hash; 
1991/1011    
			link = &mh->mount; 
			for(m = f->mount; m; m = m->next) { 
				n = newmount(mh, m->to); 
1991/1113/sys/src/9/port/pgrp.c:41,471991/1127/sys/src/9/port/pgrp.c:41,52 (short | long)
1991/0705    
	Fgrp *f, *fe; 
	Mount *m, *em; 
1991/1011    
	Mhead *hm, *hem; 
1991/1127    
	Crypt *cr; 
1990/0227    
 
1991/1127    
	/* 
	 * need to /dev/proc read protect crypt memory 
	 */ 
	cr = ialloc(conf.npgrp*sizeof(Crypt), 0); 
1990/1110    
	pgrpalloc.arena = ialloc(conf.npgrp*sizeof(Pgrp), 0); 
	pgrpalloc.free = pgrpalloc.arena; 
1990/0227    
 
1991/1113/sys/src/9/port/pgrp.c:49,541991/1127/sys/src/9/port/pgrp.c:54,60
1991/1011    
	for(i=0; i<conf.npgrp; i++,p++) { 
1990/1110    
		p->index = i; 
1990/0227    
		p->next = p+1; 
1991/1127    
		p->crypt = cr++; 
1990/0227    
	} 
1990/0825    
	p[-1].next = 0; 
1990/0227    
 
1991/1113/sys/src/9/port/pgrp.c:114,1191991/1127/sys/src/9/port/pgrp.c:120,126
1991/0705    
			pgrpalloc.free = p->next; 
			p->ref = 1; 
			p->pgrpid = ++pgrpalloc.pgrpid; 
1991/1127    
			memset(p->crypt, 0, sizeof *p->crypt); 
1991/0806    
			memset(p->rendhash, 0, sizeof(p->rendhash)); 
1991/1011    
			memset(p->mnthash, 0, sizeof(p->mnthash)); 
1991/0705    
			unlock(&pgrpalloc); 
1991/1113/sys/src/9/port/pgrp.c:318,3231991/1127/sys/src/9/port/pgrp.c:325,331
1991/0514    
 
1991/1011    
	rlock(&from->ns); 
 
1991/1127    
	*to->crypt = *from->crypt; 
1991/1011    
	e = &from->mnthash[MNTHASH]; 
1991/1113    
	tom = to->mnthash; 
1991/1011    
	for(h = from->mnthash; h < e; h++) { 
1991/1127/sys/src/9/port/pgrp.c:95,1031991/1216/sys/src/9/port/pgrp.c:95,103 (short | long)
1990/1110    
	p = proctab(0); 
1991/1112    
	for(i=0; i<conf.nproc; i++, p++) { 
		if(p->pgrp == pg && p->kp == 0) { 
1990/1110    
			lock(&p->debug); 
1991/1216    
			qlock(&p->debug); 
1990/1110    
			if(p->pid==0 || p->pgrp!=pg){ 
				unlock(&p->debug); 
1991/1216    
				qunlock(&p->debug); 
1990/1110    
				continue; 
			} 
1991/0125    
			if(!waserror()){ 
1991/1127/sys/src/9/port/pgrp.c:104,1101991/1216/sys/src/9/port/pgrp.c:104,110
1991/0125    
				postnote(p, 0, buf, flag); 
				poperror(); 
1990/1110    
			} 
			unlock(&p->debug); 
1991/1216    
			qunlock(&p->debug); 
1990/1110    
		} 
	} 
} 
1991/1216/sys/src/9/port/pgrp.c:88,951991/1231/sys/src/9/port/pgrp.c:88,93 (short | long)
1990/1110    
 
	if(n >= ERRLEN-1) 
1990/11211    
		error(Etoobig); 
1990/1110    
	if(n>=4 && strncmp(a, "sys:", 4)==0) 
1990/11211    
		error(Ebadarg); 
1991/0318    
	memmove(buf, a, n); 
1990/1110    
	buf[n] = 0; 
	p = proctab(0); 
1991/1231/sys/src/9/port/pgrp.c:3,91992/0111/sys/src/9/port/pgrp.c:3,9 (short | long)
Move error.h to ../port. Change errors to actual strings.
rsc Fri Mar 4 12:44:25 2005
1990/0227    
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
#include	"errno.h" 
1992/0111    
#include	"../port/error.h" 
1990/0227    
 
1991/0705    
struct 
{ 
1992/0111/sys/src/9/port/pgrp.c:5,171992/0128/sys/src/9/port/pgrp.c:5,11 (short | long)
1990/0227    
#include	"fns.h" 
1992/0111    
#include	"../port/error.h" 
1990/0227    
 
1991/0705    
struct 
{ 
1990/0227    
	Lock; 
1990/1110    
	Pgrp	*arena; 
1990/0227    
	Pgrp	*free; 
	ulong	pgrpid; 
}pgrpalloc; 
1992/0128    
Pgrps pgrpalloc; 
1990/0227    
 
1991/0705    
struct 
{ 
1992/0111/sys/src/9/port/pgrp.c:43,521992/0128/sys/src/9/port/pgrp.c:37,46
1991/1011    
	Mhead *hm, *hem; 
1991/1127    
	Crypt *cr; 
1990/0227    
 
1991/1127    
	/* 
	 * need to /dev/proc read protect crypt memory 
	 */ 
	cr = ialloc(conf.npgrp*sizeof(Crypt), 0); 
1992/0128    
	i = conf.npgrp*sizeof(Crypt); 
	cr = ialloc(i, 0); 
	pgrpalloc.cryptbase = (ulong)cr; 
	pgrpalloc.crypttop = (ulong)cr + i; 
1990/1110    
	pgrpalloc.arena = ialloc(conf.npgrp*sizeof(Pgrp), 0); 
	pgrpalloc.free = pgrpalloc.arena; 
1990/0227    
 
1992/0128/sys/src/9/port/pgrp.c:1,51992/0321/sys/src/9/port/pgrp.c:1,5 (short | long)
Move lib.h to ../port.
rsc Fri Mar 4 12:44:25 2005
1990/0227    
#include	"u.h" 
#include	"lib.h" 
1992/0321    
#include	"../port/lib.h" 
1990/0227    
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
Too many diffs (26 > 25). Stopping.


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)