SMCIOC_READ_CARTIDGE_LOCATION
The SMCIOC_READ_CARTIDGE_LOCATION IOCTL is
used to return the cartridge location information for storage elements
in the library. The element_address field specifies
the starting element address to return. The number_elements field
specifies how many storage elements are returned. The data field
is a pointer to the buffer for return data. The buffer must be large
enough for the number of elements that are returned. If the storage
element contains a cartridge, then the ASCII identifier field
in return data specifies the location of the cartridge.
Note: This
IOCTL is supported only on the TS3500 (3584) library.
The data structures that are used with this IOCTL are
struct cartridge_location_data
{
ushort address; /* element address */
uint :4, /* reserved */
access:1, /* robot access allowed */
except:1, /* abnormal element state */
:1, /* reserved */
full:1; /* element contains medium */
uchar resvd1; /* reserved */
uchar asc; /* additional sense code */
uchar ascq; /* additional sense code qualifier */
uchar resvd2[3]; /* reserved */
uint svalid:1, /* element address valid */
invert:1, /* medium inverted */
:6; /* reserved */
ushort source; /* source storage element address */
uchar volume[36]; /* primary volume tag */
uint :4, /* reserved */
code_set:4; /* code set X'2' is all ASCII identifier */
uint :4, /* reserved */
ident_type:4; /* identifier type */
uchar resvd3; /* reserved */
uchar ident_len; /* identifier length */
uchar identifier[24]; /* slot identification */
};
struct read_cartridge_location
{
ushort element_address; /* starting element address */
ushort number_elements; /* number of elements */
struct cartridge_location_data *data; /* storage element pages */
char reserved[8]; /* reserved */
};
Example of the SMCIOC_READ_CARTRIDGE_LOCATION IOCTL
#include <sys/Atape.h>
int i;
struct cartridge_location_data *data, *elemp;
struct read_cartridge_location cart_location;
struct element_info element_info;
/* get the number of slots and starting element address */
if (ioctl(fd, SMCIOC_ELEMENT_INFO, &element_info) < 0)
return errno;
if (element_info.slots == 0)
return 0;
data = malloc(element_info.slots * sizeof(struct cartridge_location_data));
if (data == NULL)
return ENOMEM;
/* Read cartridge location for all slots */
bzero(data,element_info.slots * sizeof(struct cartridge_location_data));
cart_location.data = data;
cart_location.element_address = element_info.slot_addr;
cart_location.number_elements = element_info.slots;
if (ioctl (fd, SMCIOC_READ_CARTRIDGE_LOCATION, &cart_location) < 0)
{
free(data);
return errno;
}
elemp = data;
for (i = 0; i < element_info.slots; i++, elemp++)
{
if (elemp->address == 0
) continue;
printf("Slot Address %d\n",elemp->address);
if (elemp->except)
printf(" Slot State ..................... Abnormal\n");
else
printf(" Slot State ..................... Normal\n");
printf(" ASC/ASCQ ....................... %02X%02X\n",
elemp->asc,elemp->ascq);
if (elemp->full)
printf(" Media Present .................. Yes\n");
else
printf(" Media Present .................. No\n");
if (elemp->access)
printf(" Robot Access Allowed ........... Yes\n");
else
printf(" Robot Access Allowed ........... No\n");
if (elemp->svalid)
printf(" Source Element Address ......... %d\n",elemp->source);
else
printf(" Source Element Address Valid ... No\n");
if (elemp->invert)
printf(" Media Inverted ................. Yes\n");
else
printf(" Media Inverted ................. No\n");
printf(" Volume Tag ..................... %0.36s\n", elemp->volume);
printf(" Cartridge Location ............. %0.24s\n", elemp->identifier);
} free(data);
return 0;