LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-21-2005, 01:27 AM   #1
vetrimani
LQ Newbie
 
Registered: Dec 2005
Posts: 8

Rep: Reputation: 0
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.
 
Old 12-21-2005, 06:01 AM   #2
ppanyam
Member
 
Registered: Oct 2004
Location: India
Distribution: Redhat
Posts: 88

Rep: Reputation: 15
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.
 
Old 12-21-2005, 06:18 AM   #3
vetrimani
LQ Newbie
 
Registered: Dec 2005
Posts: 8

Original Poster
Rep: Reputation: 0
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.
 
Old 12-21-2005, 06:43 AM   #4
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
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
 
Old 12-21-2005, 07:00 AM   #5
ppanyam
Member
 
Registered: Oct 2004
Location: India
Distribution: Redhat
Posts: 88

Rep: Reputation: 15
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!
 
Old 12-21-2005, 11:13 PM   #6
vetrimani
LQ Newbie
 
Registered: Dec 2005
Posts: 8

Original Poster
Rep: Reputation: 0
i tried tat but i am not able to go beyond the EOF, by C program, as well as other applications like mt etc..
 
Old 12-21-2005, 11:28 PM   #7
ppanyam
Member
 
Registered: Oct 2004
Location: India
Distribution: Redhat
Posts: 88

Rep: Reputation: 15
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot access Sony SDX-250V tape drive RH8 PK2K Linux - Hardware 2 05-08-2005 06:40 PM
How to access the tape drive? LenkaNguyen Linux - Hardware 3 07-02-2004 10:29 AM
can't access tape drive in RH8.0 :( lpriyamb Linux - Software 16 10-12-2003 11:38 PM
DLT 40 How do I access this tape drive? chr15t0 Linux - Hardware 1 02-14-2003 10:13 AM
Remote tape access Paul_assheton Linux - Networking 0 09-05-2002 08:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration