+/*
+ Bacula® - The Network Backup Solution
+
+ Copyright (C) 2002-2008 Free Software Foundation Europe e.V.
+
+ The main author of Bacula is Kern Sibbald, with contributions from
+ many others, a complete list can be found in the file AUTHORS.
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version two of the GNU General Public
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Bacula® is a registered trademark of Kern Sibbald.
+ The licensor of Bacula is the Free Software Foundation Europe
+ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+ Switzerland, email:ftf@fsfeurope.org.
+*/
/*
*
* This routine provides a routine that will handle all
*
* Version $Id$
*/
-/*
- Copyright (C) 2000-2006 Kern Sibbald
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as amended with additional clauses defined in the
- file LICENSE in the main source directory.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- the file LICENSE for additional details.
-
- */
#include "bacula.h"
#include "stored.h"
static char *rec_state_to_str(DEV_RECORD *rec);
#endif
-static const int dbglvl = 1000;
+static const int dbglvl = 500;
+/*
+ * This subroutine reads all the records and passes them back to your
+ * callback routine (also mount routine at EOM).
+ * You must not change any values in the DEV_RECORD packet
+ */
bool read_records(DCR *dcr,
bool record_cb(DCR *dcr, DEV_RECORD *rec),
bool mount_cb(DCR *dcr))
DEV_RECORD *trec = new_record();
Jmsg(jcr, M_INFO, 0, _("End of Volume at file %u on device %s, Volume \"%s\"\n"),
dev->file, dev->print_name(), dcr->VolumeName);
+ volume_unused(dcr); /* mark volume unused */
if (!mount_cb(dcr)) {
Jmsg(jcr, M_INFO, 0, _("End of all volumes.\n"));
ok = false; /* Stop everything */
jcr->mount_next_volume = false;
/*
* The Device can change at the end of a tape, so refresh it
- * from the dcr.
+ * and the block from the dcr.
*/
dev = dcr->dev;
+ block = dcr->block;
/*
* We just have a new tape up, now read the label (first record)
* and pass it off to the callback routine, then continue
* most likely reading the previous record.
*/
read_block_from_device(dcr, NO_BLOCK_NUMBER_CHECK);
- read_record_from_block(block, trec);
+ read_record_from_block(dcr, block, trec);
handle_session_record(dev, trec, &sessrec);
ok = record_cb(dcr, trec);
free_record(trec);
continue;
} else if (dev->at_eof()) {
+#ifdef neeeded_xxx
if (verbose) {
- char dvdpart[100];
+ char *fp;
+ uint32_t fp_num;
if (dev->is_dvd()) {
- bsnprintf(dvdpart, sizeof(dvdpart), _("part %d "), dev->part);
+ fp = _("part");
+ fp_num = dev->part;
} else {
- dvdpart[0] = 0;
+ fp = _("file");
+ fp_num = dev->file;
}
- Jmsg(jcr, M_INFO, 0, _("End of file %u %son device %s, Volume \"%s\"\n"),
- dev->file, dvdpart, dev->print_name(), dcr->VolumeName);
+ Jmsg(jcr, M_INFO, 0, _("End of %s %u on device %s, Volume \"%s\"\n"),
+ fp, fp_num, dev->print_name(), dcr->VolumeName);
}
+#endif
Dmsg3(200, "End of file %u on device %s, Volume \"%s\"\n",
dev->file, dev->print_name(), dcr->VolumeName);
continue;
display_tape_error_status(jcr, dev);
if (forge_on || jcr->ignore_label_errors) {
dev->fsr(1); /* try skipping bad record */
- Pmsg0(000, _("Did fsr\n"));
+ Pmsg0(000, _("Did fsr in attemp to skip bad record.\n"));
continue; /* try to continue */
}
ok = false; /* stop everything */
rec->state = 0;
Dmsg1(dbglvl, "Block %s empty\n", is_block_empty(rec)?"is":"NOT");
for (rec->state=0; ok && !is_block_empty(rec); ) {
- if (!read_record_from_block(block, rec)) {
+ if (!read_record_from_block(dcr, block, rec)) {
Dmsg3(400, "!read-break. state=%s blk=%d rem=%d\n", rec_state_to_str(rec),
block->BlockNumber, rec->remainder);
break;
* he wants to know if they matched the bsr, then he must
* check the match_stat in the record */
ok = record_cb(dcr, rec);
+#ifdef xxx
/*
* If this is the end of the Session (EOS) for this record
* we can remove the record. Note, there is a separate
* record to read each session. If a new session is seen
* a new record will be created at approx line 157 above.
+ * However, it seg faults in the for line at lineno 196.
*/
if (rec->FileIndex == EOS_LABEL) {
Dmsg2(dbglvl, "Remove EOS rec. SI=%d ST=%d\n", rec->VolSessionId,
recs->remove(rec);
free_record(rec);
}
+#endif
continue;
} /* end if label record */
* Apply BSR filter
*/
if (jcr->bsr) {
- rec->match_stat = match_bsr(jcr->bsr, rec, &dev->VolHdr, &sessrec);
+ rec->match_stat = match_bsr(jcr->bsr, rec, &dev->VolHdr, &sessrec, jcr);
if (rec->match_stat == -1) { /* no more possible matches */
done = true; /* all items found, stop */
Dmsg2(dbglvl, "All done=(file:block) %u:%u\n", dev->file, dev->block_num);
rec->VolSessionId, rec->VolSessionTime, rec->FileIndex);
break; /* read second part of record */
}
+
Dmsg6(dbglvl, "OK callback. recno=%d state=%s blk=%d SI=%d ST=%d FI=%d\n", record,
rec_state_to_str(rec), block->BlockNumber,
rec->VolSessionId, rec->VolSessionTime, rec->FileIndex);
/*
* If we have a digest stream, we check to see if we have
* finished the current bsr, and if so, repositioning will
- * be truned on.
+ * be turned on.
*/
if (crypto_digest_stream_type(rec->Stream) != CRYPTO_DIGEST_NONE) {
Dmsg3(dbglvl, "Have digest FI=%u before bsr check pos %u:%u\n", rec->FileIndex,
return true;
}
if (bsr) {
- if (verbose) {
- Jmsg(jcr, M_INFO, 0, _("Reposition from (file:block) %u:%u to %u:%u\n"),
- dev->file, dev->block_num, bsr->volfile->sfile,
- bsr->volblock->sblock);
+ /*
+ * ***FIXME*** gross kludge to make disk seeking work. Remove
+ * when find_next_bsr() is fixed not to return a bsr already
+ * completed.
+ */
+ uint32_t block, file;
+ /* TODO: use dev->file_addr ? */
+ uint64_t dev_addr = (((uint64_t) dev->file)<<32) | dev->block_num;
+ uint64_t bsr_addr = get_bsr_start_addr(bsr, &file, &block);
+
+ if (dev_addr > bsr_addr) {
+ return false;
}
- Dmsg4(dbglvl, "Try_Reposition from (file:block) %u:%u to %u:%u\n",
- dev->file, dev->block_num, bsr->volfile->sfile,
- bsr->volblock->sblock);
- dev->reposition(dcr, bsr->volfile->sfile, bsr->volblock->sblock);
+ Dmsg4(10, "Try_Reposition from (file:block) %u:%u to %u:%u\n",
+ dev->file, dev->block_num, file, block);
+ dev->reposition(dcr, file, block);
rec->Block = 0;
}
return false;
{
BSR *bsr = NULL;
DEVICE *dev = dcr->dev;
+ uint32_t file, block;
/*
* Now find and position to first file and block
* on this tape.
if (jcr->bsr) {
jcr->bsr->reposition = true; /* force repositioning */
bsr = find_next_bsr(jcr->bsr, dev);
- if (bsr && (bsr->volfile->sfile != 0 || bsr->volblock->sblock != 0)) {
- Jmsg(jcr, M_INFO, 0, _("Forward spacing to file:block %u:%u.\n"),
- bsr->volfile->sfile, bsr->volblock->sblock);
- Dmsg2(dbglvl, "Forward spacing to file:block %u:%u.\n",
- bsr->volfile->sfile, bsr->volblock->sblock);
- dev->reposition(dcr, bsr->volfile->sfile, bsr->volblock->sblock);
+
+ if (get_bsr_start_addr(bsr, &file, &block) > 0) {
+ Jmsg(jcr, M_INFO, 0, _("Forward spacing Volume \"%s\" to file:block %u:%u.\n"),
+ dev->VolHdr.VolumeName, file, block);
+ dev->reposition(dcr, file, block);
}
}
return bsr;