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

1990/0820/port/chan.c (diff list | history)

1990/08141/sys/src/9/port/chan.c:340,3461990/0820/sys/src/9/port/chan.c:340,346 (short | long | prev | next)
1990/0227    
			goto Notfound; 
		} 
		if(c->mountid != mnt->mountid){ 
1990/0321    
			pprint("walk: changed underfoot?\n"); 
1990/0820    
			pprint("walk: changed underfoot? '%s'\n", name); 
1990/0227    
			unlock(pg); 
			goto Notfound; 
		} 
1990/08141/sys/src/9/port/chan.c:431,4421990/0820/sys/src/9/port/chan.c:431,443
1990/0227    
{ 
	Chan *c, *nc; 
	int t; 
	int mntok; 
1990/0820    
	int mntok, isdot; 
1990/0227    
	char *elem = u->elem; 
 
	if(name[0] == 0) 
		error(0, Enonexist); 
	mntok = 1; 
1990/0820    
	isdot = 0; 
1990/0227    
	if(name[0] == '/'){ 
		c = clone(u->slash, 0); 
		/* 
1990/08141/sys/src/9/port/chan.c:459,4661990/0820/sys/src/9/port/chan.c:460,471
1990/0227    
		}else 
			name = nextelem(name, elem); 
		c = (*devtab[t].attach)(elem); 
	}else 
1990/0820    
	}else{ 
1990/0227    
		c = clone(u->dot, 0); 
1990/0820    
		name = skipslash(name);	/* eat leading ./ */ 
		if(*name == 0) 
			isdot = 1; 
	} 
1990/0227    
 
	if(waserror()){ 
		close(c); 
1990/08141/sys/src/9/port/chan.c:468,4751990/0820/sys/src/9/port/chan.c:473,481
1990/0227    
	} 
 
	name = nextelem(name, elem); 
	if(mntok) 
	if(!(amode==Amount && elem[0]==0))	/* don't domount on dot or slash */ 
1990/0820    
 
	if(mntok && !isdot) 
	if(!(amode==Amount && elem[0]==0))	/* don't domount on slash */ 
1990/0227    
		c = domount(c);			/* see case Atodir below */ 
 
	/* 
1990/08141/sys/src/9/port/chan.c:482,4871990/0820/sys/src/9/port/chan.c:488,494
1990/0227    
		c = nc; 
		name = nextelem(name, elem); 
	} 
1990/0820    
 
1990/0227    
	/* 
	 * Last element; act according to type of access. 
	 */ 
1990/08141/sys/src/9/port/chan.c:488,4961990/0820/sys/src/9/port/chan.c:495,507
1990/0227    
 
	switch(amode){ 
	case Aaccess: 
1990/0515    
		if((nc=walk(c, elem, mntok)) == 0) 
1990/0227    
			error(0, Enonexist); 
		c = nc; 
1990/0820    
		if(isdot) 
			c = domount(c); 
		else{ 
			if((nc=walk(c, elem, mntok)) == 0) 
				error(0, Enonexist); 
			c = nc; 
		} 
1990/0227    
		break; 
 
	case Atodir: 
1990/08141/sys/src/9/port/chan.c:506,5141990/0820/sys/src/9/port/chan.c:517,529
1990/0227    
		break; 
 
	case Aopen: 
		if((nc=walk(c, elem, mntok)) == 0) 
			error(0, Enonexist); 
		c = nc; 
1990/0820    
		if(isdot) 
			c = domount(c); 
		else{ 
			if((nc=walk(c, elem, mntok)) == 0) 
				error(0, Enonexist); 
			c = nc; 
		} 
1990/0227    
	Open: 
		c = (*devtab[c->type].open)(c, omode); 
1990/08141    
		if(omode & OCEXEC) 
1990/08141/sys/src/9/port/chan.c:527,5321990/0820/sys/src/9/port/chan.c:542,549
1990/0227    
		break; 
 
	case Acreate: 
1990/0820    
		if(isdot) 
			error(0, Eisdir); 
1990/0227    
		if((nc=walk(c, elem, 1)) != 0){ 
			c = nc; 
			omode |= OTRUNC; 
1990/08141/sys/src/9/port/chan.c:552,5611990/0820/sys/src/9/port/chan.c:569,587
1990/0227    
char* 
skipslash(char *name) 
{ 
1990/0820    
    Again: 
1990/0227    
	while(*name == '/'){ 
		if(((ulong)name&KZERO)==0 && (((ulong)name+1)&(BY2PG-1))==0) 
			validaddr((ulong)name+1, 1, 0); 
		name++; 
1990/0820    
	} 
	if(*name == '.'){ 
		if(((ulong)name&KZERO)==0 && (((ulong)name+1)&(BY2PG-1))==0) 
			validaddr((ulong)name+1, 1, 0); 
		if(name[1]==0 || name[1]=='/'){ 
			name++; 
			goto Again; 
		} 
1990/0227    
	} 
	return name; 
} 


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