LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-19-2009, 08:37 AM   #1
Lakki
Member
 
Registered: Jul 2008
Posts: 32

Rep: Reputation: 15
Problem with write/read to/from the tape


I am using RHEL 5.3

I want to do some backup/restore and export/import operation with the database.
I am writing a label to the tape as "BACKUP TAPE" or "EXPORT TAPE" during backup/export , so that i can check the same while doing restore/import.

I used the below code to write to the tape:

//checking the tape
if ((fd = open("/dev/st0", O_RDONLY)) >= 0) {
printf( "Tape open succeeded\n");
close(fd); }

//Rewinding the tape
if( system("mt -f /dev/st0 rewind") != 0 ) {
printf( "tape rewind failed\n");
exit(0); }

//Opening the tape in non-rewinding mode
if ((fp = fopen("/dev/nst0","w")) == NULL) {
printf( "tape open failed\n");
exit(0); }

//writing to tape
if((fprintf(fp,"BACKUP TAPE\n")<=0) || (ferror(fp)!=0))
printf("write failed\n");
fclose(fp);

To read from the tape:

I did the first 3 same operation as in writing and here the code follows
if((fgets(cmd,sizeof(cmd)-1,fp)==NULL) || (ferror(fp)!=0) ) {

printf("Reading from tape failed\n"); }
printf ("cmd is %s\n", cmd); --> prints nothing

But write is getting passed without any errors.
On the other side, read fails and cud nt read the label

Can anyone help me out where i am going wrong?
Should i go for tar/cpio to write even a string?

-Lakshmi
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
IBM 3590 Tape Drive, Ubuntu Sever, MT read/write error penguinboy08 Linux - Hardware 11 02-14-2009 10:44 AM
read/write file_operation problem ashok449 Linux - Kernel 1 02-29-2008 04:28 AM
Write / Read a DAT (DDS 3 / 4) tape label Zxarr Linux - Software 1 02-06-2008 09:36 PM
SMB Read/Write Problem dhammika Linux - Networking 3 05-12-2004 12:03 PM
Open office read only, K-write read/write mode lwtvh Linux - Newbie 1 07-19-2003 12:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:20 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