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

1993/0330/port/dev.c (diff list | history)

1993/0330/sys/src/9/port/dev.c:65,751993/0501/sys/src/9/port/dev.c:65,80 (short | long | prev | next)
Convert to Brazil: add Path, up, format edits. Directory mode back to 0700.
rsc Fri Mar 4 12:44:25 2005
1990/0227    
devattach(int tc, char *spec) 
{ 
	Chan *c; 
1993/0501    
	char buf[NAMELEN+4]; 
1990/0227    
 
1992/0711    
	USED(spec); 
1990/0227    
	c = newchan(); 
1990/11211    
	c->qid = (Qid){CHDIR, 0}; 
1990/0227    
	c->type = devno(tc, 0); 
1993/0501    
	if(tc != 'M') { 
		sprint(buf, "#%C%s", tc, spec); 
		c->path = ptenter(&syspt, 0, buf); 
	} 
1990/0227    
	return c; 
} 
 
1993/0330/sys/src/9/port/dev.c:78,851993/0501/sys/src/9/port/dev.c:83,92
1990/0227    
{ 
1990/0329    
	if(c->flag & COPEN) 
1992/1217    
		panic("clone of open file type %C\n", devchar[c->type]); 
1993/0501    
 
1990/0227    
	if(nc == 0) 
		nc = newchan(); 
1993/0501    
 
1990/0227    
	nc->type = c->type; 
1991/0421    
	nc->dev = c->dev; 
1990/0227    
	nc->mode = c->mode; 
1993/0330/sys/src/9/port/dev.c:91,961993/0501/sys/src/9/port/dev.c:98,105
1991/0421    
	nc->aux = c->aux; 
1990/0303    
	nc->mchan = c->mchan; 
	nc->mqid = c->mqid; 
1993/0501    
	nc->path = c->path; 
	incref(nc->path); 
1990/0227    
	return nc; 
} 
 
1993/0330/sys/src/9/port/dev.c:99,1121993/0501/sys/src/9/port/dev.c:108,122
1990/0227    
{ 
	long i; 
	Dir dir; 
1993/0501    
	Path *op; 
1990/0227    
 
	isdir(c); 
	if(name[0]=='.' && name[1]==0) 
		return 1; 
	for(i=0;; i++) 
1993/0501    
	for(i=0;; i++) { 
1990/0227    
		switch((*gen)(c, tab, ntab, i, &dir)){ 
		case -1: 
1992/0111    
			strncpy(u->error, Enonexist, NAMELEN); 
1993/0501    
			strncpy(up->error, Enonexist, NAMELEN); 
1990/0227    
			return 0; 
		case 0: 
			continue; 
1993/0330/sys/src/9/port/dev.c:113,1231993/0501/sys/src/9/port/dev.c:123,137
1990/0227    
		case 1: 
			if(strcmp(name, dir.name) == 0){ 
				c->qid = dir.qid; 
1993/0501    
				op = c->path; 
				c->path = ptenter(&syspt, op, name); 
				decref(op); 
1990/0227    
				return 1; 
			} 
			continue; 
		} 
1992/0520    
	return 1;	/* not reached */ 
1993/0501    
	} 
	return 0;	/* not reached */ 
1991/0411    
} 
 
1990/0227    
void 
1993/0330/sys/src/9/port/dev.c:129,1511993/0501/sys/src/9/port/dev.c:143,165
1993/0330    
	for(i=0;; i++) 
1990/0227    
		switch((*gen)(c, tab, ntab, i, &dir)){ 
		case -1: 
			/* 
1991/1206    
			 *  given a channel, we cannot derive the directory name 
			 *  that the channel was generated from since it was lost 
			 *  by namec. 
1990/0227    
			 */ 
1993/0501    
		/* 
		 *  given a channel, we cannot derive the directory name 
		 *  that the channel was generated from since it was lost 
		 *  by namec. 
		 */ 
1990/11211    
			if(c->qid.path & CHDIR){ 
1993/0330    
				devdir(c, c->qid, ".", 0L, eve, CHDIR|0775, &dir); 
1993/0501    
				devdir(c, c->qid, c->path->elem, i*DIRLEN, eve, CHDIR|0700, &dir); 
1990/0227    
				convD2M(&dir, db); 
				return; 
			} 
1992/1217    
			print("%s %s: devstat %C %lux\n", u->p->text, u->p->user, 
1993/0330    
							devchar[c->type], c->qid.path); 
1993/0501    
			print("%s %s: devstat %C %lux\n", up->text, up->user, 
						devchar[c->type], c->qid.path); 
1991/0626    
			error(Enonexist); 
1993/0330    
		case 0: 
			break; 
1990/0227    
		case 1: 
1993/0330    
			if(eqqid(c->qid, dir.qid)){ 
1993/0501    
			if(eqqid(c->qid, dir.qid)) { 
1993/0323    
				if(c->flag&CMSG) 
					dir.mode |= CHMOUNT; 
1990/0227    
				convD2M(&dir, db); 
1993/0330/sys/src/9/port/dev.c:162,1681993/0501/sys/src/9/port/dev.c:176,182
1990/0227    
	Dir dir; 
 
	k = c->offset/DIRLEN; 
1990/0821    
	for(m=0; m<n; k++) 
1993/0501    
	for(m=0; m<n; k++) { 
1990/0227    
		switch((*gen)(c, tab, ntab, k, &dir)){ 
		case -1: 
1990/0821    
			return m; 
1993/0330/sys/src/9/port/dev.c:177,1821993/0501/sys/src/9/port/dev.c:191,198
1990/0227    
			d += DIRLEN; 
			break; 
		} 
1993/0501    
	} 
 
1990/0821    
	return m; 
1990/0227    
} 
 
1993/0330/sys/src/9/port/dev.c:188,1941993/0501/sys/src/9/port/dev.c:204,210
1991/1112    
	ulong t, mode; 
1990/0227    
	static int access[] = { 0400, 0200, 0600, 0100 }; 
 
	for(i=0;; i++) 
1993/0501    
	for(i=0;; i++) { 
1990/0227    
		switch((*gen)(c, tab, ntab, i, &dir)){ 
		case -1: 
			goto Return; 
1993/0330/sys/src/9/port/dev.c:196,2071993/0501/sys/src/9/port/dev.c:212,224
1990/0227    
			break; 
		case 1: 
1991/1112    
			if(eqqid(c->qid, dir.qid)) { 
				if(strcmp(u->p->user, dir.uid) == 0)	/* User */ 
1993/0501    
				if(strcmp(up->user, dir.uid) == 0) 
1991/1112    
					mode = dir.mode; 
1991/1206    
				else if(strcmp(u->p->user, eve) == 0)	/* eve is group */ 
1993/0501    
				else 
				if(strcmp(up->user, eve) == 0) 
1991/1112    
					mode = dir.mode<<3; 
				else 
					mode = dir.mode<<6;		/* Other */ 
1993/0501    
					mode = dir.mode<<6; 
1991/1112    
 
				t = access[omode&3]; 
				if((t & mode) == t) 
1993/0330/sys/src/9/port/dev.c:210,2161993/0501/sys/src/9/port/dev.c:227,234
1990/0227    
			} 
			break; 
		} 
    Return: 
1993/0501    
	} 
Return: 
1990/0227    
	c->offset = 0; 
1990/11211    
	if((c->qid.path&CHDIR) && omode!=OREAD) 
		error(Eperm); 


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