Mmsg1(&dev->errmsg, _("Read zero bytes on device %s.\n"), dev->dev_name);
if (dev->state & ST_EOF) { /* EOF alread read? */
dev->state |= ST_EOT; /* yes, 2 EOFs => EOT */
+ block->read_len = 0;
return 0;
}
dev->file++; /* increment file */
dev->state |= ST_EOF; /* set EOF read */
+ block->read_len = 0;
return 0; /* return eof */
}
/* Continue here for successful read */
}
if (!unser_block_header(dev, block)) {
+ block->read_len = 0;
return 0;
}
Dmsg0(100, "Backspace record for reread.\n");
if (bsf_dev(dev, 1) != 0) {
Emsg0(M_ERROR, 0, dev->errmsg);
+ block->read_len = 0;
return 0;
}
} else {
uint32_t block_len; /* length of current block read */
uint32_t buf_len; /* max/default block length */
uint32_t BlockNumber; /* sequential block number */
- uint32_t read_len; /* bytes read into buffer */
+ uint32_t read_len; /* bytes read into buffer, if zero, block empty */
uint32_t VolSessionId; /* */
uint32_t VolSessionTime; /* */
int BlockVer; /* block version 1 or 2 */
*/
} DEV_BLOCK;
+#define block_is_empty(block) !((block)->read_len)
+
#endif
}
free_record(record);
- empty_block(block);
- rewind_dev(dev);
+ /* If we are a streaming device, we only get one chance to read */
+ if (!dev_cap(dev, CAP_STREAM)) {
+ empty_block(block);
+ rewind_dev(dev);
+ }
if (dev->VolHdr.VerNum != BaculaTapeVersion &&
dev->VolHdr.VerNum != OldCompatibleBaculaTapeVersion1 &&
/* Read Record */
Dmsg1(500, "Main read_record. rem=%d\n", rec->remainder);
- if (!read_block_from_device(dev, block)) {
+ if (block_is_empty(block) && !read_block_from_device(dev, block)) {
Dmsg1(500, "Main read record failed. rem=%d\n", rec->remainder);
if (dev->state & ST_EOT) {
DEV_RECORD *record;
}
#endif
rec->state |= (REC_NO_HEADER | REC_BLOCK_EMPTY);
+ empty_block(block); /* mark block empty */
return 0;
}