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

2002/0623/port/devcap.c (diff list | history)

2002/0622/sys/src/9/port/devcap.c:29,352002/0623/sys/src/9/port/devcap.c:29,34 (short | long | prev | next)
2001/0527    
struct 
{ 
	QLock; 
	int	opens; 
	Caphash	*first; 
	int	nhash; 
} capalloc; 
2002/0622/sys/src/9/port/devcap.c:41,532002/0623/sys/src/9/port/devcap.c:40,53
2001/0527    
	Quse, 
}; 
 
2002/0623    
/* caphash must be last */ 
2001/0527    
Dirtab capdir[] = 
{ 
	".",		{Qdir,0,QTDIR},	0,		DMDIR|0500, 
	"caphash",	{Qhash},	0,		0200, 
	"capuse",	{Quse},		0,		0222, 
2002/0623    
	"caphash",	{Qhash},	0,		0200, 
2001/0527    
}; 
#define NCAPDIR 3 
2002/0623    
int ncapdir = nelem(capdir); 
2001/0527    
 
static Chan* 
capattach(char *spec) 
2002/0622/sys/src/9/port/devcap.c:58,702002/0623/sys/src/9/port/devcap.c:58,80
2001/0527    
static Walkqid* 
capwalk(Chan *c, Chan *nc, char **name, int nname) 
{ 
	return devwalk(c, nc, name, nname, capdir, NCAPDIR, devgen); 
2002/0623    
	return devwalk(c, nc, name, nname, capdir, ncapdir, devgen); 
2001/0527    
} 
 
2002/0623    
static void 
capremove(Chan *c) 
{ 
	if(iseve() && c->qid.path == Qhash) 
		ncapdir = nelem(capdir)-1; 
	else 
		error(Eperm); 
} 
 
 
2001/0527    
static int 
capstat(Chan *c, uchar *db, int n) 
{ 
	return devstat(c, db, n, capdir, NCAPDIR, devgen); 
2002/0623    
	return devstat(c, db, n, capdir, ncapdir, devgen); 
2001/0527    
} 
 
/* 
2002/0622/sys/src/9/port/devcap.c:86,1052002/0623/sys/src/9/port/devcap.c:96,108
2001/0527    
		qunlock(&capalloc); 
		nexterror(); 
	} 
	qlock(&capalloc); 
	switch((ulong)c->qid.path){ 
	case Qhash: 
2002/0622    
		if(!iseve()) 
			error(Eperm); 
2001/0527    
		if(capalloc.opens > 0){ 
			qunlock(&capalloc); 
			error("exclusive use"); 
		} 
		capalloc.opens++; 
		break; 
	} 
	poperror(); 
	qunlock(&capalloc); 
 
	c->mode = openmode(omode); 
	c->flag |= COPEN; 
2002/0622/sys/src/9/port/devcap.c:164,1772002/0623/sys/src/9/port/devcap.c:167,174
2001/0527    
} 
 
static void 
capclose(Chan *c) 
2002/0623    
capclose(Chan*) 
2001/0527    
{ 
	if(c->flag & COPEN) 
		if(c->qid.path == Qhash){ 
			qlock(&capalloc); 
			capalloc.opens--; 
			qunlock(&capalloc); 
		} 
} 
 
static long 
2002/0622/sys/src/9/port/devcap.c:179,1852002/0623/sys/src/9/port/devcap.c:176,182
2001/0527    
{ 
	switch((ulong)c->qid.path){ 
	case Qdir: 
		return devdirread(c, va, n, capdir, nelem(capdir), devgen); 
2002/0623    
		return devdirread(c, va, n, capdir, ncapdir, devgen); 
2001/0527    
 
	default: 
		error(Eperm); 
2002/0622/sys/src/9/port/devcap.c:258,2792002/0623/sys/src/9/port/devcap.c:255,276
2001/0527    
} 
 
Dev capdevtab = { 
	L'¤', 
	"cap", 
2002/0623    
.dc=		L'¤', 
.name=		"cap", 
2001/0527    
 
	devreset, 
	devinit, 
2002/0109    
	devshutdown, 
2001/0527    
	capattach, 
	capwalk, 
	capstat, 
	capopen, 
	devcreate, 
	capclose, 
	capread, 
	devbread, 
	capwrite, 
	devbwrite, 
	devremove, 
	devwstat, 
2002/0623    
.reset=		devreset, 
.init=		devinit, 
.shutdown=	devshutdown, 
.attach=	capattach, 
.walk=		capwalk, 
.stat=		capstat, 
.open=		capopen, 
.create=	devcreate, 
.close=		capclose, 
.read=		capread, 
.bread=		devbread, 
.write=		capwrite, 
.bwrite=	devbwrite, 
.remove=	capremove, 
.wstat=		devwstat, 
2001/0527    
}; 


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