|
|
|
|
| Author |
Message |
Guest
|
Posted: Fri Feb 09, 2007 6:25 pm Post subject: Problems while writing to VXA tape... |
|
|
Hi ... I have a rather peculiar problem...
I have two sets of data from different sources...Both the sets of
data consists of lot of TIFF images which i have clubbed one after the
other.
I use a program in C to write to chunks of data to tape...it is a
simple program which lifts certain amounts of data from the file and
writes it to tape.
The set 1 of data writes correctly; i check the status of write()
command everytime. and the data writes correctly and reads correctly.
the problem occurs when i try to write set 2 of data; everytime the
write() command fails and i am not able to write to tape.
i know this sounds absurd...but there is hardly any difference in the
two sets of files; except the orientation tag values. Still i am not
able to write to tape.
Does anything from the data affect the write command or the VXA tape
drive?
i am puzzled...
thanks ,
pravin |
|
| Back to top |
|
 |
Fix your Windows Problems - FAST.
FREE Safe Scan Registry Check. Locate & Fix Errors in Minutes!
|
|
Michael Baeuerle Guest
|
Posted: Sat Feb 10, 2007 5:19 am Post subject: Re: Problems while writing to VXA tape... |
|
|
prabhu.pravin@gmail.com wrote:
| Quote: |
[...]
The set 1 of data writes correctly; i check the status of write()
command everytime. and the data writes correctly and reads correctly.
the problem occurs when i try to write set 2 of data; everytime the
write() command fails and i am not able to write to tape.
|
In general this should work. I have written a small test program to see
how my type drive behaves. The program writes two files to the tape, one
containing 1MiByte zeros, the other containing 1MiByte ones. The only
thing I can do to get an error is to specify a blocksize that is not
supported by the tape drive (e.g. write the whole data as one block).
The filemark between the two files is generated by the tape driver on
closing and reopening the device file, no ioctl() required. After
running the program I have checked the two files using dd and they
contained the expected data (zeros and ones).
This is the test program:
----------------------------------------------------------------------
/* Tape access test */
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
/* Filesize (1MiByte) */
#define FILESIZE (1024L * 1024L)
/* Blocksize */
#define BLOCKSIZE 512
int main(void)
{
long int i;
unsigned char data[FILESIZE];
int fd;
ssize_t rv;
long int written;
/* Open nonrewinding device file */
fd = open("/dev/rmt0.1", O_WRONLY);
if (fd == -1)
{
perror("Cannot open tape device");
exit(1);
}
/* Write zeros */
printf("Write zeros ...\n");
for (i = 0; i < FILESIZE; i++)
{
data[i] = 0x00;
}
written = 0;
do
{
rv = write(fd, &data[written], (size_t) BLOCKSIZE);
if (rv == -1)
{
perror("Write error");
exit(1);
}
written += (long int) rv;
} while (written != (long int) FILESIZE);
/* Close device file */
close(fd);
/* Reopen nonrewinding device file */
fd = open("/dev/rmt0.1", O_WRONLY);
if (fd == -1)
{
perror("Cannot open tape device");
exit(1);
}
/* Write ones */
printf("Write ones ...\n");
for (i = 0; i < FILESIZE; i++)
{
data[i] = 0xFF;
}
written = 0;
do
{
rv = write(fd, &data[written], (size_t) BLOCKSIZE);
if (rv == -1)
{
perror("Write error");
exit(1);
}
written += (long int) rv;
} while (written != (long int) FILESIZE);
/* Close device file */
close(fd);
printf("Success.\n\n");
exit(0);
}
/* EOF */
----------------------------------------------------------------------
BTW: For simplicity, write errors are not checked for EINTR (interrupted
system call) and the program fails if write() returns a value between 0
and BLOCKSIZE.
BTW2: I have tested this on AIX using a QIC-3080 tape drive - should be
the same for every other Unix and/or VXA tape drive except for device
names and supported blocksizes.
Micha
--
http:/micha.freeshell.org |
|
| Back to top |
|
 |
|
|
| |