示例#1
0
Block*
netifbread(Netif *nif, Chan *c, long n, vlong offset)
{
	Netfile *f;
	Block *bp;

	if((c->qid.type & QTDIR) || NETTYPE(c->qid.path) != Ndataqid)
		return devbread(c, n, offset);

	f = nif->f[NETID(c->qid.path)];
	if(f->fat){
		/*
		 * Frame at a time (fat) allows us to provide
		 * non-blocking performance with blocking semantics
		 * for consumers that know ahead of time data is
		 * contained within a single frame.  Once empty, we
		 * get in line with other blocking reads and wait our
		 * turn.
		 */
		for(;;){
			if(bp = qget(f->iq))
				return bp;
			if(waserror())
				return nil;
			qsleep(f->iq);
			poperror();
		}
	}
	return qbread(f->iq, n);
}
示例#2
0
文件: netif.c 项目: Requaos/harvey
Block*
netifbread(Netif *nif, Chan *c, int32_t n, int64_t offset)
{
	if((c->qid.type & QTDIR) || NETTYPE(c->qid.path) != Ndataqid)
		return devbread(c, n, offset);

	return qbread(nif->f[NETID(c->qid.path)]->iq, n);
}
示例#3
0
文件: netif.c 项目: CoryXie/nix-os
Block*
netifbread(Netif *nif, Chan *c, long n, ulong offset)
{
	if((c->qid.type & QTDIR) || NETTYPE(c->qid.path) != Ndataqid)
		return devbread(c, n, offset);

	return qbread(nif->f[NETID(c->qid.path)]->in, n);
}
示例#4
0
文件: netif.c 项目: goovdl/akaros
struct block *netifbread(struct ether *nif, struct chan *c, long n,
						 uint32_t offset)
{
	if ((c->qid.type & QTDIR) || NETTYPE(c->qid.path) != Ndataqid)
		return devbread(c, n, offset);

	return qbread(nif->f[NETID(c->qid.path)]->in, n);
}
示例#5
0
static Block*
loopbackbread(Chan *c, long n, ulong offset)
{
	Loop *lb;

	lb = c->aux;
	if(TYPE(c->qid.path) == Qdata)
		return qbread(lb->link[ID(c->qid.path)].iq, n);

	return devbread(c, n, offset);
}
示例#6
0
static Block*
pipebread(Chan *c, long n, ulong offset)
{
	Pipe *p;

	p = c->aux;

	switch(NETTYPE(c->qid.path)){
	case Qdata0:
		return qbread(p->q[0], n);
	case Qdata1:
		return qbread(p->q[1], n);
	}

	return devbread(c, n, offset);
}
示例#7
0
文件: devpipe.c 项目: Shamar/harvey
static Block*
pipebread(Chan *c, int32_t n, int64_t offset)
{
	Pipe *p;

	p = c->aux;

	switch(PIPETYPE(c->qid.path)){
	case Qdata0:
		return qbread(p->q[0], n);
	case Qdata1:
		return qbread(p->q[1], n);
	}

	return devbread(c, n, offset);
}
示例#8
0
文件: devip.c 项目: 99years/plan9
static Block*
ipbread(Chan* ch, long n, ulong offset)
{
	Conv *c;
	Proto *x;
	Fs *f;

	switch(TYPE(ch->qid)){
	case Qdata:
		f = ipfs[ch->dev];
		x = f->p[PROTO(ch->qid)];
		c = x->conv[CONV(ch->qid)];
		return qbread(c->rq, n);
	default:
		return devbread(ch, n, offset);
	}
}
示例#9
0
文件: pipe.c 项目: GanShun/akaros
static struct block *pipebread(struct chan *c, long n, uint32_t offset)
{
	Pipe *p;

	p = c->aux;

	switch (NETTYPE(c->qid.path)) {
		case Qdata0:
			if (c->flag & O_NONBLOCK)
				return qbread_nonblock(p->q[0], n);
			else
				return qbread(p->q[0], n);
		case Qdata1:
			if (c->flag & O_NONBLOCK)
				return qbread_nonblock(p->q[1], n);
			else
				return qbread(p->q[1], n);
	}

	return devbread(c, n, offset);
}