From 1733220244e41e180cfe5aa2213b45b5c2c0cf9f Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 22 Jul 2017 18:09:19 +0200 Subject: [PATCH] Fix btape test which counted files incorrectly on EOT --- bacula/src/stored/btape.c | 17 ++++++++--------- bacula/src/stored/tape_dev.c | 3 +++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index f6e50c1a12..e88a9b7934 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -1966,7 +1966,7 @@ static void scancmd() blocks = block_size = tot_blocks = 0; bytes = 0; - if (dev->state & ST_EOT) { + if (dev->at_eot()) { Pmsg0(0, _("End of tape\n")); return; } @@ -2009,18 +2009,17 @@ static void scancmd() dev->update_pos(dcr); printf(_("End of File mark.\n")); /* Two reads of zero means end of tape */ - if (dev->state & ST_EOF) - dev->state |= ST_EOT; - else { - dev->state |= ST_EOF; - dev->file++; + if (dev->at_eof()) { + dev->set_ateot(); + } else { + dev->set_ateof(); } - if (dev->state & ST_EOT) { + if (dev->at_eot()) { printf(_("End of tape\n")); break; } } else { /* Got data */ - dev->state &= ~ST_EOF; + dev->clear_eof(); blocks++; tot_blocks++; bytes += stat; @@ -2057,7 +2056,7 @@ static void scan_blocks() for (;;) { if (!dcr->read_block_from_device(NO_BLOCK_NUMBER_CHECK)) { Dmsg1(100, "!read_block(): ERR=%s\n", dev->bstrerror()); - if (dev->state & ST_EOT) { + if (dev->at_eot()) { if (blocks > 0) { if (blocks==1) { printf(_("1 block of %d bytes in file %d\n"), block_size, dev->file); diff --git a/bacula/src/stored/tape_dev.c b/bacula/src/stored/tape_dev.c index 908149a8d3..cb5e9b7499 100644 --- a/bacula/src/stored/tape_dev.c +++ b/bacula/src/stored/tape_dev.c @@ -1059,6 +1059,9 @@ bool tape_dev::mount_tape(int mount, int dotimeout) void tape_dev::set_ateof() { + if (at_eof()) { + return; + } DEVICE::set_ateof(); file++; } -- 2.39.5