shithub: riscv

ref: 92ce2cfea6a6bff967cc6f3f9b71b74df2305f6a
dir: /sys/src/libbio/boffset.c/

View raw version
#include	<u.h>
#include	<libc.h>
#include	<bio.h>

vlong
Boffset(Biobufhdr *bp)
{
	vlong n;

	switch(bp->state) {
	default:
		fprint(2, "Boffset: unknown state %d\n", bp->state);
		n = Beof;
		break;

	case Bracteof:
	case Bractive:
		n = bp->offset + bp->icount;
		break;

	case Bwactive:
		n = bp->offset + (bp->bsize + bp->ocount);
		break;
	}
	return n;
}