[comp.unix.ultrix] Tape EOF processing

keith@sequoia.UUCP (Keith Pyle) (05/04/89)

I have encountered the following problem under Ultrix-32 V3.0 (Rev 64):
when reading from a tape (either TK50 or TK70, I haven't checked 9 track),
the end of file processing is incorrect.  Quoting from TFM for mtio(4):

>                                A zero byte count is returned
>    when a tape mark is read, but another read will fetch the
>    first record of the next tape file.

What I have found is that when an EOF is encountered, all subsequent
calls to read(2) will return 0.  The only way to clear this condition
that I have found thus far is to close(2) the file and open(2) it
again.  (This assumes the use of the no-rewind device.)

The exact same code functions as expected and as per the documentation
under SunOS 4.0.1 and Sequent's DYNIX V3.0.12.  Is this a known problem
with Ultrix?  Is there a peculiar, strange, or warped reason for this
behavior (other than "It's a bug")?  If not a bug, is there a method,
other than the one I've discovered, to clear the condition to permit
the next read(2) to succeed as the manual says it should in the first
place?  Are we having fun yet?

-- 
-----------------------------------------------------------------------------
Keith Pyle                                      ...!cs.utexas.edu!execu!keith
Execucom Systems Corp., Austin, Texas

Disclaimer: What??  You actually believed me?
-----------------------------------------------------------------------------

russes@ryn.DEC.COM (Bob Russes) (05/14/89)

In article <490@sequoia.UUCP> keith@sequoia.UUCP (Keith Pyle) writes:

>behavior (other than "It's a bug")?  If not a bug, is there a method,
>other than the one I've discovered, to clear the condition to permit
>the next read(2) to succeed as the manual says it should in the first
>place?

	To get around the problem, I simply advance the tape zero files.
Note:  this only seems to work on the VAX, it doesn't seem to work on a
DS3100:

 if (fromtape)
    {
      if ((len = read(fileno(fp), tapebuf, BUFLEN)) > 0)
	{ markcount = 0; return len; }
      if (++markcount == 1)
	then {
	       op.mt_op    = MTFSF;
               op.mt_count =     0;
               ioctl (fileno(fp),MTIOCTOP,&op);
               return TAPE_MARK;
	     }

    }

-----

Bob