Click to See Complete Forum and Search --> : tape drive help


phatbeatsboy
07-29-2004, 04:17 PM
i have a sony ait i260 tape drive on an adaptec 29160N running rh9. I writing a program to control the tape drive in c++. So far i can do all the basic commands using ioctl's and the mtio.h lib(read, write, rewind, write filemarks, etc). What i need to do is to find out either one or both of these things, tape capacity and tape remaining. I contatcted sony and they suggested that i use the sg drivers. In my searching i have come across a command called READ CAPACITY in scsi/scsi.h, now all i need to do is use it. I've probably been trying to figure this out for too long, becuase i must be missing something simple that is messing things up. any help would be appreciated.

phatbeatsboy
07-29-2004, 05:00 PM
for instance this works just fine,

#include <sys/ioctl.h>
#include <iostream>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
#include "drss.h"
#include <linux/mtio.h>
#include "ustimer.h"
#include "ustimer.cpp"
#include <scsi/scsi.h>
#include <scsi/sg.h>

using namespace std;

int main() {
int fd, test;
sg_scsi_id capacity;

fd = open("/dev/sg0", O_RDWR);
if (fd == -1) {
cout << "could not open" << endl;
}
test = ioctl(fd, SG_GET_SCSI_ID, &capacity);
cout << "this is a result of the magical capacity test " << test << endl;

cout << capacity.host_no << endl;
cout << capacity.channel << endl;
/* SCSI id of target device. */
cout << capacity.scsi_id << endl;
cout << capacity.lun << endl;
/* TYPE_... defined in <scsi/scsi.h>. */
cout << capacity.scsi_type << endl;


return 0;
}

here is the output

this is a result of the magical capacity test 0
0
0
1
0
1

so like i said i can get some things to work but the read capacity operation remains elusive.

phatbeatsboy
09-28-2004, 12:08 PM
turns out that there is no way that i am aware of to access the MIC chip. apparently, according to sony, it is used for speeding up access times and the such. so basically i can't access it. What i did for the tape remaining was just space to the end of data and calculate based on position, block size and size of tape. i'm pretty much just talking to myself here but incase anyone ever needs this...