LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   HOW to ACCESS MAG TAPE (https://www.linuxquestions.org/questions/programming-9/how-to-access-mag-tape-395146/)

vetrimani 12-21-2005 01:27 AM

HOW to ACCESS MAG TAPE
 
How can i access and read a magtape device ( /dev/st0 ) from a C or C++ program in linux. To recover corrupt tapes.

ppanyam 12-21-2005 06:01 AM

Magnetic tapes are also handled like any file in *nix. (Only they are sequential). So fopen() etc will work normally. Make sure to handle the return value from read(). This will tell you the number of bytes that could be read from the read() call.

What do you mean by corrupt tapes? Damaged ( may be due to dust or not used for a long time)? There is something called as Tape Archiving, in which the damaged tapes are treated in ovens(you got it right, hot ovens) and then read in special/modified tape drives.

vetrimani 12-21-2005 06:18 AM

Thanx for your reply, now i have made throug open and read system calls. but the proper no. of bytes must be read at a time that should match with the mag tape's buffer size (e.g 20*512 for HP DAT).

I told corrupted means by mistake while extracting i have given a command tar -cvf /dev/st0 dir/ ( note dir/ doesnot exist in loacl sys).

how to recover the data.

AnanthaP 12-21-2005 06:43 AM

Unfortunate isn't it that 'c" and "x" keys are right next to one another.

Even if there is no data in "dir/", it must have written an EOF on the tape. So no ordinary app can go beyond this. My suggestion is as follows: May wrk.

(1) Open using some no rewind device (normally this would be some device like "st0nr").
(2) Go to eof (your dummy output).
(3) Read blocks and start dumping to a destination device.
(4) All the best. Hope you didn't loose too much data.

Also any tape recovery specialists in your area?

End

ppanyam 12-21-2005 07:00 AM

May not work that way. When EOF is written, it writes 'some data' on the tape. Hence the initial part of the tar data on the tape is lost. Even if you recover the latter part and try tar xvf on the disk file, it will probably say 'the file is not a proper tar format' or some such thing. It makes a CRC check before opening a tar file, and that will fail.

Best of luck, really. I will now remember that x and c are next to each other on keyboard!

vetrimani 12-21-2005 11:13 PM

i tried tat but i am not able to go beyond the EOF, by C program, as well as other applications like mt etc..

ppanyam 12-21-2005 11:28 PM

That's what I thought. Once you write anything at the beginning of the tape, all old data is lost. Its one of the things we can't "undo" in computers.

If its really important, you may have to look for data recovery specialists.

Bad luck.


All times are GMT -5. The time now is 10:40 PM.