hi
I hope this is the right forum for this questions. I am having a problem
with a dat scsi tape drive. I have written multiple files to the tape and
when I try to seek to a file mark using ioctl, the seek operation does not
work correctly. The next read after the seek operation returns the filemark
instead of the following data. This happens only for the first seek on the
tape. i.e. if I initially do a read, and then do a seek, it fails, but if I
do a seek initially and then a read, the read works correctly. The
following code segment and result illustrates this -
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/mtio.h>
main()
{
struct mtop os_tapeop;
int i, j, s, k, fd;
char buf[16384];
fd = open("/dev/st0", O_RDWR);
printf("fd = %d (%d)\n", fd, errno);
for (i=0; i<20; i++) {
if (i==1) {
os_tapeop.mt_op = MTFSF;
os_tapeop.mt_count = 1;
j = ioctl(fd, MTIOCTOP, &os_tapeop);
printf("ioctl code = %d (%d)\n", j, errno);
}
s = read(fd,buf,16384);
printf("Read %d of %d Bytes (%d)\n", i+1, s, errno);
}
}
**********
Results
***********
fd = 3 (0)
Read 1 of 16384 Bytes (0)
ioctl code = 0 (0) <= ioctl to skip to the next filemark
Read 2 of 0 Bytes (0) <= WHY DID WE READ A FILEMARK?
Read 3 of 16384 Bytes (0)
Read 4 of 16384 Bytes (0)
This is the output of a version that works, where I first seeked and then read.
fd = 3 (0)
ioctl code = 0 (0) <= Seek to first filemark
Read 1 of 16384 Bytes (0) <= The first 16KB after the filemark:
Read 2 of 16384 Bytes (0)
Read 3 of 16384 Bytes (0)
I am running stock redhat 6.1 with a SCSI Adaptec 7895 motherboard
controller and the tape drive is a SONY SDT-10000 DDS-4 drive. Anyone seen
this kind of problem before and any possible solutions. My backups do not
work because the backup software relies on the correct behavior of the
ioctl call for a seek.
Thanks
naren