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

1990/0617/gnot/fault.c (diff list | history)

1990/0614/sys/src/9/gnot/fault.c:280,2981990/0617/sys/src/9/gnot/fault.c:280,305 (short | long | prev | next)
1990/03091    
void 
validaddr(ulong addr, ulong len, int write) 
{ 
	Seg *s; 
1990/0617    
	Seg *s, *ns; 
1990/03091    
 
	if((long)len < 0) 
1990/0312    
		goto Err; 
1990/03091    
	s = seg(u->p, addr); 
	if(s==0 || addr+len>s->maxva || (write && (s->o->flag&OWRPERM)==0)){ 
1990/0617    
	if((long)len < 0){ 
1990/0312    
    Err: 
1990/03091    
		pprint("invalid address in sys call pc %lux sp %lux\n", ((Ureg*)UREGADDR)->pc, ((Ureg*)UREGADDR)->sp); 
		postnote(u->p, 1, "bad address", NDebug); 
		error(0, Ebadarg); 
	} 
1990/0617    
    Again: 
	s = seg(u->p, addr); 
	if(s==0) 
		goto Err; 
	if(write && (s->o->flag&OWRPERM)==0) 
		goto Err; 
	if(addr+len > s->maxva){ 
		len -= s->maxva - addr; 
		addr = s->maxva; 
		goto Again; 
	} 
1990/03091    
} 
                 
/* 
 * &s[0] is known to be a valid address. 
 */ 


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