This IOCTL queries and displays information for tapes that support partitioning. The data structure that is used for this IOCTL is
#define MAX_PARTITIONS 255
struct query_partition {
	unchar max_partitions;
	unchar active_partition;
	unchar number_of_partitions;
	unchar size_unit;
	ushort size[MAX_PARTITIONS];
	char reserved[32];
  • max_partitions is the maximum number of partitions that the tape allows.
  • active_partition is the current partition to which tape operations apply.
  • number_of_partitions is the number of partitions currently on the tape.
  • size_unit describes the units for the size of the tape, which is given as a logarithm to the base 10.
For example, 0 refers to 10^0 = 1, the most basic unit, which is bytes. All sizes that are reported are in bytes. 3 refers to 10^3, or kilobytes. Size is an array of the size of the partitions on tape, one array element per partition, in size_units.
int stioc_query_partition()
struct query_partition qry;
int rc = 0, i = 0;

memset(&qry, '\0', sizeof(struct query_partition));
 	printf("Issuing IOCTL...\n");
rc = ioctl(fd, STIOC_QUERY_PARTITION, &qry);

  if(rc) {
     	printf("Query partition failed: %d\n", rc);
   	goto EXIT_LABEL;
 } /* if */

 printf("\nmax possible partitions: %d\n", qry.max_partitions);
 printf("number currently on tape: %d\n", qry.number_of_partitions);
 printf("active: %d\n", qry.active_partition);
 printf("unit: %d\n", qry.size_unit);

 for(i = 0; i < qry.number_of_partitions; i++)
   	printf("size[%d]: %d\n", i, qry.size[i]);


 return rc;
 } /* stioc_query_partition() */