next up previous contents
Next: domt.c Up: Appendix B: An Previous: Example Makefile

tape.c

/****************************************************************
*        program tape.c                                         *
*                                                               *
*        modified        by        reason                       *
*        --------        --        ------                       *
*        24-Jun-92       cbl       orignal, to understand how   *
*                                 to ioctl functions.           *
*                                                               *
*        13-Jan-93       cbl      make a tape test function for *
*                                 magic.                        *
*        29-Jan-93       cbl      modified for testing stacker  *
****************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/mtio.h>
#include <rpc/rpc.h> 
#include "jukeclnt.h" 


#define MAXSLOT 10

int
main(int argv,char **argc)
{
        char *drive="tps0d3";
        char *rdrive="/dev/vtp/t2";
        int slot;                /* loop over slot.                        */
        int fd;                        /* file descriptor for open.        */

        extern int myjuke(char *chdrive,JGP_LOCATION slot,int command);
        extern int wait_for_tape (int fd);
        extern int domt(int fd,char iop,int num);
        extern void readit(int fd);

        if(argv>1) 
                drive=*(argc+1);        /* override default if necessary.*/

        for (slot=0 ; slot < MAXSLOT ; slot++) {
          printf(" Attempting to look at tape from slot %d\n",slot);
          if(myjuke(drive,slot,0)==0){; /* load tape from slot           */
            fd=open(rdrive,O_RDONLY);
            if(fd > 0 ) {               /* driver open.                  */
              wait_for_tape(fd);        /* wait for driver to be ready.  */
              readit(fd);               /* read first record.            */
              printf(" Unloading tape, be patient.\n");
              domt(fd,MTUNLOAD,1);      /* unload tape.                  */
              close(fd);                /* close up driver.              */
              printf(" Relocating in tray tape, be patient.\n");
              myjuke(drive,slot,1);     /* unload tape from slot         */
            } 
          } else
            printf(" slot %d empty ",slot);

        }
        printf("\n End of Program. \n");
}



Marc Mengel
Wed May 29 11:09:46 CDT 1996