uint32_t record, num_files = 0;
int verbose = FALSE;
int ok = TRUE;
+ int done = FALSE;
SESSION_LABEL sessrec;
block = new_block(dev);
rec = new_record();
- for ( ;ok; ) {
+ for ( ;ok && !done; ) {
if (job_cancelled(jcr)) {
ok = FALSE;
break;
if (!read_block_from_device(dev, block)) {
Dmsg0(20, "!read_record()\n");
if (dev->state & ST_EOT) {
- DEV_RECORD *record;
+ DEV_RECORD *trec = new_record();
+
Dmsg3(100, "EOT. stat=%s blk=%d rem=%d\n", rec_state_to_str(rec),
block->BlockNumber, rec->remainder);
if (!mount_cb(jcr, dev, block)) {
Dmsg3(100, "After mount next vol. stat=%s blk=%d rem=%d\n", rec_state_to_str(rec),
block->BlockNumber, rec->remainder);
ok = FALSE;
+ /*
+ * Create EOT Label so that Media record may
+ * be properly updated because this is the last
+ * tape.
+ */
+ trec->FileIndex = EOT_LABEL;
+ trec->File = dev->file;
+ trec->Block = rec->Block; /* return block last read */
+ record_cb(jcr, dev, block, trec);
+ free_record(trec);
break;
}
Dmsg3(100, "After mount next vol. stat=%s blk=%d rem=%d\n", rec_state_to_str(rec),
block->BlockNumber, rec->remainder);
- record = new_record();
+ /*
+ * 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(dev, block);
- read_record_from_block(block, record);
- get_session_record(dev, record, &sessrec);
- record_cb(jcr, dev, block, record);
- free_record(record);
+ read_record_from_block(block, trec);
+ get_session_record(dev, trec, &sessrec);
+ record_cb(jcr, dev, block, trec);
+ free_record(trec);
goto next_record;
}
if (dev->state & ST_EOF) {
- Emsg1(M_INFO, 0, "Got EOF on device %s\n", dev_name(dev));
+ Emsg2(M_INFO, 0, "Got EOF on device %s, Volume \"%s\"\n",
+ dev_name(dev), jcr->VolumeName);
Dmsg0(20, "read_record got eof. try again\n");
continue;
}
}
if (debug_level >= 30) {
Dmsg4(30, "VolSId=%ld FI=%s Strm=%s Size=%ld\n", rec->VolSessionId,
- FI_to_ascii(rec->FileIndex), stream_to_ascii(rec->Stream),
+ FI_to_ascii(rec->FileIndex),
+ stream_to_ascii(rec->Stream, rec->FileIndex),
rec->data_len);
}
/*
* Apply BSR filter
*/
- if (jcr->bsr && !match_bsr(jcr->bsr, rec, &dev->VolHdr, &sessrec)) {
- if (verbose) {
- Dmsg5(10, "BSR no match rec=%d block=%d SessId=%d SessTime=%d FI=%d\n",
- record, block->BlockNumber, rec->VolSessionId, rec->VolSessionTime,
- rec->FileIndex);
+ if (jcr->bsr) {
+ int stat = match_bsr(jcr->bsr, rec, &dev->VolHdr, &sessrec);
+ if (stat == -1) { /* no more possible matches */
+ done = TRUE; /* all items found, stop */
+ break;
+ } else if (stat == 0) { /* no match */
+ if (verbose) {
+ Dmsg5(10, "BSR no match rec=%d block=%d SessId=%d SessTime=%d FI=%d\n",
+ record, block->BlockNumber, rec->VolSessionId, rec->VolSessionTime,
+ rec->FileIndex);
+ }
+ rec->remainder = 0;
+ continue; /* we don't want record, read next one */
}
- rec->remainder = 0;
- continue; /* we don't want record, read next one */
}
if (is_partial_record(rec)) {
Dmsg6(10, "Partial, break. recno=%d state=%s blk=%d SI=%d ST=%d FI=%d\n", record,
break; /* read second part of record */
}
record_cb(jcr, dev, block, rec);
-
}
}
if (verbose) {
}
return buf;
}
-