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

1991/0411/port/sysfile.c (diff list | history)

1991/0319/sys/src/9/port/sysfile.c:191,1971991/0411/sys/src/9/port/sysfile.c:191,197 (short | long | prev | next)
Bug fix: add explicit read lock and write lock instead of using channel's qlock. This way a process can write even if another process is blocked doing a read. Add explicit offset to dev read and write to accomodate this.
rsc Fri Mar 4 17:11:43 2005
1990/0227    
	} 
	nc = (*devtab[nc->type].open)(nc, OREAD); 
	nc->offset = c->offset; 
	nr = (*devtab[nc->type].read)(nc, va, n); 
1991/0411    
	nr = (*devtab[nc->type].read)(nc, va, n, nc->offset); 
1990/0821    
	c->offset = nc->offset;		/* devdirread e.g. changes it */ 
1990/0227    
	close(nc); 
	poperror(); 
1991/0319/sys/src/9/port/sysfile.c:226,2341991/0411/sys/src/9/port/sysfile.c:226,234
1990/0227    
 
1990/1009    
	c = fdtochan(arg[0], OREAD); 
1990/1004    
	validaddr(arg[1], arg[2], 1); 
1990/0227    
	qlock(c); 
1991/0411    
	qlock(&c->rdl); 
1990/0227    
	if(waserror()){ 
		qunlock(c); 
1991/0411    
		qunlock(&c->rdl); 
1990/0227    
		nexterror(); 
	} 
	n = arg[2]; 
1991/0319/sys/src/9/port/sysfile.c:240,2481991/0411/sys/src/9/port/sysfile.c:240,248
1990/11211    
	if((c->qid.path&CHDIR) && (c->flag&CMOUNT)) 
1990/0227    
		n = unionread(c, (void*)arg[1], n); 
	else 
		n = (*devtab[c->type].read)(c, (void*)arg[1], n); 
1991/0411    
		n = (*devtab[c->type].read)(c, (void*)arg[1], n, c->offset); 
1990/0227    
	c->offset += n; 
	qunlock(c); 
1991/0411    
	qunlock(&c->rdl); 
1990/0227    
	return n; 
} 
 
1991/0319/sys/src/9/port/sysfile.c:254,2691991/0411/sys/src/9/port/sysfile.c:254,269
1990/0227    
 
1990/1009    
	c = fdtochan(arg[0], OWRITE); 
1990/0227    
	validaddr(arg[1], arg[2], 0); 
	qlock(c); 
1991/0411    
	qlock(&c->wrl); 
1990/0227    
	if(waserror()){ 
		qunlock(c); 
1991/0411    
		qunlock(&c->wrl); 
1990/0227    
		nexterror(); 
	} 
1990/11211    
	if(c->qid.path & CHDIR) 
		error(Eisdir); 
1990/0227    
	n = (*devtab[c->type].write)(c, (void*)arg[1], arg[2]); 
1991/0411    
	n = (*devtab[c->type].write)(c, (void*)arg[1], arg[2], c->offset); 
1990/0227    
	c->offset += n; 
	qunlock(c); 
1991/0411    
	qunlock(&c->wrl); 
1990/0227    
	return n; 
} 
 
1991/0319/sys/src/9/port/sysfile.c:280,2881991/0411/sys/src/9/port/sysfile.c:280,290
1990/11211    
		error(Eisdir); 
1991/0319    
	if(devchar[c->type] == '|') 
		error(Eisstream); 
1990/0227    
	qlock(c); 
1991/0411    
	qlock(&c->rdl); 
	qlock(&c->wrl); 
1990/0227    
	if(waserror()){ 
		qunlock(c); 
1991/0411    
		qunlock(&c->rdl); 
		qunlock(&c->wrl); 
1990/0227    
		nexterror(); 
	} 
	switch(arg[2]){ 
1991/0319/sys/src/9/port/sysfile.c:301,3071991/0411/sys/src/9/port/sysfile.c:303,310
1990/0227    
		break; 
	} 
	off = c->offset; 
	qunlock(c); 
1991/0411    
	qunlock(&c->rdl); 
	qunlock(&c->wrl); 
1990/0227    
	poperror(); 
	return off; 
} 


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