kvt@drutx.ATT.COM (TranKV) (03/25/88)
When read(2)/write(2) are used to access a physical device in raw mode (9-track tape devices specifically), are there a standard errno's that read(2)/write(2) returns to signify end of physical tapes? Or do they vary among UNIX versions and tape drives? If they are indeed different, what one can do in application programs to make them portable when changing tape drives or machines? To add more spices to the discussion, here are some interesting phenomenon: - Using our 3B5 with UNIX V 2.0, we got errno=5 for both end of tape read(2) and write(2). - Using our 3B2/600 with UNIX V 3.1 with 9-track tape drive hooked up through SCSI, we got errno=28 for end of tape write(2) and errno=0 for end of tape read(2). - We wrote a small C program to write(2) 5120 bytes at a time to a 9-track tape on the 3B5 (using raw mode) until we got to the end of tape. Then we tried to read(2) the tape (5120 bytes at a time) on the 3B2. To our surprise, 3B2 can read more than the 3B5 wrote and the 3B2 cannot detect end of tape without giving error warning. Reverse the read/write order, the 3B5 seems read less than what was put on tape by the 3B2. So we're confused. And help is definitely needed. Kim Tran AT&T EUO
henry@utzoo.uucp (Henry Spencer) (03/27/88)
> When read(2)/write(2) are used to access a physical device in raw mode > (9-track tape devices specifically), are there a standard errno's that > read(2)/write(2) returns to signify end of physical tapes? The magtape driver unfortunately is an area where many people have exercised their creativity, to the detriment of standardization and portability... -- "Noalias must go. This is | Henry Spencer @ U of Toronto Zoology non-negotiable." --DMR | {allegra,ihnp4,decvax,utai}!utzoo!henry
atbowler@watmath.waterloo.edu (Alan T. Bowler [SDG]) (04/08/88)
In article <7051@drutx.ATT.COM> kvt@drutx.ATT.COM (TranKV) writes: > >When read(2)/write(2) are used to access a physical device in raw mode >(9-track tape devices specifically), are there a standard errno's that >read(2)/write(2) returns to signify end of physical tapes? Or do they >vary among UNIX versions and tape drives? If they are indeed different, >what one can do in application programs to make them portable when >changing tape drives or machines? Henry Spencer has observed that the mag tape drivers and their status returns tend to be non-standard. Part of the reason of course is that the original Unix drivers ignored end of tape. That aside I will point out that most tape hardware has NO end-of-tape status on a read. On a write, the hardware usually returns "successful write, and by the way you just passed the foil marker". The software is expected to observe the end of tape indication and write something on the tape that the reader will recognize as an end of tape. On the older operating systems, this usually is an eof marker and a trailer label indicating the name of the reel that the data is continued on. The Unix convention of return statuses from write does not lend itself well to this concept of "the operation worked but there is something that requires your attention soon (i.e. before you run out of wrapup space)". I.e. if the write is successful, then it should be returning the number of bytes written, and so the programmer doesn't get the idea he should check errno. If the write returns -1 to tell the user he should check errno, the program has lost the "actual byte count written" data that the program needs to continue (assuming he is not using a raw device). The early Unix mag tape drivers solved the problem by ignoring the end of tape status, and assuming programs would precalculate a "guestimate" of how much the tape would hold. Since then various things have been done depending on the expected use pattern at individual sites.