summaryrefslogtreecommitdiff
path: root/sys/src/libbio/bbuffered.c
blob: 1b2bdbe096e8682320aaf98aa7cdae77ddb89c22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include	<u.h>
#include	<libc.h>
#include	<bio.h>

int
Bbuffered(Biobufhdr *bp)
{
	switch(bp->state) {
	case Bracteof:
	case Bractive:
		return -bp->icount;

	case Bwactive:
		return bp->bsize + bp->ocount;

	case Binactive:
		return 0;
	}
	fprint(2, "Bbuffered: unknown state %d\n", bp->state);
	return 0;
}