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

1990/11211/port/devpipe.c (diff list | history)

1990/1118/sys/src/9/port/devpipe.c:37,461990/11211/sys/src/9/port/devpipe.c:37,46 (short | long | prev | next)
1990/1113    
}; 
1990/0227    
 
1990/1009    
Dirtab pipedir[]={ 
	"data",		Sdataqid,	0,			0600, 
	"ctl",		Sctlqid,	0,			0600, 
	"data1",	Sdataqid,	0,			0600, 
	"ctl1",		Sctlqid,	0,			0600, 
1990/11211    
	"data",		{Sdataqid},	0,			0600, 
	"ctl",		{Sctlqid},	0,			0600, 
	"data1",	{Sdataqid},	0,			0600, 
	"ctl1",		{Sctlqid},	0,			0600, 
1990/1009    
}; 
#define NPIPEDIR 4 
 
1990/1118/sys/src/9/port/devpipe.c:78,841990/11211/sys/src/9/port/devpipe.c:78,84
1990/1009    
	lock(&pipealloc); 
	if(pipealloc.free == 0){ 
		unlock(&pipealloc); 
		error(0, Enopipe); 
1990/11211    
		error(Enopipe); 
1990/1009    
	} 
	p = pipealloc.free; 
	pipealloc.free = p->next; 
1990/1118/sys/src/9/port/devpipe.c:86,921990/11211/sys/src/9/port/devpipe.c:86,92
1990/1013    
		panic("pipeattach"); 
1990/1009    
	unlock(&pipealloc); 
 
	c->qid = CHDIR|STREAMQID(2*(p - pipealloc.pipe), 0); 
1990/11211    
	c->qid = (Qid){CHDIR|STREAMQID(2*(p - pipealloc.pipe), 0), 0}; 
1990/0227    
	return c; 
} 
 
1990/1118/sys/src/9/port/devpipe.c:95,1011990/11211/sys/src/9/port/devpipe.c:95,101
1990/0227    
{ 
1990/1009    
	Pipe *p; 
 
	p = &pipealloc.pipe[STREAMID(c->qid)/2]; 
1990/11211    
	p = &pipealloc.pipe[STREAMID(c->qid.path)/2]; 
1990/0227    
	nc = devclone(c, nc); 
1990/1013    
	if(incref(p) <= 1) 
		panic("pipeclone"); 
1990/1118/sys/src/9/port/devpipe.c:107,1191990/11211/sys/src/9/port/devpipe.c:107,119
1990/1009    
{ 
	int id; 
1990/0629    
 
1990/1009    
	id = STREAMID(c->qid); 
1990/11211    
	id = STREAMID(c->qid.path); 
1990/1009    
	if(i > 1) 
		id++; 
	if(tab==0 || i>=ntab) 
		return -1; 
	tab += i; 
	devdir(c, STREAMQID(id, tab->qid), tab->name, tab->length, tab->perm, dp); 
1990/11211    
	devdir(c, (Qid){STREAMQID(id, tab->qid.path),0}, tab->name, tab->length, tab->perm, dp); 
1990/1009    
	return 1; 
1990/0227    
} 
 
1990/1118/sys/src/9/port/devpipe.c:139,1471990/11211/sys/src/9/port/devpipe.c:139,147
1990/1009    
	Pipe *p; 
	Stream *local, *remote; 
 
	if(CHDIR & c->qid){ 
1990/11211    
	if(c->qid.path & CHDIR){ 
1990/1009    
		if(omode != OREAD) 
			error(0, Ebadarg); 
1990/11211    
			error(Ebadarg); 
1990/1009    
		c->mode = omode; 
		c->flag |= COPEN; 
		c->offset = 0; 
1990/1118/sys/src/9/port/devpipe.c:148,1541990/11211/sys/src/9/port/devpipe.c:148,154
1990/1009    
		return c; 
	} 
 
	p = &pipealloc.pipe[STREAMID(c->qid)/2]; 
1990/11211    
	p = &pipealloc.pipe[STREAMID(c->qid.path)/2]; 
1990/1009    
	remote = 0; 
	if(waserror()){ 
		unlock(p); 
1990/1118/sys/src/9/port/devpipe.c:163,1691990/11211/sys/src/9/port/devpipe.c:163,169
1990/1009    
		/* 
		 *  First stream opened, create the other end also 
		 */ 
		remote = streamnew(c->type, c->dev, STREAMID(c->qid)^1, &pipeinfo, 1); 
1990/11211    
		remote = streamnew(c->type, c->dev, STREAMID(c->qid.path)^1, &pipeinfo, 1); 
1990/1009    
 
		/* 
		 *  connect the device ends of both streams 
1990/1118/sys/src/9/port/devpipe.c:192,2101990/11211/sys/src/9/port/devpipe.c:192,210
1990/0227    
void 
pipecreate(Chan *c, char *name, int omode, ulong perm) 
{ 
	error(0, Egreg); 
1990/11211    
	error(Egreg); 
1990/0227    
} 
 
void 
piperemove(Chan *c) 
{ 
	error(0, Egreg); 
1990/11211    
	error(Egreg); 
1990/0227    
} 
 
void 
pipewstat(Chan *c, char *db) 
{ 
1990/0617    
	error(0, Eperm); 
1990/11211    
	error(Eperm); 
1990/0227    
} 
 
void 
1990/1118/sys/src/9/port/devpipe.c:211,2241990/11211/sys/src/9/port/devpipe.c:211,228
1990/0227    
pipeclose(Chan *c) 
{ 
1990/1009    
	Pipe *p; 
1990/11211    
	Stream *remote; 
1990/0629    
 
1990/1009    
	p = &pipealloc.pipe[STREAMID(c->qid)/2]; 
1990/11211    
	p = &pipealloc.pipe[STREAMID(c->qid.path)/2]; 
1990/0629    
 
1990/1009    
	/* 
1990/1011    
	 *  take care of associated streams 
1990/1009    
	 */ 
1990/1118    
	if(c->stream) 
1990/1009    
		streamclose(c);		/* close this stream */ 
1990/11211    
	if(c->stream){ 
		remote = c->stream->devq->ptr; 
		if(streamclose(c) <= 0) 
			streamexit(remote, 0); 
	} 
1990/11161    
 
	/* 
	 *  free the structure 
1990/1118/sys/src/9/port/devpipe.c:236,2421990/11211/sys/src/9/port/devpipe.c:240,246
1990/0227    
long 
piperead(Chan *c, void *va, long n) 
{ 
1990/1009    
	if(CHDIR&c->qid) 
1990/11211    
	if(c->qid.path & CHDIR) 
1990/1009    
		return devdirread(c, va, n, pipedir, NPIPEDIR, pipegen); 
	else 
		return streamread(c, va, n); 
1990/1118/sys/src/9/port/devpipe.c:251,2571990/11211/sys/src/9/port/devpipe.c:255,261
1990/0227    
{ 
	if(waserror()){ 
		postnote(u->p, 1, "sys: write on closed pipe", NExit); 
		error(0, Egreg); 
1990/11211    
		error(Egreg); 
1990/0227    
	} 
1990/0513    
	n = streamwrite(c, va, n, 0); 
	poperror(); 
1990/1118/sys/src/9/port/devpipe.c:258,2751990/11211/sys/src/9/port/devpipe.c:262,267
1990/0513    
	return n; 
1990/0227    
} 
 
void 
pipeuserstr(Error *e, char *buf) 
{ 
	consuserstr(e, buf); 
} 
                 
void 
pipeerrstr(Error *e, char *buf) 
{ 
	rooterrstr(e, buf); 
} 
                 
/* 
 *  stream stuff 
 */ 
1990/1118/sys/src/9/port/devpipe.c:317,3261990/11211/sys/src/9/port/devpipe.c:309,312
1990/0629    
	bp = allocb(0); 
	bp->type = M_HANGUP; 
	PUTNEXT(q, bp); 
1990/1118    
                 
	/* 
	 *  release stream for other half of pipe 
	 */ 
	remote = RD(q)->ptr; 
	streamexit(remote, 0); 
1990/0227    
} 


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