ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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).
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.
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!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.