Xref: utzoo comp.unix.sysv386:1889 comp.periphs.scsi:1310 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!pilchuck!dataio!fnx!del From: del@fnx.UUCP (Dag Erik Lindberg) Newsgroups: comp.unix.sysv386,comp.periphs.scsi Subject: using SCSI tape in read/write mode Keywords: I'm confused Message-ID: <755@fnx.UUCP> Date: 6 Nov 90 21:44:22 GMT Followup-To: comp.unix.sysv386 Organization: I/Ovations Kirkland, WA Lines: 130 I have decided to write a tape archiving utility and am having some problems figuring out how to use the tape drive. Some background: What I need is approximately the functional equivalent of 'tar r' to append files to the end of an archive tape. Unfortunately, 'tar r' does not allow blocking factors, and without the blocking start/stop of the tape is absurd. While the lost data from inter-record spacing is not a problem, time to write a file and wear-and-tear on the drive are objectionable. I have come up with several approaches for this utility, and I am currently favoring writing a (fixed size) tape directory to the front of the tape with pointers to the files on the tape and the start point for the next file to be written. Here is the problem: 1) If I make a loop to write 30 x 1k records containing "Record #x", rewind the tape, and read 30 records, printf()ing each, there is no problem. Rewind again, read 15 records, write one record containing "Record 15 modified" and rewind the tape. Now read 30 records and printf(). Hmmm, nobody got modified. The write() did not return an error. What am I doing wrong? 2) I have used ioctl()'s to write EOF marks to the tape, and then tried to skip 'x' of them with the appropriate ioctl(). This does not seem to get me to the correct record #. For example, I write 30 x 1k records containing only "Record #x", with an ioctl() in between each one, rewind the tape, then skip 15 of them. Read one and printf the contents. I seem to come up around #10. The system is ISC 2.0.2, the tape drive is an Archive 2150s on 1542. I don't have the code around anymore which demonstrates #2 above, but here is the hack I've been using to experiment with #1: #include #include #include #include #include #define NUMRECS 30 struct tc_parms tcp; main() { char buf[1024],buf1[1024]; int fd, x; /* Note that I am opening the tape in read/write mode. */ fd = open("/dev/mt0",O_RDWR|O_EXCL); strcpy(buf1,"This is a string in the tape output buffer.\n"); ioctl(fd,TC_REWIND); /* Initialize the tape with 30 records. */ for (x=0; x