write(2) to tape with odd byte count

Henry Spencer henry at utzoo.UUCP
Wed Dec 11 08:30:33 AEST 1985


> > Is it possible to create a tape with an odd number of bytes
> > per record?  When I try such an operation with write(2), I
> > get a return code of -1 (Oh, sorry, this is 2.8BSD)...
> 
> Magtapes can be written with any number of bytes between about
> 14 and 2K (often up to 64K-1) per record (block).  However, some
> brain-damaged operating systems maintain the transfer count
> internally as PDP-11 words, instead of bytes.  On such systems,
> you can only request an even number of bytes.  I don't know why
> you would get an error return instead of having your request
> rounded to an even number of bytes.  I am also surprised if 2.8BSD
> really still has the old 6th Edition word counts instead of the
> 7th Edition byte counts...

The problem is historical in origin.  Most pdp11 device controllers, back
in the good (?) old days, did their transfers a word at a time and hence
were restricted to working in even numbers of bytes.  Virtually all pdp11
disks worked that way, for example.  The magtape was practically the sole
exception.  So raw disk i/o (*not* via the file system, which hides all
this) had to be an even number of bytes.  The V[67] physio() routine, which
copes with the details of raw i/o setup, therefore rejects odd byte counts;
they are literally impossible on pdp11 disks.  Unfortunately, the magtape
driver also uses physio() to do its dirty work, and hence inherits the
unnecessary even-counts-only restriction.  I'm surprised that 2.8BSD hasn't
fixed this particular mistake; it's not hard.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry



More information about the Comp.unix mailing list