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

1990/0821/gnot/dev.c (diff list | history)

1990/0821/sys/src/9/gnot/dev.c:4,101990/11211/sys/src/9/gnot/dev.c:4,9 (short | long | prev | next)
1990/03091    
#include	"dat.h" 
#include	"fns.h" 
#include	"errno.h" 
                 
#define	DEVTAB 
#include	"devtab.h" 
 
1990/0821/sys/src/9/gnot/dev.c:25,371990/11211/sys/src/9/gnot/dev.c:24,36
1990/03091    
} 
 
void 
devdir(Chan *c, long qid, char *n, long length, long perm, Dir *db) 
1990/11211    
devdir(Chan *c, Qid qid, char *n, long length, long perm, Dir *db) 
1990/03091    
{ 
	strcpy(db->name, n); 
	db->qid = qid; 
	db->type = devchar[c->type]; 
	db->dev = c->dev; 
	if(qid & CHDIR) 
1990/11211    
	if(qid.path & CHDIR) 
1990/03091    
		db->mode = CHDIR|perm; 
	else 
		db->mode = perm; 
1990/0821/sys/src/9/gnot/dev.c:39,461990/11211/sys/src/9/gnot/dev.c:38,45
1990/03091    
	db->mtime = db->atime; 
	db->hlength = 0; 
	db->length = length; 
	db->uid = 0; 
	db->gid = 0; 
1990/11211    
	memcpy(db->uid, user, NAMELEN); 
	memcpy(db->gid, user, NAMELEN); 
1990/03091    
} 
 
int 
1990/0821/sys/src/9/gnot/dev.c:59,651990/11211/sys/src/9/gnot/dev.c:58,64
1990/03091    
	Chan *c; 
 
	c = newchan(); 
	c->qid = CHDIR; 
1990/11211    
	c->qid = (Qid){CHDIR, 0}; 
1990/03091    
	c->type = devno(tc, 0); 
	return c; 
} 
1990/0821/sys/src/9/gnot/dev.c:95,1031990/11211/sys/src/9/gnot/dev.c:94,100
1990/03091    
	for(i=0;; i++) 
		switch((*gen)(c, tab, ntab, i, &dir)){ 
		case -1: 
			u->error.type = 0; 
			u->error.dev = 0; 
			u->error.code = Enonexist; 
1990/11211    
			strncpy(u->error, errstrtab[Enonexist], NAMELEN); 
1990/03091    
			return 0; 
		case 0: 
			continue; 
1990/0821/sys/src/9/gnot/dev.c:123,1291990/11211/sys/src/9/gnot/dev.c:120,126
1990/03091    
			 * devices with interesting directories usually don't get 
			 * here, which is good because we've lost the name by now. 
			 */ 
			if(c->qid & CHDIR){ 
1990/11211    
			if(c->qid.path & CHDIR){ 
1990/03091    
				devdir(c, c->qid, ".", 0L, CHDIR|0700, &dir); 
				convD2M(&dir, db); 
				return; 
1990/0821/sys/src/9/gnot/dev.c:132,1381990/11211/sys/src/9/gnot/dev.c:129,135
1990/03091    
		case 0: 
			break; 
		case 1: 
			if(c->qid == dir.qid){ 
1990/11211    
			if(eqqid(c->qid, dir.qid)){ 
1990/03091    
				convD2M(&dir, db); 
				return; 
			} 
1990/0821/sys/src/9/gnot/dev.c:180,1961990/11211/sys/src/9/gnot/dev.c:177,193
1990/03091    
		case 0: 
			break; 
		case 1: 
			if(c->qid == dir.qid){ 
1990/11211    
			if(eqqid(c->qid, dir.qid)){ 
1990/03091    
				if((access[omode&3] & dir.mode) == access[omode&3]) 
					goto Return; 
				error(0, Eperm); 
1990/11211    
				error(Eperm); 
1990/03091    
			} 
			break; 
		} 
    Return: 
	c->offset = 0; 
	if((c->qid&CHDIR) && omode!=OREAD) 
		error(0, Eperm); 
1990/11211    
	if((c->qid.path&CHDIR) && omode!=OREAD) 
		error(Eperm); 
1990/03091    
	c->mode = openmode(omode); 
	c->flag |= COPEN; 
	return c; 


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