From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sat, 16 Sep 1995 10:53:02 -0400 From: presotto@plan9.att.com presotto@plan9.att.com Subject: dirfstat on tcp/udp/il connections is always 0 Topicbox-Message-UUID: 2488eeca-eac8-11e9-9e20-41e7f4b1d025 Message-ID: <19950916145302.A5vfq-FRGH-Jav75KJwTHQfMPN-76lCnx57tPYlrVbA@z> Since dirfstat returns the size of the next message queued for reading for pipes, it would be nice if the same happened for IP protocols. The following changes make it work. Note that dirstat will still return 0 (the stream gets bound to the fd on open...). -------------------------------------------- In port/stream.c, replace streamstat() with: -------------------------------------------- ulong streamlen(Chan *c) { Stream *s; Queue *q; Block *bp; ulong n; s = c->stream; n = 0; if(s) { q = RD(s->procq); if(q->flag & QHUNGUP) error(Ehungup); lock(q); for(bp=q->first; bp; bp = bp->next){ n += BLEN(bp); if(bp->flags&S_DELIM) break; } unlock(q); } return n; } void streamstat(Chan *c, char *db, char *name, long perm) { Dir dir; devdir(c, c->qid, name, streamlen(c), eve, perm, &dir); convD2M(&dir, db); } -------------------------------------------- In port/net.c -------------------------------------------- % diff net.c $old/net.c 93c93 < devdir(c, q, "data", streamlen(c), o, perm, dp); --- > devdir(c, q, "data", 0, o, perm, dp); -------------------------------------------- In port/portfns.h -------------------------------------------- % diff portfns.h $old/portfns.h 267d266 < ulong streamlen(Chan*);