Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!lll-tis!lll-lcc!pyramid!oliveb!jerry
From: jerry@oliveb.UUCP
Newsgroups: comp.unix.wizards
Subject: Re: read() applied to mag tapes
Message-ID: <1929@oliveb.UUCP>
Date: Thu, 9-Jul-87 23:16:35 EDT
Article-I.D.: oliveb.1929
Posted: Thu Jul  9 23:16:35 1987
Date-Received: Sun, 12-Jul-87 09:58:19 EDT
References: <153@qetzal.UUCP>
Reply-To: jerry@oliveb.UUCP (Jerry F Aguirre)
Organization: Olivetti ATC; Cupertino, Ca
Lines: 36
Keywords: what is your experience

In article <153@qetzal.UUCP> rcw@qetzal.UUCP (sysop) writes:
>physical record size = 8000 bytes, and I do two discrete read() calls,
>from /dev/rmt0, I get the first 80 bytes from each PHYSICAL record,
>not 160 bytes in succession.  (Wicat 160 w/Uniplus V.2 + Cipher 
>1600bpi drive)

This is primarily a characteristic of the tape hardware.  Once you start
reading a record you can't just top in the middle and wait for the next
read.

The alternative is to buffer the data.  This allows you to return the
requested number of bytes and save the rest of the record for the next
read.  The problem with this is how big do you make the buffer?  If the
tape has a maximum record size and it is not unreasonable then the
driver can include buffer(s) of that size.  But some drives allow
records approaching the size of physical memory!

Unix provides a normal and a raw interface to the tape drive.  The
normal one will provide the buffering you desire providing the records
are less than the buffer size.  The buffer size varies depending on the
version but is on the order of 512 or 1024 bytes.  Not much help for the
tape you have.

The raw interface provides no buffering so you must read a record in
using a single read large enough to hold the maximum expected record.
If the record is smaller the value returned from read will tell you
that.

The utility "dd" includes a number of features usefull for dealing with
tape records.  It can read one input record size and write out a
compleatly different one.  If your program can accept input from a pipe
then you can "dd if=/dev/tape_name ibs=8000 | yourprog" and the pipe
will provide the buffering you need.  The alternative is to dd the tape
into a disk file and process it there.

					Jerry Aguirre