STIOC_SET_ACTIVE_PARTITION
This IOCTL allows the user to specify the partition on which to run subsequent tape operations.
The data structure that is used for this IOCTL
is
struct set_active_partition {
unchar partition_number;
unsigned long long logical_block_id;
char reserved[32];
};
- partition_number is the number of the requested active partition.
- logical_block_id is the requested block position within the new active partition.
An example of the STIOC_SET_ACTIVE_PARTITION IOCTL
is
int stioc_set_partition()
{
int rc = 0;
struct set_active_partition set;
char* input = NULL;
input = malloc(DEF_BUF_SIZE / 16);
if(!input) {
rc = ENOMEM;
goto EXIT_LABEL;
} /* if */
memset(input, '\0', DEF_BUF_SIZE / 16);
memset(&set, '\0', sizeof(struct set_active_partition));
while(input[0] < '0' || input[0] > '9') {
printf("Select partition (< 0 to cancel): ");
fgets(input, DEF_BUF_SIZE / 16, stdin);
if(input[0] == '-' && atoi(&input[1]) > 0) {
rc = 0;
goto EXIT_LABEL;
} /* if */
if(atoi(input) > MAX_PARTITIONS) {
printf("Please select number < %d\n", MAX_PARTITIONS);
input[0] = '\0';
} /* if */
} /* while */
set.partition_number = atoi(input);
printf("Issuing IOCTL...\n");
rc = ioctl(fd, STIOC_SET_ACTIVE_PARTITION, &set);
if(rc) {
printf("Set partition failed: %d\n", rc);
goto EXIT_LABEL;
} /* if */
EXIT_LABEL:
if(input) free(input);
return rc;
} /* stioc_set_partition() */