Annotation of researchv10no/cmd/worm/oscsi/unload.c, revision 1.1

1.1     ! root        1: #include       <stdio.h>
        !             2: #include       <stddef.h>
        !             3: #include       <string.h>
        !             4: #include       "scsi.h"
        !             5: #include       "juke.h"
        !             6: 
        !             7: j_unload(char *vol_id, char *buf)
        !             8: {
        !             9:        Side side;
        !            10:        int i, sh, dr;
        !            11:        char disk_to_unload[256];
        !            12: 
        !            13:        if(j_rdshelves(buf))    /* read in shelf names */
        !            14:                return(-1);
        !            15:        if(j_getstatus(buf))    /* get the jukebox status */
        !            16:                return(-1);
        !            17:        /* now check which side we want */
        !            18: 
        !            19:        strcpy(disk_to_unload, vol_id);
        !            20:        side = SIDEA;
        !            21:        sh = j_shelfof(disk_to_unload);
        !            22:        if(sh < 0){
        !            23:                sprintf(buf, "can not find vol_id %s", disk_to_unload);
        !            24:                return(-1);
        !            25:        }
        !            26:        dr = -1;
        !            27:        for(i = 0; i < NLUN; i++){
        !            28:                printf("dr:.. %d  ", i);
        !            29:                printf(" rtsh: %d\n", j_status.lun[i].retshelf);
        !            30: 
        !            31:                /* is sh = retshelf? */
        !            32: 
        !            33:                if( (j_status.lun[i].retshelf>>1 == sh) ||
        !            34:                                        (j_status.lun[i].retshelf == sh*2+1) ){                                         dr = i; 
        !            35:                                break;
        !            36:                } }
        !            37:        printf("dr: %d, sh: %d, side: %d, i: %d\n", dr, sh, side, i);
        !            38:        if (dr == -1){
        !            39:                sprintf(buf, "no drive has vol_id %s", disk_to_unload);
        !            40:                return(-1);
        !            41:        }
        !            42:        /* put vol_id in it's shelf*/   
        !            43:        if (j_drive_to_shelf(dr, sh, side, buf) >= 0){
        !            44:                sprintf(buf,"/dev/worm%d\n", dr);
        !            45:                return(0);
        !            46:        }
        !            47:        return(-1);     
        !            48: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.