Operating System - HP-UX
1827760 Members
2708 Online
109969 Solutions
New Discussion

how to get the status like mt status with mtio in C

 
joao coelho_1
Occasional Contributor

how to get the status like mt status with mtio in C

I am using solaris intel on a compaq with a compaq tape drive. I am trying to get the status of a tape drive. I would like to use something that returns the same information as the command mt status.
I saw ioctl and the use of the structure mtget to get the status of the tape, but when i check the struct member mt_dsreg it's always 0
whether the tape is online or offline.
Now, i don't know if the status that i refer to is the same as the one used in the mt_dsreg field. I probably assumed incorrectly that they
were Does anyone know what is meant by status in this struct ? Are there any other functions or structs i can use for this or is there
something else i need to do with mtget.mt_dsreg ? Many thanks.
4 REPLIES 4
Rory R Hammond
Trusted Contributor

Re: how to get the status like mt status with mtio in C

You can get source code for mtx. which is like mt from mtx.sourceforge.net. You might be able to find your answer. I sorry that I don't have time to look closer
There are a 100 ways to do things and 97 of them are right
Rory R Hammond
Trusted Contributor

Re: how to get the status like mt status with mtio in C

I lied.

got the gnu mt source from gun paxutils-2.4
I am listing the print_status function.

print_status (char *dev, int desc)
{
struct mtget status;

if (rmtioctl (desc, MTIOCGET, (char *) &status))
error (2, errno, "%s", dev);

printf (_("drive type = %d\n"), (int) status.mt_type);
#if defined(hpux) || defined(__hpux__)
printf (_("drive status (high) = %d\n"), (int) status.mt_dsreg1);
printf (_("drive status (low) = %d\n"), (int) status.mt_dsreg2);
#else
printf (_("drive status = %d\n"), (int) status.mt_dsreg);
#endif
printf (_("sense key error = %d\n"), (int) status.mt_erreg);
printf (_("residue count = %d\n"), (int) status.mt_resid);
#if !defined(ultrix) && !defined(__ultrix__) && !defined(hpux) && !defined(__hpp
ux) && !defined(__osf__)
printf (_("file number = %d\n"), (int) status.mt_fileno);
printf (_("block number = %d\n"), (int) status.mt_blkno);
#endif
}
There are a 100 ways to do things and 97 of them are right
joao coelho_1
Occasional Contributor

Re: how to get the status like mt status with mtio in C

Thanks very much, i am at home now, but when i get to work in a couple of hours, i will check it out.
joao coelho_1
Occasional Contributor

Re: how to get the status like mt status with mtio in C

Well Rory,
Thanks, but i am getting the same result i was getting with my sample code. The mt_dsreg value is always 0, in fact i had tried this before with the mtget struct and i get 0s. Only the drive type gives a number: 52. Thanks for the try i will have to hunt down the sample code for mt if available.