Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Dec 1997 23:05:33 -0800 (PST)
From:      dan@math.berkeley.edu (Dan Strick)
To:        scsi@FreeBSD.ORG
Cc:        dan@math.berkeley.edu
Subject:   Re: Questions about mt and SCSI subsystem
Message-ID:  <199712100705.XAA22478@math.berkeley.edu>

next in thread | raw e-mail | index | archive | help
> In SCSI, there is no such thing as an "EOT" marker.  Instead, you must

Modern SCSI tape systems typically recognize some combination of
physical EOT (beyond which you cannot write), logical EOT (beyond
which you might be able to write if you know the magic commands),
and EOM (after the most recently written record on a sequential
access tape).  The details depend mainly on the exact medium and
somewhat on the drive.  I don't remember how much of this is
standardized in the various versions of SCSI.

> The Berkeley convention was that 2 filemarks in a row signaled EOT.

This convention (which as far as I know did not originate at UCB)
predates all flavors of Unix.  It was a really simple and convenient
device and OS independent convention for marking the end of data.
It did have the disadvantage that it discouraged empty files and
it was finally broken by modern cheap tape drives that were not able
to overwrite EOF marks.

My personal policy (in writing tape drivers) is that all drivers for
tapes that are capable of overwritting EOF marks should write a double
EOF and then backspace before closing the device or doing any tape motion
operation if the previous tape operation was a write.  For drives
that are not capable of overwriting EOF marks, I favor the convention
that a single EOF mark (with no backspace) be written in these
circumstances and that a double EOF mark be written before rewinds
(even though this may inconvenience lazy programmers who don't think
ahead).

Of course, nobody ever listens to me ... :-)

> Right now, we only have a single error code to pass back to the application
> for filemarks, setmarks, EOD, and EOM.  Either we have to add some error
> codes or add an MT ioctl so the application can determin what the exact
> cause of the EIO was.

The convention that a raw tape driver return a single zero length
read to mark EOF is very ancient and should be respected because it
is so darn useful.  It means that a program can distinguish between
a read error and an end of file without knowing specific error codes.
I would rather not see that convention change just because some
tape drivers were written by people who were too green to know the
convention or were unable to appreciate its value.

I think we should strive to do the "right" thing even though major
OS vendors do it wrong.

Dan Strick
dan@math.berkeley.edu



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712100705.XAA22478>