VMS Help  —  MRD Library, mrd_prevent_allow
    mrd_prevent_allow - Send a Prevent/Allow Media Removal command

    Windows NT         mrd.dll
    UNIX               /usr/lib/libmrd.a
    OpenVMS            MRD$RTL.EXE

    #include <mrd_common.h>
    #include <mrd_message.h>

    int mrd_prevent_allow(
        robot_info_t *robot_info,
        int           lock,
        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  lock The lock argument indicates whether media removal should
       be prevented or allowed.

    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 Prevent/Allow Media Removal. It is
    used by mrd_lock(3mrd). The robot_info argument is the address of
    a robot_info_t that has been opened by mrd_startup(3mrd).

    When a lock value of one (1) is specified media removal is
    prevented. When the value zero (0) is used, media removal is
    allowed. If other values for lock are used, the routine will
    create a status which corresponds to an illegal request.

    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

    /*
     *   This is an example of using mrd_prevent_allow(3mrd) to
     *   prevent or allow media removal, where allowed.  For
     *   robot name on the command line, the desired version
     *   of the command will be used according lock value.
     *   name.
     *
     *   Usage:
     *
     *      mrd_prevent_allow lock-value robot [ robot... ]
     */
    #ifndef   lint
    static   char   SccsId[] = "@(#)mrd_prevent_allow.c   1.2 3/5/97" ;
    #endif

    #include <stdio.h>
    #include <stdlib.h>
    #include <mrd_common.h>
    #include <mrd_message.h>

    main(int argc, char *argv[])
    {
       int      rc ;      /* Counter */
       int      lock ;      /* Lock value */
       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 < 3 ) {
          printf("usage: %s lock-value robot [ robot... ]\n", argv[0]) ;
          exit(1) ;
       }
       else
          lock  = atoi(argv[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 = 2; rc < argc; rc++) {
          /*
           *   The robot for this command.
           */
          robot = argv[rc] ;

          status = mrd_startup(robot, &robot_info, log_info) ;

          if( status != MRD_STATUS_SUCCESS ) {
             printf("Startup failed on %s: %s.\n", robot,
                mrd_strstatus(status)) ;

             continue ;
          }

          printf("Lock value %d on %s.\n", lock, robot) ;

          status = mrd_prevent_allow(&robot_info, lock, &dev_status) ;

          if( status != MRD_STATUS_SUCCESS )
             printf("Prevent/Allow failed on %s: %s.\n", robot,
                mrd_strstatus(status)) ;

          (void)mrd_shutdown(&robot_info) ;
       }

       return 0 ;
    }

4  –  Return Values

    Upon successful completion, mrd_prevent_allow(3mrd) will return
    MRD_STATUS_SUCCESS. On a failure, one of the following status
    values will be returned.

4.1  –  MRD_STATUS_PARAM

    This error is returned if the robot_info or dev_status arguments
    are NULL pointers.

4.2  –  MRD_STATUS_ROBOT_ILLEGAL_REQUEST

    This error occurs when the medium changer does not support the
    Prevent/Allow Medium Removal command or the lock value is not one
    or zero. The specific cause can be determined by examining the
    ASC/ASCQ values in the status data.

    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_lock(3mrd)
Close Help