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

1994/0613/port/pgrp.c (diff list | history)

1993/1115/sys/src/9/port/pgrp.c:74,911994/0613/sys/src/9/port/pgrp.c:74,115 (short | long | prev | next)
1990/0227    
} 
 
1991/0705    
void 
1994/0613    
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 
1991/0514    
pgrpcpy(Pgrp *to, Pgrp *from) 
{ 
1991/1113    
	Mhead **h, **e, *f, **tom, **l, *mh; 
1991/1011    
	Mount *n, *m, **link; 
1994/0613    
	int i; 
	Mount *n, *m, **link, *order; 
	Mhead *f, **tom, **l, *mh; 
1991/0514    
 
1991/1011    
	rlock(&from->ns); 
                 
	e = &from->mnthash[MNTHASH]; 
1994/0613    
	order = 0; 
1991/1113    
	tom = to->mnthash; 
1991/1011    
	for(h = from->mnthash; h < e; h++) { 
1994/0613    
	for(i = 0; i < MNTHASH; i++) { 
1991/1113    
		l = tom++; 
1991/1011    
		for(f = *h; f; f = f->hash) { 
1994/0613    
		for(f = from->mnthash[i]; f; f = f->hash) { 
1992/0619    
			mh = smalloc(sizeof(Mhead)); 
1991/1011    
			mh->from = f->from; 
			incref(mh->from); 
1993/1115/sys/src/9/port/pgrp.c:93,1041994/0613/sys/src/9/port/pgrp.c:117,143
1991/1113    
			l = &mh->hash; 
1991/1011    
			link = &mh->mount; 
			for(m = f->mount; m; m = m->next) { 
1993/0501    
				n = newmount(mh, m->to, m->flag, m->spec); 
1994/0613    
				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); 
1991/1011    
				*link = n; 
				link = &n->next;	 
			} 
1991/0514    
		} 
1991/1011    
	} 
1994/0613    
	/* 
	 * 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); 
1991/1011    
	runlock(&from->ns); 
} 
1991/0514    
 


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