]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/patches/testing/faketape.c
ebl add new hash lib test code
[bacula/bacula] / bacula / patches / testing / faketape.c
index f4d714180de59973537972d2a9cda21a2fd7d39f..9284680b6635f8e531595253ef423a4023fdba3d 100644 (file)
@@ -41,11 +41,24 @@ Device {
   RandomAccess = no;
 }
 
+  Block description :
+
+  block {
+    int32  size;
+    void   *data;
+  }
+
+  EOF description :
+
+  EOF {
+    int32  size=0;
+  }
+
+
  */
 
-#include <dirent.h>
-#include <sys/mtio.h>
-#include <ctype.h>
+#include "bacula.h"            /* define 64bit file usage */
+#include "stored.h"
 #include "faketape.h"
 
 static int dbglevel = 10;
@@ -395,12 +408,10 @@ faketape::faketape()
 
    max_block = 1024*1024*1024*1024*8;
 
-   volume = get_pool_memory(PM_NAME);
 }
 
 faketape::~faketape()
 {
-   free_pool_memory(volume);
 }
 
 int faketape::get_fd()
@@ -474,6 +485,7 @@ int faketape::weof(int count)
    Dmsg3(dbglevel, "Writing EOF %i:%i last=%i\n", 
         current_file, current_block,last_file);
    if (atEOT) {
+      errno = ENOSPC;
       current_block = -1;
       return -1;
    }
@@ -742,6 +754,7 @@ int faketape::read(void *buffer, unsigned int count)
       return 0;
    }
    if (s > count) {            /* not enough buffer to read block */
+      Dmsg2(dbglevel, "Need more buffer to read next block %i > %i\n",s,count);
       lseek(fd, s, SEEK_CUR);
       errno = ENOMEM;
       return -1;
@@ -766,15 +779,14 @@ int faketape::read(void *buffer, unsigned int count)
 int faketape::open(const char *pathname, int uflags)
 {
    Dmsg2(dbglevel, "faketape::open(%s, %i)\n", pathname, uflags);
-   pm_strcpy(volume, pathname);
 
    struct stat statp;   
-   if (stat(volume, &statp) != 0) {
-      Dmsg1(dbglevel, "Can't stat on %s\n", volume);
+   if (stat(pathname, &statp) != 0) {
+      Dmsg1(dbglevel, "Can't stat on %s\n", pathname);
       return -1;
    }
 
-   fd = ::open(pathname, O_CREAT | O_RDWR, 0700);
+   fd = ::open(pathname, O_CREAT | O_RDWR | O_LARGEFILE, 0700);
    if (fd < 0) {
       return -1;
    }
@@ -822,10 +834,10 @@ int faketape::seek_file()
    if(lseek(fd, pos, SEEK_SET) == -1) {
       return -1;
    }
+   last_file = (last_file > current_file)?last_file:current_file;
    if (current_block > 0) {
       fsr(current_block);
    }
-   last_file = (last_file > current_file)?last_file:current_file;
    inplace = true;
 
    return 0;
@@ -836,7 +848,6 @@ void faketape::dump()
    Dmsg0(dbglevel+1, "===================\n");
    Dmsg2(dbglevel, "file:block = %i:%i\n", current_file, current_block);
    Dmsg1(dbglevel+1, "last_file=%i\n", last_file);
-   Dmsg1(dbglevel+1, "volume=%s\n", volume);
    Dmsg1(dbglevel+1, "file_size=%i\n", file_size);  
    Dmsg4(dbglevel+1, "EOF=%i EOT=%i EOD=%i BOT=%i\n", 
         atEOF, atEOT, atEOD, atBOT);