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

1999/0122/port/devenv.c (diff list | history)

1998/0512/sys/src/9/port/devenv.c:28,381999/0122/sys/src/9/port/devenv.c:28,48 (short | long | prev | next)
1992/0623    
		return -1; 
1990/0227    
	} 
1992/0623    
 
	devdir(c, (Qid){e->path, 0}, e->name, e->len, eve, 0666, dp); 
1999/0122    
	devdir(c, e->qid, e->name, e->len, eve, 0666, dp); 
1992/0623    
	qunlock(eg); 
	return 1; 
1990/0227    
} 
 
1999/0122    
static Evalue* 
envlookup(Egrp *eg, char *name, ulong qidpath) 
{ 
	Evalue *e; 
	for(e = eg->entries; e; e = e->link) 
		if(e->qid.path == qidpath || (name && strcmp(e->name, name) == 0)) 
			return e; 
	return nil; 
} 
 
1997/0327    
static Chan* 
1990/0227    
envattach(char *spec) 
{ 
1998/0512/sys/src/9/port/devenv.c:48,531999/0122/sys/src/9/port/devenv.c:58,65
1997/0327    
static void 
1990/0227    
envstat(Chan *c, char *db) 
{ 
1999/0122    
	if(c->qid.path & CHDIR) 
		c->qid.vers = up->egrp->vers; 
1990/0227    
	devstat(c, db, 0, 0, envgen); 
} 
 
1998/0512/sys/src/9/port/devenv.c:64,781999/0122/sys/src/9/port/devenv.c:76,88
1992/0623    
	} 
	else { 
		qlock(eg); 
		for(e = eg->entries; e; e = e->link) 
			if(e->path == c->qid.path) 
				break; 
                 
1999/0122    
		e = envlookup(eg, nil, c->qid.path); 
1992/0623    
		if(e == 0) { 
			qunlock(eg); 
1991/1018    
			error(Enonexist); 
1990/0227    
		} 
1992/0623    
		if(omode == (OWRITE|OTRUNC) && e->value) { 
1999/0122    
		if((omode & OTRUNC) && e->value) { 
			e->qid.vers++; 
1992/0623    
			free(e->value); 
			e->value = 0; 
			e->len = 0; 
1998/0512/sys/src/9/port/devenv.c:103,1201999/0122/sys/src/9/port/devenv.c:113,131
1992/0623    
		nexterror(); 
1990/0227    
	} 
1992/0623    
 
	for(e = eg->entries; e; e = e->link) 
		if(strcmp(e->name, name) == 0) 
			error(Einuse); 
1999/0122    
	if(envlookup(eg, name, -1)) 
		error(Eexist); 
1992/0623    
 
	e = smalloc(sizeof(Evalue)); 
	e->name = smalloc(strlen(name)+1); 
	strcpy(e->name, name); 
 
	e->path = ++eg->path; 
1999/0122    
	e->qid.path = ++eg->path; 
	e->qid.vers = 0; 
	eg->vers++; 
1992/0623    
	e->link = eg->entries; 
	eg->entries = e; 
	c->qid = (Qid){e->path, 0}; 
1999/0122    
	c->qid = e->qid; 
1998/0512    
 
1992/0623    
	qunlock(eg); 
	poperror(); 
1998/0512/sys/src/9/port/devenv.c:135,1441999/0122/sys/src/9/port/devenv.c:146,154
1992/0623    
 
1993/0501    
	eg = up->egrp; 
1992/0623    
	qlock(eg); 
                 
	l = &eg->entries; 
	for(e = *l; e; e = e->link) { 
		if(e->path == c->qid.path) 
1999/0122    
		if(e->qid.path == c->qid.path) 
1992/0623    
			break; 
		l = &e->link; 
	} 
1998/0512/sys/src/9/port/devenv.c:149,1541999/0122/sys/src/9/port/devenv.c:159,165
1990/0227    
	} 
1992/0623    
 
	*l = e->link; 
1999/0122    
	eg->vers++; 
1992/0623    
	qunlock(eg); 
	free(e->name); 
	if(e->value) 
1998/0512/sys/src/9/port/devenv.c:157,1641999/0122/sys/src/9/port/devenv.c:168,182
1990/0227    
} 
 
1997/0327    
static void 
1995/0804    
envclose(Chan*) 
1999/0122    
envclose(Chan *c) 
1990/0227    
{ 
1999/0122    
	/* 
	 * close can't fail, so errors from remove will be ignored anyway. 
	 * since permissions aren't checked, 
	 * envremove can't not remove it if its there. 
	 */ 
	if(c->flag & CRCLOSE) 
		envremove(c); 
1991/1018    
} 
1990/0227    
 
1997/0327    
static long 
1998/0512/sys/src/9/port/devenv.c:173,1821999/0122/sys/src/9/port/devenv.c:191,197
1992/0623    
 
1993/0501    
	eg = up->egrp; 
1992/0623    
	qlock(eg); 
	for(e = eg->entries; e; e = e->link) 
		if(e->path == c->qid.path) 
			break; 
                 
1999/0122    
	e = envlookup(eg, nil, c->qid.path); 
1992/0623    
	if(e == 0) { 
		qunlock(eg); 
1991/1018    
		error(Enonexist); 
1998/0512/sys/src/9/port/devenv.c:210,2191999/0122/sys/src/9/port/devenv.c:225,231
1992/0623    
 
1993/0501    
	eg = up->egrp; 
1992/0623    
	qlock(eg); 
	for(e = eg->entries; e; e = e->link) 
		if(e->path == c->qid.path) 
			break; 
                 
1999/0122    
	e = envlookup(eg, nil, c->qid.path); 
1992/0623    
	if(e == 0) { 
		qunlock(eg); 
1991/1018    
		error(Enonexist); 
1998/0512/sys/src/9/port/devenv.c:228,2331999/0122/sys/src/9/port/devenv.c:240,247
1992/0623    
		e->len = vend; 
1991/1018    
	} 
1992/0623    
	memmove(e->value+offset, a, n); 
1999/0122    
	e->qid.vers++; 
	eg->vers++; 
1992/0623    
	qunlock(eg); 
	return n; 
1995/0108    
} 
1998/0512/sys/src/9/port/devenv.c:269,2751999/0122/sys/src/9/port/devenv.c:283,289
1992/0625    
			memmove(ne->value, e->value, e->len); 
			ne->len = e->len; 
		} 
		ne->path = ++to->path; 
1999/0122    
		ne->qid.path = ++to->path; 
1992/0625    
		*l = ne; 
		l = &ne->link; 
	} 


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