int _tmf_bksp(struct fdinfo *fio, struct ffsw *stat) { struct tmfio *xf_info; register int ret; int usertm; xf_info = (struct tmfio *)fio->lyr_info; if (xf_info->tmf_tpos) { if (_tmf_tpwait (xf_info) < 0) { ERETURN(stat, errno, 0); } } /* * If the file's been writing, flush out any unwritten data. */ if (xf_info->rwflag == WRITIN) { if (_tmf_flush(fio, stat) < 0) { return(ERR); } } /* * Now backspace. */ ret = _tmf_stpos(fio, FP_TPOS_BACK, 1, 0, 0, 0, &usertm, stat); if (ret < 0 && stat->sw_error != ETBOF) return(ERR); xf_info->rwflag = POSITIN; return(0); }
/* * Skip file. * Note that this has slightly different meaning that skip tape mark. * Except in the case where you request positioning past EOD, * _tmp_skipf will position you at the beginning of a file. That is, * _tmf_skipf will position you either at BOD, immediately after a * user tape mark, or at EOD. */ int _tmf_skipf( struct fdinfo *fio, long nb, int *count, struct ffsw *stat) { int rescnt; int usertm; struct tmfio *xf_info; xf_info = (struct tmfio *)fio->lyr_info; *count = 0; if (nb == 0) { /* Position to 0. This will cause us to wait for */ /* any outstanding positioning, to flush any unwritten data, */ /* and if we're ever doing */ /* read-ahead it will clear that out. */ if (_tmf_stpos(fio, FP_TPOS_BACK, 0, 0, 0, 0, &usertm, stat) < 0) { return(ERR); } return(0); } else if (nb > 0) { /* Positioning forward nb files.*/ /* First position to 0. This will cause us to wait for */ /* any outstanding positioning, to flush any unwritten data, */ /* and if we're ever doing read-ahead it will */ /* clear that out. */ if (_tmf_stpos(fio, FP_TPOS_BACK, 0, 0, 0, 0, &usertm, stat) < 0) { return(ERR); } if (xf_info->tmf_rwtpmk == 0) { /* No user tape marks */ ERETURN(stat, FETASKPF, 0); } if (_tmf_skiptpmk(xf_info->tmf_fd, nb, &rescnt, stat) < 0) { if (stat->sw_error != ETEOF) { return(ERR); } } *count = nb - rescnt; } else { /* Positioning back nb files */ /* First position back 1 record. If we were */ /* immediately after a tapemark, then this */ /* will put us in the previous file. */ if (_tmf_stpos(fio, FP_TPOS_BACK, 1, 0, 0, 0, &usertm, stat) < 0) { if (stat->sw_error == ETBOF) { return(0); } return(ERR); } if (xf_info->tmf_rwtpmk == 0) { /* No user tape marks, just rewind */ if (_tmf_seek(fio,0,0,stat) < 0) { *count = -nb; return(ERR); } *count = 0; return(0); } /* Now position back nb files */ if (_tmf_skiptpmk(xf_info->tmf_fd, nb, &rescnt, stat) == 0) { /* Move to the other side of this tape mark */ int ut; if (_tmf_stpos(fio, FP_TPOS_FORW, 1, 0, 0, 0, &ut, stat) < 0) { return(ERR); } } else { if (stat->sw_error != ETBOF) { return(ERR); } } *count = -nb - rescnt; if (usertm == 0) { /* The user was positioned in the middle of a file. */ if (*count > 0) *count = *count - 1; } } return(0); }