git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7100
91ce42f0-d328-0410-95d8-
f526ca767f89
Index: src/stored/faketape.c
===================================================================
Index: src/stored/faketape.c
===================================================================
---- src/stored/faketape.c (révision 7092)
-+++ src/stored/faketape.c (copie de travail)
-@@ -63,7 +63,7 @@
- #ifdef USE_FAKETAPE
- #include "faketape.h"
-
--static int dbglevel = 10;
-+static int dbglevel = 0;
- #define FILE_OFFSET 30
- faketape *ftape_list[FTAPE_MAX_DRIVE];
-
+--- src/stored/faketape.c (revision 7097)
++++ src/stored/faketape.c (working copy)
@@ -170,6 +170,7 @@
int faketape::tape_op(struct mtop *mt_com)
{
@@ -170,6 +170,7 @@
int faketape::tape_op(struct mtop *mt_com)
{
uint32_t size = count;
::write(fd, &size, sizeof(uint32_t));
nb = ::write(fd, buffer, count);
uint32_t size = count;
::write(fd, &size, sizeof(uint32_t));
nb = ::write(fd, buffer, count);
+ ::write(fd, &cur_FM, sizeof(off_t));
+ lseek(fd, cur_FM, SEEK_SET);
+
+ ::write(fd, &cur_FM, sizeof(off_t));
+ lseek(fd, cur_FM, SEEK_SET);
+
+ last_FM = cur_FM;
+ next_FM = 0;
+
+ last_FM = cur_FM;
+ next_FM = 0;
+
{
ASSERT(online);
ASSERT(current_file >= 0);
{
ASSERT(online);
ASSERT(current_file >= 0);
/*
* 1 0 -> fsf -> 2 0 -> fsf -> 2 -1
*/
/*
* 1 0 -> fsf -> 2 0 -> fsf -> 2 -1
*/
Dmsg0(dbglevel, "Try to FSF after EOT\n");
errno = EIO;
current_file = last_file ;
Dmsg0(dbglevel, "Try to FSF after EOT\n");
errno = EIO;
current_file = last_file ;
+ */
+bool faketape::read_next_fm(bool read_all /* read the 0 byte */)
+{
+ */
+bool faketape::read_next_fm(bool read_all /* read the 0 byte */)
+{
+ return read_fm(read_all);
+}
+
+ return read_fm(read_all);
+}
+
int faketape::fsr(int count)
{
ASSERT(online);
int faketape::fsr(int count)
{
ASSERT(online);
uint32_t s;
Dmsg3(dbglevel, "fsr %i:%i count=%i\n", current_file,current_block, count);
uint32_t s;
Dmsg3(dbglevel, "fsr %i:%i count=%i\n", current_file,current_block, count);
check_eof();
if (atEOT) {
check_eof();
if (atEOT) {
current_file, current_block, nb,s);
errno = EIO;
ret = -1;
- if (current_file < last_file) {
current_file, current_block, nb,s);
errno = EIO;
ret = -1;
- if (current_file < last_file) {
current_file++;
- seek_file();
- }
current_file++;
- seek_file();
- }
int faketape::bsr(int count)
{
Dmsg2(dbglevel, "bsr current_block=%i count=%i\n",
int faketape::bsr(int count)
{
Dmsg2(dbglevel, "bsr current_block=%i count=%i\n",
ASSERT(count == 1);
ASSERT(fd >= 0);
ASSERT(count == 1);
ASSERT(fd >= 0);
check_eof();
if (!count) {
check_eof();
if (!count) {
+ if (current_file == 0) {/* BOT + errno */
+ lseek(fd, 0, SEEK_SET);
+ read_fm(true);
+ if (current_file == 0) {/* BOT + errno */
+ lseek(fd, 0, SEEK_SET);
+ read_fm(true);
current_file = 0;
current_block = 0;
atBOT = true;
current_file = 0;
current_block = 0;
atBOT = true;
int faketape::close()
{
check_eof();
int faketape::close()
{
check_eof();
int faketape::read(void *buffer, unsigned int count)
{
ASSERT(online);
int faketape::read(void *buffer, unsigned int count)
{
ASSERT(online);
Dmsg2(dbglevel, "read %i:%i\n", current_file, current_block);
if (atEOT || atEOD) {
Dmsg2(dbglevel, "read %i:%i\n", current_file, current_block);
if (atEOT || atEOD) {
errno = EIO;
return -1;
}
errno = EIO;
return -1;
}
/* reading size of data */
nb = ::read(fd, &s, sizeof(uint32_t));
/* reading size of data */
nb = ::read(fd, &s, sizeof(uint32_t));
if (!s) { /* EOF */
atEOF = true;
if (!s) { /* EOF */
atEOF = true;
nb = ::read(fd, buffer, s);
if (s != nb) { /* read error */
errno=EIO;
nb = ::read(fd, buffer, s);
if (s != nb) { /* read error */
errno=EIO;
current_block = -1;
Dmsg0(dbglevel, "EOT during reading\n");
return -1;
current_block = -1;
Dmsg0(dbglevel, "EOT during reading\n");
return -1;
file_block = 0;
current_block = 0;
current_file = 0;
file_block = 0;
current_block = 0;
current_file = 0;
-+ prev_FM = next_FM = last_FM = 0;
++ next_FM = last_FM = 0;
+ eot_count = 0;
needEOF = false;
- inplace = true;
+ eot_count = 0;
needEOF = false;
- inplace = true;
void faketape::update_pos()
{
ASSERT(online);
void faketape::update_pos()
{
ASSERT(online);
Dmsg1(dbglevel+1, "update_pos=%i\n", file_block);
if (file_block > max_block) {
Dmsg1(dbglevel+1, "update_pos=%i\n", file_block);
if (file_block > max_block) {
Dmsg0(dbglevel+1, "===================\n");
Index: src/stored/faketape.h
===================================================================
Dmsg0(dbglevel+1, "===================\n");
Index: src/stored/faketape.h
===================================================================
---- src/stored/faketape.h (révision 7084)
-+++ src/stored/faketape.h (copie de travail)
-@@ -56,35 +56,39 @@
+--- src/stored/faketape.h (revision 7097)
++++ src/stored/faketape.h (working copy)
+@@ -56,35 +56,38 @@
private:
int fd; /* Our file descriptor */
private:
int fd; /* Our file descriptor */
+ off_t file_block; /* size */
off_t max_block;
+ off_t file_block; /* size */
off_t max_block;
-+ off_t prev_FM; /* previous file mark */
+ off_t last_FM; /* last file mark (current file) */
+ off_t last_FM; /* last file mark (current file) */
++ off_t next_FM; /* next file mark (next file) */
+
bool atEOF; /* End of file */
bool atEOT; /* End of media */
+
bool atEOF; /* End of file */
bool atEOT; /* End of media */