How do I tell physio that my device has reached EOF?
tony cooper
name at portia.Stanford.EDU
Thu Nov 16 23:06:18 AEST 1989
In the context of a raw device driver for a tape drive, physio() tells
my strategy routine to schedule that 16 blocks of data be put into a
buf buffer. My device transfers 14 blocks then reaches EOF. My question
is this: How do I report back to physio() that 14 blocks have been put
into the buf structure and that EOF has been reached.
When I try:
bp->b_resid = 2*512; /* 2 blocks unread */
bp->b_flags &= ~B_ERROR;
bp->b_error = 0;
iodone(bp);
physio() realises that only 14 blocks were read and does the right thing
with them. But then it comes back and asks for another 16 blocks, not
realizing that EOF has been reached. The device obliges by reading 16
blocks from the next file on the tape drive since the tape was positioned
ready for the next file.
In the case that 16 blocks were unread instead of 2 before the EOF was
reached then bp->b_resid equals 16 blocks and physio() accepts that EOF
has been reached and doesn't ask for any more. But for less than 16 blocks
unread, this does not work. I have tried things such as setting b_count
to zero or to b_resid, but with no luck.
A solution to this problem would be greatly appreciated. Thanks.
Tony Cooper
tony at popserver.stanford.edu
name at portia.stanford.edu
More information about the Comp.unix.wizards
mailing list