From: Eric Bollengier Date: Sun, 1 Jun 2008 20:57:21 +0000 (+0000) Subject: ebl fix bsr code X-Git-Tag: Release-3.0.0~1348 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5f0065304140fab3ff7a7721220e30dacd574797;p=bacula%2Fbacula ebl fix bsr code git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7092 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/stored/faketape.c b/bacula/src/stored/faketape.c index 93077433de..ee98d31cc7 100644 --- a/bacula/src/stored/faketape.c +++ b/bacula/src/stored/faketape.c @@ -63,7 +63,7 @@ Device { #ifdef USE_FAKETAPE #include "faketape.h" -static int dbglevel = 1000; +static int dbglevel = 10; #define FILE_OFFSET 30 faketape *ftape_list[FTAPE_MAX_DRIVE]; @@ -444,7 +444,6 @@ int faketape::write(const void *buffer, unsigned int count) return -1; } - Dmsg1(dbglevel, "write inplace=%i\n", inplace); check_inplace(); if (!atEOD) { /* if not at the end of the data */ @@ -636,6 +635,26 @@ int faketape::bsr(int count) int orig_f = current_file; int orig_b = current_block; + /* begin of tape, do nothing */ + if (atBOT) { + errno = EIO; + return -1; + } + + if (atEOF) { + if (!current_block) { + if (current_file > 0) { + current_file--; + } + current_block=-1; + errno = EIO; + return -1; + + } else { + atEOF=false; + } + } + current_block=0; seek_file(); @@ -672,7 +691,11 @@ int faketape::bsr(int count) } Dmsg2(dbglevel, "bsr %i:%i\n", current_file, current_block); + errno=0; atEOT = atEOF = atEOD = false; + atBOT = (current_block == 0 && current_file == 0); + + current_block = -1; return 0; } @@ -808,7 +831,9 @@ int faketape::read(void *buffer, unsigned int count) return -1; } /* read ok */ - current_block++; + if (current_block >= 0) { + current_block++; + } return nb; }