The device drivers provide application a friendly interface GET_VHF_DEVICE_STATUS to report the tape drive and medium statuses. (VHF is short Very High Frequency).

The structure for the GET_VHF_DEVICE_STATUS ioctl is
struct get_vhf_device_status
uchar pamr; /* [OUT] prevent/allow medium removal */
uchar hiu; /* [OUT] host initialed unload */
uchar macc; /* [OUT] medium auxiliary memory (MAM) accessible */
uchar cmpr; /* [OUT] data compress is enabled */
uchar wrtp; /* [OUT] volume is physically write protected when mprsnt is on */
uchar crqst; /* [OUT] cleaning requested */
uchar crqrd; /* [OUT] cleaning required */
uchar dinit; /* [OUT] this VHF data valid or invalid */
uchar inxtn; /* [OUT] device is transitioning to another state */
uchar rsvd1;
uchar raa; /* [OUT] robotic access allowed */
uchar mprsnt; /* [OUT] medium present */
uchar rsvd2;
uchar mstd; /* [OUT] medium seated */
uchar mthrd; /* [OUT] medium threaded */
uchar mounted; /* [OUT] medium is mounted */
uchar dev_act; /* [OUT] the current activity of the device below */
/* 00h No DT device activity
01h Cleaning operation in progress
02h Medium is being loaded
03h Medium is being unloaded
04h Other medium activity
05h Reading from medium
06h Writing to medium
07h Locating medium
08h Rewinding medium
09h Erasing medium
0Ah Formatting medium
0Bh Calibrating medium
0Ch Other DT device activity
0Dh Microcode update in progress
0Eh Reading encrypted from medium
0Fh Writing encrypted to medium */
uchar vs;
uchar rsvd3;
uchar tddec; /* [OUT] tape diagnostic data entry created */
uchar epp; /* [OUT] encryption parameters present */
uchar esr; /* [OUT] encryption service request */
uchar rrqst; /* [OUT] recovery requested */
uchar intfc; /* [OUT] interface changed */
uchar tafc; /* [OUT] tape alert state flag changed */
/* the fields below for LTO only */
uchar rsvd4[6];
uchar overwrite; /* [OUT] overwrite occurs and write mode isn't in append-only
mode */
uchar pcl_p; /* [OUT] potential conflict list present */
uchar rsvd5[6];
uchar hostlogin; /* [OUT] host login has occurred */
uchar sleepmode; /* [OUT] operating in one of the low power states */
char reserved[15];
Note: IBM tape drivers reports the data from the tape drive. The device drivers still return no error on this ioctl when the tape drive returns a good SCSI status even though VHF data is invalid, so the application must determine if the data is valid before to use it. The variable of dinit indicates this VHF data valid or invalid. The variable of wrtp shows a volume is physically write protected only when mprsnt is ON.
An example of the GET_VHF_DEVICE_STATUS command is
#include <sys/Atape.h>
int rc;
struct get_vhf_device_status qvhf;
bzero(&qvhf,sizeof(struct get_vhf_device_status));
rc = ioctl(fd,GET_VHF_DEVICE_STATUS,&qvhf);
if (rc)
printf("GET_VHF_DEVICE_STATUS fails with rc %d\n",rc);
printf ("GET_VHF_DEVICE_STATUS Command Succeeds");
return rc;