]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/vtape.c
Add extra lock debug code but turned off
[bacula/bacula] / bacula / src / stored / vtape.c
index df044f8e46e3b20990de0f79477fc777980953d7..b8b9b4a50d4edb3377f92d75e932023afde1e54f 100644 (file)
@@ -20,7 +20,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Bacula® is a registered trademark of John Walker.
+   Bacula® is a registered trademark of Kern Sibbald.
    The licensor of Bacula is the Free Software Foundation Europe
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
@@ -139,10 +139,10 @@ int vtape_close(int fd)
    return 0;
 }
 
-int vtape_ioctl(int fd, unsigned long int request, ...)
+int vtape_ioctl(int fd, ioctl_req_t request, ...)
 {
    va_list argp;
-   int result=0;
+   int result = 0;
 
    vtape *t = get_tape(fd);
    if (!t) {
@@ -268,7 +268,7 @@ int vtape::tape_op(struct mtop *mt_com)
             current_file++;
          }
       }
-      off_t l;
+      boffset_t l;
       while (::read(fd, &l, sizeof(l)) > 0) {
          if (l) {
             lseek(fd, l, SEEK_CUR);
@@ -433,7 +433,7 @@ vtape::vtape()
    current_file = 0;
    current_block = -1;
 
-   max_block = 2*1024*2048;      /* 2GB */
+   max_block = VTAPE_MAX_BLOCK;
 }
 
 vtape::~vtape()
@@ -527,8 +527,8 @@ int vtape::weof()
    cur_FM = lseek(fd, 0, SEEK_CUR); // current position
    
    /* update previous next_FM  */
-   lseek(fd, last_FM + sizeof(uint32_t)+sizeof(off_t), SEEK_SET);
-   ::write(fd, &cur_FM, sizeof(off_t));
+   lseek(fd, last_FM + sizeof(uint32_t)+sizeof(boffset_t), SEEK_SET);
+   ::write(fd, &cur_FM, sizeof(boffset_t));
    lseek(fd, cur_FM, SEEK_SET);
 
    next_FM = 0;
@@ -611,7 +611,7 @@ int vtape::fsf()
 bool vtape::read_fm(VT_READ_FM_MODE read_all)
 {
    int ret;
-   uint32_t c;
+   uint32_t c = 0;
    if (read_all == VT_READ_EOF) {
       ::read(fd, &c, sizeof(c));
       if (c != 0) {
@@ -643,7 +643,7 @@ int vtape::fsr(int count)
    ASSERT(fd >= 0);
    
    int i,nb, ret=0;
-   off_t where=0;
+   boffset_t where=0;
    uint32_t s;
    Dmsg4(dbglevel, "fsr %i:%i EOF=%i c=%i\n", 
          current_file,current_block,atEOF,count);
@@ -707,8 +707,8 @@ int vtape::bsr(int count)
    int last_f=0;
    int last_b=0;
 
-   off_t last=-1, last2=-1;
-   off_t orig = lseek(fd, 0, SEEK_CUR);
+   boffset_t last=-1, last2=-1;
+   boffset_t orig = lseek(fd, 0, SEEK_CUR);
    int orig_f = current_file;
    int orig_b = current_block;
 
@@ -780,7 +780,7 @@ int vtape::bsr(int count)
    Dmsg2(dbglevel, "bsr %i:%i\n", current_file, current_block);
    errno=0;
    atEOT = atEOF = atEOD = false;
-   atBOT = (lseek(fd, 0, SEEK_CUR) - (sizeof(uint32_t)+2*sizeof(off_t))) == 0;
+   atBOT = (lseek(fd, 0, SEEK_CUR) - (sizeof(uint32_t)+2*sizeof(boffset_t))) == 0;
 
    if (orig_b == -1) {
       current_block = orig_b;
@@ -961,7 +961,9 @@ int vtape::open(const char *pathname, int uflags)
 
    /* If the vtape is empty, start by writing a EOF */
    if (online && !read_fm(VT_READ_EOF)) {
-      weof();
+      lseek(fd, 0, SEEK_SET);          /* rewind */
+      cur_FM = next_FM = last_FM = 0;  /* reset */
+      weof();                          /* write the first EOF */
       last_file = current_file=0;
    }
 
@@ -998,7 +1000,7 @@ void vtape::dump()
 
 #else  /* USE_VTAPE */
 
-int vtape_ioctl(int fd, unsigned long int request, ...)
+int vtape_ioctl(int fd, ioctl_req_t request, ...)
 {
    return -1;
 }