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

1998/0829/port/sysfile.c (diff list | history)

1998/0512/sys/src/9/port/sysfile.c:279,3061998/0829/sys/src/9/port/sysfile.c:279,304 (short | long | prev | next)
1990/0227    
long 
unionread(Chan *c, void *va, long n) 
{ 
1998/0829    
	int i; 
1990/0227    
	long nr; 
1992/0720    
	Chan *nc; 
	Pgrp *pg; 
1998/0829    
	Mhead *m; 
	Mount *mount; 
1990/0227    
 
1993/0501    
	pg = up->pgrp; 
1993/0318    
	rlock(&pg->ns); 
1998/0829    
	m = c->mh; 
	rlock(&m->lock); 
	mount = m->mount; 
	for(i = 0; mount != nil && i < c->uri; i++) 
		mount = mount->next; 
1991/1011    
 
	for(;;) { 
		if(waserror()) { 
1993/0318    
			runlock(&pg->ns); 
1998/0829    
			runlock(&m->lock); 
1991/1011    
			nexterror(); 
		} 
1997/0327    
		nc = cclone(c->mnt->to, 0); 
1998/0829    
		nc = cclone(mount->to, 0); 
1991/1011    
		poperror(); 
 
1992/0720    
		if(c->mountid != c->mnt->mountid) { 
1993/0318    
			pprint("unionread: changed underfoot?\n"); 
			runlock(&pg->ns); 
1997/0327    
			cclose(nc); 
1991/1011    
			return 0; 
		} 
                 
1993/0318    
		/* Error causes component of union to be skipped */ 
1998/0512    
		if(waserror()) { 
1997/0327    
			cclose(nc); 
1998/0512/sys/src/9/port/sysfile.c:316,3331998/0829/sys/src/9/port/sysfile.c:314,331
1991/1011    
 
1997/0327    
		cclose(nc); 
1991/1011    
		if(nr > 0) { 
1993/0318    
			runlock(&pg->ns); 
1998/0829    
			runlock(&m->lock); 
1991/1011    
			return nr; 
		} 
1992/0720    
		/* Advance to next element */ 
	next: 
1993/0318    
		c->mnt = c->mnt->next; 
1991/1011    
		if(c->mnt == 0) 
1998/0829    
		c->uri++; 
		mount = mount->next; 
		if(mount == nil) 
1991/1011    
			break; 
		c->mountid = c->mnt->mountid; 
		c->offset = 0; 
1990/0227    
	} 
1993/0318    
	runlock(&pg->ns); 
1998/0829    
	runlock(&m->lock); 
1991/1011    
	return 0; 
1990/0227    
} 
 
1998/0512/sys/src/9/port/sysfile.c:354,3601998/0829/sys/src/9/port/sysfile.c:352,358
1994/0405    
			error(Etoosmall); 
	} 
 
	if(dir && c->mnt) 
1998/0829    
	if(dir && c->mh) 
1994/0405    
		n = unionread(c, (void*)arg[1], n); 
1997/0408    
	else if(devtab[c->type]->dc != L'M') 
1997/0327    
		n = devtab[c->type]->read(c, (void*)arg[1], n, c->offset); 
1998/0512/sys/src/9/port/sysfile.c:394,4001998/0829/sys/src/9/port/sysfile.c:392,398
1992/0114    
			error(Etoosmall); 
1990/0227    
	} 
1992/0825    
 
	if(dir && c->mnt) 
1998/0829    
	if(dir && c->mh) 
1990/0227    
		n = unionread(c, (void*)arg[1], n); 
	else 
1997/0327    
		n = devtab[c->type]->read(c, (void*)arg[1], n, c->offset); 
1998/0512/sys/src/9/port/sysfile.c:514,5191998/0829/sys/src/9/port/sysfile.c:512,518
1990/0227    
		break; 
	} 
1998/0326    
	*(vlong*)arg[0] = off; 
1998/0829    
	c->uri = 0; 
1998/0403    
	cclose(c); 
	poperror(); 
1998/0319    
} 


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