Beispiel #1
0
_bmx_checktp(BMXFIL *f,  long *istat, long *icbuf)
{
	struct tsdata tsdata;
	int  ret;


	if (f->bmx_flag & BMXIO_EOV)
		ret = _bmx_wait(f);	/* Wait for i/o to be quiet */
	else
		ret = 0;

	*icbuf = 0;

	if ((f->bmx_flag & BMXIO_SPPROC)||(f->bmx_flag & BMXIO_ERRSEEN) ) {
/*
 *		If we are in special processing, or if our last i/o
 *		returned an error, we need to get information about
 *		blank tape, and tape off reel from the system.
 */
		if(_tape_tptsi(&(f->tsireq), &tsdata, NULL)){
			return(-1);
		}
		if (tsdata.ts_dst & STS_LDTA)
			*istat = 1;	/* tape off reel */

/*
 *		If we are in special processing, get EOV status from
 *		the system. This is because once we enter special processing,
 *		the libraries no longer get an EOV error from writes or reads.
 */
		else if ((f->bmx_flag & BMXIO_SPPROC) &&((tsdata.ts_dst & STS_EOT) != 0))
			*istat = 0; 	/* EOV */
		else if (!(f->bmx_flag & BMXIO_SPPROC) && 
		  (f->bmx_flag & BMXIO_EOVSEEN))
			*istat = 0; 	/* EOV */
		else if (tsdata.ts_dst & STS_BTP)
			*istat = 3;	/* blank tape detected */
		else if (f->bmx_flag & BMXIO_TPMK)
			*istat = 2;	/* tape mark read */
		else
			*istat = -1;	/* no status */
	}
	
	else if (f->bmx_flag & BMXIO_EOVSEEN)
		*istat = 0;	/* eov */
	else if (f->bmx_flag & BMXIO_TPMK)
		*istat = 2;	/* tape mark read */
	else
		*istat = -1;	/* no status */
	if ((ret == -1) && (*istat != 3) && (*istat != 1)){
			/* _bmx_wait failed, and the cause was not */
			/* blank tape or tape off reel */
		return(-1);
	}
	return(0);
}
Beispiel #2
0
_er90b_gettp(struct fdinfo *fio, long *pa, long palen, long synch)
{
	ER90BYT *f;
	struct tsdata	tsdata;
	int 		vsn[MAXVSN];

	f = (ER90BYT *)fio->lyr_info;
	if ( f->tpos ) {
		if( _tape_tpwait( f->fd, &(f->tpos) ) != 0)
			return(-1); 
	}

	if (synch == 1 && fio->rwflag == WRITIN) {
		if(_tape_sync(f->fd) != 0)
			return(-1);
	}

	if( _tape_tptsi (&(f->tsireq), &tsdata, vsn) != 0)
		return(-1);
	_tape_gtpos(&tsdata, vsn, 0, pa, palen);
	return(0);
}
Beispiel #3
0
_er90b_stpos(struct fdinfo *fio, long nbs, long nb, long nvs, long nv, long vi, ...)
{
    register int	  nb_request, lstcnt, lib = 0;
    struct bmxlist	*lstptr;
    long	pa[12];
    struct tsdata tsi;
    int ret = 0;
    struct bmxio *ptr;
    struct bmxpos ctl;
    int zro;
    va_list args;
    ER90BYT *f;


    /* it is the user's responsibility to wait for outstanding i/o */

    f = (ER90BYT *)fio->lyr_info;
    if ( nb != 0 ) {
        if (nbs == FP_TPOS_BACK ) {
            nb = -nb;
        } else if ( nbs == FP_TPOS_ABS ) {
            if ( (nv == 0) && (vi == 0) ) {
                /*
                 *				Convert absolute block number to
                 *				relative block number from current
                 *				position. First find current position.
                 */
                if (_er90b_gettp(fio,pa,12,1)!= 0)
                    RETURN(-1);
                /*
                 *				The tape subsystem adjusts for the blocks
                 *				in the IOS.
                 *				pa[9] = block number. pa[11] = blocks in IOS
                 */
                nb = nb -(pa[9]-pa[11]);
            }
            nb -=1;	/* absolute block numbers start with 1 */
            lib = 0;
        }
        nb_request = nb - lib;
    } else {
        if ((nv == 0) && (vi == 0))
            nb_request = nb - lib;
        else
            nb_request = 0;
    }

    if ( nv > 0 ) {
        /* Handle positioning by volume */
        if (nbs != FP_TPOS_ABS) {
            errno = FETAPCMB;
            RETURN(-1);
        }

        if (nvs != FP_TPOS_ABS) {
            if (_tape_tptsi(&(f->tsireq), &tsi, NULL)) {
                RETURN(-1);
            }
            if (nvs == FP_TPOS_BACK) {
                nv = tsi.ts_cvsn - nv +1;
                if (nv <= 0) {
                    errno = FETAPNVY;
                    RETURN(-1);
                }
            }
            else { /* must be FP_TPOS_FORW */
                nv = tsi.ts_cvsn + nv +1;
                if (nv > tsi.ts_numvsn) {
                    errno = FETAPNVY;
                    RETURN(-1);
                }
            }
        }
        ctl.pos_fcn = TR_PVOL;
        ctl.pos_count = nv;
        if(_er90_tpv (f->fd, &ctl )) {
            RETURN(-1);
        }

        /* Position to the correct block */
        if ( nb_request != 0 ) {
            if(_er90_tpblk(f->fd,nb_request)) {
                RETURN(-1);
            }
        }

    } else if ( vi != 0 ) {

        ctl.pos_fcn = TR_PVSN;
        ctl.pos_vsn = vi;
        ctl.pos_count = 0;

        if (_er90_tpv (f->fd, &ctl )) {
            RETURN(-1);
        }

        /* Position to the correct block */
        if ( nb_request != 0 ) {
            if(_er90_tpblk(f->fd, nb_request)) {
                RETURN(-1);
            }
        }

    } else {
        if(_er90_tpblk(f->fd,nb_request)) {
            RETURN(-1);
        }
    }

done:
    return(ret);

}