mrd_initialize_element - Force a robot inventory operation
Windows NT mrd.dll
UNIX /usr/lib/libmrd.a
OpenVMS MRD$RTL.EXE
#include <mrd_common.h>
#include <mrd_message.h>
int mrd_initialize_element(
robot_info_t *robot_info,
dev_status_t *dev_status) ;
1 – Parameters
o robot_info - This is the address of a robot_info_t structure
initialized using mrd_startup(3mrd) or mrd_show(3mrd). This
data structure contains the element starting address and
counts for each type of element, which are needed to map an
absolute element to the correct zero relative address and
type.
o dev_status - The dev_status is the address of a dev_status_
t structure, which is used to pass back detailed error
information in the event of a command failure.
2 – Description
This routine performs a SCSI Initialize Element Status command.
It is used by mrd_initialize(3mrd). On supported medium changers
this typically causes the medium changer to perform a physical
inventory of its contents. This routine can take a long time to
complete. The longest time ever observed on a supported medium
changer was approximately 23 minutes on an empty TL820 with all
bin-packs in place. The DLT and RDAT changers may take only a few
seconds.
The robot_info argument is the address of a robot_info_t that has
been opened by mrd_startup(3mrd).
This routine uses the dev_status_t structure for handing errors.
The dev_status_t structure includes the code, os_status, and SCSI
error fields. The following describes how to decode errors with
the dev_status_t structure.
SCSI Errors
SCSI errors are indicated when the value of the valid field of
the SCSI error is not equal to 0. The key, asc, and ascq fields
provide additional information to help determine the cause of the
error.
The code usually maps the Additional Sense Code and Additional
Sense Code Qualifier (ASC/ASCQ) values to an MRD error. The asc
and ascq values are copied from the request sense data returned
by the target.
The Additional Sense Code (asc) indicates further information
related to the error or exception condition reported in the sense
key field. The Additional Sense Code Qualifier (ascq) indicates
detailed information related to the additional sense code. For
more information, consult the SCSI-2 Specification.
Operating System Errors
Operating system errors are indicated when the value of the valid
field of the SCSI error is equal to 0 and the value of the os_
status field is not equal to 0. This result is most likely caused
by an operating system error, and probably has a mapped error in
MRD.
MRD Errors
MRD errors are indicated when the value of the os_status field is
0, and the value of the valid field of the SCSI error is 0. This
result is most likely caused when MRD encounters its own failure.
3 – Example
/*
* Example of mrd_initialize_element(3mrd). The command usage is:
*
* Usage:
*
* mrd_initialize_element robot [ robot... ]
* robot_name
*
* It has been observed on an empty TL820 with all the bin-packs
* in place that this command takes just under 23 minutes.
*/
#ifndef lint
static char SccsId[] = "@(#)mrd_initialize_element.c 1.3) 6/20/97";
#endif
#include <stdio.h>
#include <stdlib.h>
#include <mrd_common.h>
#include <mrd_message.h>
main(int argc, char *argv[])
{
int rc ;
int status ; /* return status */
char *robot ; /* Robot to open */
robot_info_t robot_info ; /* Robot data */
dev_status_t dev_status ; /* Device status */
char log_info[MRD_MAX_LOG_STRING+1] ;
/*
* Check that there are enough arguments.
*/
if( argc < 4 ) {
printf("usage: %s robot [ robot... ]\n", argv[0]) ;
exit(1) ;
}
/*
* Initialize the channel field of the robot_info, so
* mrd_startup(3mrd) will actually open the robot.
*/
robot_info.channel = BAD_CHANNEL ;
for(rc = 1; rc < argc; rc++) {
/*
* Save the current robot name.
*/
robot = argv[rc] ;
status = mrd_startup(robot, &robot_info, log_info) ;
if( status != MRD_STATUS_SUCCESS ) {
printf("Startup failed: %s: %s.\n",
mrd_strstatus(status),
log_info[0] ? log_info : "none") ;
continue ;
}
printf("Initialize Element Status on %s...", robot) ;
fflush(stdout) ;
status = mrd_initialize_element(&robot_info, &dev_status) ;
if( status != MRD_STATUS_SUCCESS )
printf("Failed: %s.\n", mrd_strstatus(status)) ;
else
printf("Success.\n") ;
(void)mrd_shutdown(&robot_info) ;
}
return 0 ;
}
4 – Return Values
Upon successful completion mrd_initialize_element(3mrd) will
return MRD_STATUS_SUCCESS. On a failure, an MRD_STATUS value
corresponding to the error will be returned. Common errors are:
4.1 – MRD_STATUS_PARAM
This error is returned if the robot_info or dev_status arguments
are NULL pointers. The dev_status structure is unchanged, even if
a valid address is provided.
4.2 – MRD_STATUS_ROBOT_ILLEGAL_REQUEST
This error occurs when the medium changer does not support the
Initialize Element Status command.
It is also used for a SCSI command failure, when the ASC is set
to one of:
o 0x1A - Parameter list length error
o 0x20 - Invalid command operation code
o 0x22 - Unsupported command
o 0x24 - Illegal field in CDB
o 0x25 - Logical unit not supported
o 0x26 - Threshold parameters not supported
o 0x28 - Import or Export element accessed
o 0x2C - Command sequence error
o 0x39 - Saving parameters not supported
o 0x3D - Invalid bits in Identify message
o 0x53 - Medium removal prevented
This status is also returned when the ASC and ASCQ are zero, but
the key is five (5).
4.3 – MRD_STATUS_IVCHAN
This error code is used when an OpenVMS system service fails
with the status SS$_IVCHAN. It is likely when an operating system
specific routine is used on a device that hasn't been opened by
mrd_startup(3mrd).
5 – Related Functions
Functions:
mrd_initialize(3mrd)