* Writing to tape from C system calls [not found] <033701c3c0ac$97659270$aa00a8c0@ASTERIX> @ 2003-12-12 12:39 ` Ujval Lodha 2003-12-12 15:14 ` Tony Battersby 0 siblings, 1 reply; 4+ messages in thread From: Ujval Lodha @ 2003-12-12 12:39 UTC (permalink / raw) To: linux-scsi Hi I'm new to tape devices. My application requires me to seek to a certain block on the tape device and write data on it (besides being able to retrieve data by reading). So far, I have no trouble reading from the tape. When I write to it at any block that block becomes the last block on the device. I am unable to seek to any block after that on the tape. I have tried : a. Using mt to seek and dd to write b. Using open / ioctl / write from C Both with the same results. I am using a Tandberg SDLT for my tests with the linux kernel st drivers. Is this normal? Is it not possible to use the tape device - and modify data at any block by seeking to it and writing? Is there some source of information where I can read about programming tape devices from C? So far, I havent been able to find one. Please advise. Regards, Ujval Lodha ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Writing to tape from C system calls 2003-12-12 12:39 ` Writing to tape from C system calls Ujval Lodha @ 2003-12-12 15:14 ` Tony Battersby 2003-12-12 16:18 ` Ujval Lodha 0 siblings, 1 reply; 4+ messages in thread From: Tony Battersby @ 2003-12-12 15:14 UTC (permalink / raw) To: 'Ujval Lodha', linux-scsi > When I write to it at any block that block becomes the last > block on the device. I am unable to seek to any block after > that on the tape. > Is this normal? Is it not possible to use the tape device - > and modify data at any block by seeking to it and writing? It is completely normal. All modern tape drives work this way. Unlike a disk drive, a block address on tape does not correspond to a predefined location on the medium. The tape drive (re)formats the medium while it writes, which invalidates anything past the last written point on tape. So, you can seek/read/write the tape from the beginning of the tape up to just after the last written block, but the tape medium after that point is not considered to be formatted and cannot be used (again) until it is reached while writing. As you observed, writing to tape in the middle of valid data will cause the contents of the tape to be truncated at the write point. That's the way the technology works. There is no way to update a block in the middle of the valid data without losing everything that comes after it. The only way around this is to use multiple partitions, but not all tape drives support partitions, and changing partitions takes time. > Is there some source of information where I can read about > programming tape devices from C? So far, I havent been able > to find one. man st But that's pretty low-level, of course. Anthony J. Battersby Cybernetics ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Writing to tape from C system calls 2003-12-12 15:14 ` Tony Battersby @ 2003-12-12 16:18 ` Ujval Lodha 2003-12-12 16:38 ` Tony Battersby 0 siblings, 1 reply; 4+ messages in thread From: Ujval Lodha @ 2003-12-12 16:18 UTC (permalink / raw) To: tonyb, linux-scsi Thanks for your reply. That clears up my understanding. I've already read the man page. That is how I got so far, in fact. It seems to require some understanding of the functionality of tape drives. The description of some of the options seems very cryptic to me - as I dont know much of the jargon associated with tape drives. Any material that would help understand tape devices and tape as a medium - filemarks, setmarks, and the order of operations one is expected to perform. Also, I wonder if it absolutely not possible to use the tape in the manner I intended. I am using the tape without compression - and I dont mind making 'sub-optimal' use of the capacity of the tape. Thanks again. Regards, Ujval ----- Original Message ----- From: "Tony Battersby" <tonyb@cybernetics.com> To: "'Ujval Lodha'" <ujval@gdc-tech.com>; <linux-scsi@vger.kernel.org> Sent: Friday, December 12, 2003 11:14 PM Subject: RE: Writing to tape from C system calls > > When I write to it at any block that block becomes the last > > block on the device. I am unable to seek to any block after > > that on the tape. > > > Is this normal? Is it not possible to use the tape device - > > and modify data at any block by seeking to it and writing? > > It is completely normal. All modern tape drives work this way. Unlike > a disk drive, a block address on tape does not correspond to a > predefined location on the medium. The tape drive (re)formats the > medium while it writes, which invalidates anything past the last written > point on tape. So, you can seek/read/write the tape from the beginning > of the tape up to just after the last written block, but the tape medium > after that point is not considered to be formatted and cannot be used > (again) until it is reached while writing. > > As you observed, writing to tape in the middle of valid data will cause > the contents of the tape to be truncated at the write point. That's the > way the technology works. There is no way to update a block in the > middle of the valid data without losing everything that comes after it. > The only way around this is to use multiple partitions, but not all tape > drives support partitions, and changing partitions takes time. > > > Is there some source of information where I can read about > > programming tape devices from C? So far, I havent been able > > to find one. > > man st > > But that's pretty low-level, of course. > > Anthony J. Battersby > Cybernetics > ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Writing to tape from C system calls 2003-12-12 16:18 ` Ujval Lodha @ 2003-12-12 16:38 ` Tony Battersby 0 siblings, 0 replies; 4+ messages in thread From: Tony Battersby @ 2003-12-12 16:38 UTC (permalink / raw) To: 'Ujval Lodha', linux-scsi > Any material that would help understand tape devices and > tape as a medium - filemarks, setmarks, and the order of > operations one is expected to perform. Try the "SCSI-3 Stream Commands (SSC)" and "SCSI Stream Commands - 2 (SSC-2)" specifications available at http://www.t10.org/drafts.htm. They give a nice general overview of tape technology in the opening section. Anthony J. Battersby Cybernetics ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-12-12 16:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <033701c3c0ac$97659270$aa00a8c0@ASTERIX>
2003-12-12 12:39 ` Writing to tape from C system calls Ujval Lodha
2003-12-12 15:14 ` Tony Battersby
2003-12-12 16:18 ` Ujval Lodha
2003-12-12 16:38 ` Tony Battersby
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox