]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/bcopy.c
Backport new lock calls + debug for SD
[bacula/bacula] / bacula / src / stored / bcopy.c
index 7328d58d5e90cc65e63744d613ee6679f1f8e20e..8db3259c8acd60e9918e3fd6318e1afa4dc73df3 100644 (file)
@@ -1,12 +1,12 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2002-2010 Free Software Foundation Europe e.V.
+   Copyright (C) 2002-2012 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -31,8 +31,6 @@
  *
  *   Kern E. Sibbald, October 2002
  *
- *
- *   Version $Id$
  */
 
 #include "bacula.h"
@@ -199,13 +197,13 @@ int main (int argc, char *argv[])
    }
    Dmsg0(100, "About to acquire device for writing\n");
    /* For we must now acquire the device for writing */
-   out_dev->r_dlock();
-   if (out_dev->open(out_jcr->dcr, OPEN_READ_WRITE) < 0) {
+   out_dev->rLock(false);
+   if (!out_dev->open(out_jcr->dcr, OPEN_READ_WRITE)) {
       Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), out_dev->errmsg);
-      out_dev->dunlock();
+      out_dev->Unlock();
       exit(1);
    }
-   out_dev->dunlock();
+   out_dev->Unlock();
    if (!acquire_device_for_append(out_jcr->dcr)) {
       free_jcr(in_jcr);
       exit(1);
@@ -215,7 +213,7 @@ int main (int argc, char *argv[])
    ok = read_records(in_jcr->dcr, record_cb, mount_next_read_volume);
 
    if (ok || out_dev->can_write()) {
-      if (!write_block_to_device(out_jcr->dcr)) {
+      if (!out_jcr->dcr->write_block_to_device()) {
          Pmsg0(000, _("Write of last block failed.\n"));
       }
    }
@@ -273,10 +271,10 @@ static bool record_cb(DCR *in_dcr, DEV_RECORD *rec)
             /* Skipping record, because does not match BSR filter */
            return true;
         }
-         while (!write_record_to_block(out_block, rec)) {
+         while (!write_record_to_block(out_jcr->dcr, rec)) {
             Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec->data_len,
                        rec->remainder);
-            if (!write_block_to_device(out_jcr->dcr)) {
+            if (!out_jcr->dcr->write_block_to_device()) {
                Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
                   out_dev->print_name(), out_dev->bstrerror());
                Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
@@ -284,7 +282,7 @@ static bool record_cb(DCR *in_dcr, DEV_RECORD *rec)
                return false;
             }
          }
-         if (!write_block_to_device(out_jcr->dcr)) {
+         if (!out_jcr->dcr->write_block_to_device()) {
             Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
                out_dev->print_name(), out_dev->bstrerror());
             Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
@@ -309,10 +307,10 @@ static bool record_cb(DCR *in_dcr, DEV_RECORD *rec)
       return true;
    }
    records++;
-   while (!write_record_to_block(out_block, rec)) {
+   while (!write_record_to_block(out_jcr->dcr, rec)) {
       Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec->data_len,
                  rec->remainder);
-      if (!write_block_to_device(out_jcr->dcr)) {
+      if (!out_jcr->dcr->write_block_to_device()) {
          Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
             out_dev->print_name(), out_dev->bstrerror());
          Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
@@ -326,7 +324,7 @@ static bool record_cb(DCR *in_dcr, DEV_RECORD *rec)
 static void get_session_record(DEVICE *dev, DEV_RECORD *rec, SESSION_LABEL *sessrec)
 {
    const char *rtype;
-   memset(sessrec, 0, sizeof(sessrec));
+   memset(sessrec, 0, sizeof(SESSION_LABEL));
    switch (rec->FileIndex) {
    case PRE_LABEL:
       rtype = _("Fresh Volume Label");