Raw vs. block device. I"m confused.

Spencer W. Thomas thomas at utah-gr.UUCP
Mon Jan 16 15:22:18 AEST 1984


    In general, most UNIX magtape drivers use the following conventions with
    the RAW device:

	read(fh, buf, nbytes) returns -1 when nbytes < physical record size

		otherwise,

	read(fh, buf, nbytes) returns the actual number of bytes in the record
		(i.e., it transfers only a single record, regardless of the
		 byte count.)

    I have always ascribed the former behavior to a limitation of the
    controller; it transfers a full record or nothing.

If you think about this, you will see that can't be the case - there is
no way to know the record size without reading it!  I think that most
tape controllers will read a "partial" record, just dumping the "unread"
bytes on the floor.  They will probably set an error bit, too,
indicating that you lost some data.  In any case, you will usually not
get anything but your buffer written on (although I recall some really
interesting stories about early Vax tape controllers).

=Spencer



More information about the Comp.unix mailing list