/* * Example mrd_eject(3mrd). * * This example is slightly different from the others since it * also demonstrates the Eject Port feature of mrd_eject(3mrd). * This feature can be used on the TL820 family to move a tape * from the Pass-through mechanism (PTM) to the outport. * * The command usage is: * * mrd_eject robot [ slot port [ volume_tag ] ] */ #ifndef lint static char SccsId[] = "@(#)mrd_eject.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 status ; /* Status from mrd_eject(3mrd) */ char *robot ; /* Name of the robot to use */ char *volume_tag = NULL ; /* Volume tag to check */ char *slot ; /* Source slot */ char *port ; /* Destination port */ char log_info[MRD_MAX_LOG_STRING+1] ; /* Error text */ /* * Allow the command to only have the robot name specified. */ if( argc < 2 ) { printf("usage: %s robot [ slot port [ volume_tag ] ]\n", argv[0]) ; exit(1) ; } else robot = argv[1] ; /* * If the slot and port aren't specified assume that * the target robot is a TL820 and fill in default * values for an Eject Port. Otherwise take the * desired values directly from the command line. */ if( argc >= 4 ) { slot = argv[2] ; port = argv[3] ; /* * Collect the volume_tag name if the user wants it. */ if( argc > 4 ) volume_tag = argv[4] ; } /* * We also observe that this case catches the command: * * mrd_eject robot_name address * * It can't hurt to let the user specify the outport, * since an invalid one simply won't work. In this case * the 3rd argument is the port name instead of the slot * name. * * The user could get the same affect by using a quoted * empty string for the slot argument on the command line: * * robot /dev/mc54 "" 1 */ else { if( argc == 3 ) port = argv[2] ; else port = "1" ; slot = "" ; } /* * Do the operation. */ status = mrd_eject(robot, volume_tag, slot, port, log_info) ; if( status == MRD_STATUS_SUCCESS ) printf("Ejected the media in slot #%d to port #%d.\n", slot, port) ; else printf("Eject failed: %s: %s.\n", mrd_strstatus(status), log_info[0] ? log_info : "none") ; return 0 ; }