WANTED: Painless method of obtaining tape status

Chuck Lambros cpl at ednor.bbc.com
Wed Mar 28 00:28:15 AEST 1990


I am working on a tape manipulating program which requires the
knowledge of the following:

o	when a tape is at BOT,
o	when a tape is a EOT.

Presently I am using the 'ioctl' function to obtain tape status
information.  On most Unix systems, passing ioctl the MTIOCGET
option will fill the tape device status in the mt_dsreg field of
the mtget structure supplied.  The information returned in this
field is grossly hardware specific.  Also, this ioctl functionality
is not always available on System V.  This approach is therefore
not the preferred method of creating a portable software package.

When writing to the tape, I realize that I can check the
return code passed back from the 'write' function call. 
The knowledge that when 'write' returns -1, and sets errno
to ENOSPC, is sufficient to signify that we are at end of
tape (EOT).  I have not found that the method for
determining EOT while performing a read is as simple.

Documentation on the 'read' function signifies that two
consecutive tape marks signify EOT.  This method works fine
when the tapes are created using this rule.  The problem I
am encountering is that I am never guarantee that there
will be two consecutive tape marks present before the
photoreflective EOT marker tape. The program I am working
on is designed to read tapes created on non-Unix systems where
limited information may be written beyond the EOT marker
tape.  The Unix systems I have seen do not allow reading beyond
this tape marker.

I realize that when the tape is positioned at the
photoreflective EOT tape, a read operation will supply a
return value of -1.  I could use this information as a "kludgey"
way of determining if the tape is at EOT.  Unfortunately,
this return value is also returned when any read error has
occurred.  For this reason, I do not feel that this method
would be the best approach.

With regards to determining BOT without using the 
non-portable ioctl call, I haven't got a clue.

In summation, I really could use ANY hints of methods for
determining a tape's status without knowledge tape device
specifics (i.e. a portable method of determining a tapes 
status).  I am searching for methods for both Berkely 4.2,
as well as System V.  Although preferred, the methods do not
have to be the same for the two versions of Unix.

Please email any info, and thanks in advance.


-- 
Chuck Lambros                                   Boston Business Computing, Ltd.
cpl at ednor.bbc.com



More information about the Comp.unix.wizards mailing list