From 45087999c49f9c68d1a7eee13b39f4b727972d84 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 29 Dec 2003 19:58:48 +0000 Subject: [PATCH] Fix btape test for TWO EOF + use driver idea of file in fsf_dev git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@969 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/stored/btape.c | 9 +++++++++ bacula/src/stored/dev.c | 17 +++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index aca13e57e9..d596e0afd2 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -724,6 +724,9 @@ static int append_test() wrcmd(); wrcmd(); weofcmd(); /* end file 2 */ + if (dev_cap(dev, CAP_TWOEOF)) { + weofcmd(); + } rewindcmd(); Pmsg0(0, _("Now moving to end of medium.\n")); eodcmd(); @@ -737,6 +740,9 @@ static int append_test() Pmsg0(-1, _("\nNow the important part, I am going to attempt to append to the tape.\n\n")); wrcmd(); weofcmd(); + if (dev_cap(dev, CAP_TWOEOF)) { + weofcmd(); + } rewindcmd(); Pmsg0(-1, _("Done appending, there should be no I/O errors\n\n")); Pmsg0(-1, "Doing Bacula scan of blocks:\n"); @@ -909,6 +915,9 @@ static int fsf_test() weofcmd(); /* end file 3 */ wrcmd(); weofcmd(); /* end file 4 */ + if (dev_cap(dev, CAP_TWOEOF)) { + weofcmd(); + } test_again: rewindcmd(); diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 23ae650208..2dc51f42b6 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -469,8 +469,15 @@ eod_dev(DEVICE *dev) * to set EOD or to turn off CAP_FASTFSF if on. */ if (file_num == (int)dev->file) { + struct mtget mt_stat; Dmsg1(000, "fsf_dev did not advance from file %d\n", file_num); - return 0; /* we are not progressing, bail out */ + if (ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) == 0 && + mt_stat.mt_fileno >= 0) { + Dmsg2(000, "Adjust file from %d to %d\n", dev->file , mt_stat.mt_fileno); + dev->file = mt_stat.mt_fileno; + } + stat = 0; + break; /* we are not progressing, bail out */ } } } @@ -484,9 +491,11 @@ eod_dev(DEVICE *dev) /* Backup over EOF */ stat = bsf_dev(dev, 1); /* If BSF worked and fileno is known (not -1), set file */ - if (stat == 0 && ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) == 0 && - mt_stat.mt_fileno >= 0) { + if (ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) == 0 && mt_stat.mt_fileno >= 0) { + Dmsg2(000, "Adjust file from %d to %d\n", dev->file , mt_stat.mt_fileno); dev->file = mt_stat.mt_fileno; + } else { + dev->file++; /* wing it -- not correct on all OSes */ } } else { update_pos_dev(dev); /* update position */ @@ -560,7 +569,7 @@ status_dev(DEVICE *dev, uint32_t *status) } if (dev->state & ST_TAPE) { stat |= BMT_TAPE; - Dmsg0(-20," Driver status:"); + Dmsg0(-20," Bacula status:"); Dmsg2(-20," file=%d block=%d\n", dev->file, dev->block_num); if (ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) < 0) { dev->dev_errno = errno; -- 2.39.5