]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/label.c
kes Move the checking of the database in initializion of the Director
[bacula/bacula] / bacula / src / stored / label.c
index b00045572378578bd366b4e2f954c1a6f564ea28..da6f9908ad0a0b8a21d060bf44b1af5306520ce6 100644 (file)
@@ -8,19 +8,32 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000-2006 Kern Sibbald
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License
-   version 2 as amended with additional clauses defined in the
-   file LICENSE in the main source directory.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
-   the file LICENSE for additional details.
-
- */
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2000-2006 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
+   License as published by the Free Software Foundation plus additions
+   that are listed in the file LICENSE.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   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
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
 
 #include "bacula.h"                   /* pull in global headers */
 #include "stored.h"                   /* pull in Storage Deamon headers */
@@ -109,7 +122,7 @@ int read_dev_volume_label(DCR *dcr)
   
   want_ansi_label = dcr->VolCatInfo.LabelType != B_BACULA_LABEL ||
                     dcr->device->label_type != B_BACULA_LABEL;
-  if (want_ansi_label || dev_cap(dev, CAP_CHECKLABELS)) {
+  if (want_ansi_label || dev->has_cap(CAP_CHECKLABELS)) {
       stat = read_ansi_ibm_label(dcr);            
       /* If we want a label and didn't find it, return error */
       if (want_ansi_label && stat != VOL_OK) {
@@ -140,7 +153,7 @@ int read_dev_volume_label(DCR *dcr)
            "labeled Volume, because: ERR=%s"), NPRT(VolName), 
            dev->print_name(), dev->print_errmsg());
       Dmsg1(30, "%s", jcr->errmsg);
-   } else if (!read_record_from_block(block, record)) {
+   } else if (!read_record_from_block(dcr, block, record)) {
       Mmsg(jcr->errmsg, _("Could not read Volume label from block.\n"));
       Dmsg1(30, "%s", jcr->errmsg);
    } else if (!unser_volume_label(dev, record)) {
@@ -226,7 +239,7 @@ int read_dev_volume_label(DCR *dcr)
    }
    Dmsg0(30, "Leave read_volume_label() VOL_OK\n");
    /* If we are a streaming device, we only get one chance to read */
-   if (!dev_cap(dev, CAP_STREAM)) {
+   if (!dev->has_cap(CAP_STREAM)) {
       dev->rewind(dcr);
       if (have_ansi_label) {
          stat = read_ansi_ibm_label(dcr);            
@@ -406,7 +419,7 @@ bool rewrite_volume_label(DCR *dcr, bool recycle)
    if (dev->open(dcr, OPEN_READ_WRITE) < 0) {
       return false;
    }
-   Dmsg2(190, "set append found freshly labeled volume. fd=%d dev=%x\n", dev->fd, dev);
+   Dmsg2(190, "set append found freshly labeled volume. fd=%d dev=%x\n", dev->fd(), dev);
    dev->VolHdr.LabelType = VOL_LABEL; /* set Volume label */
    dev->set_append();
    if (!write_volume_label_to_block(dcr)) {
@@ -423,7 +436,7 @@ bool rewrite_volume_label(DCR *dcr, bool recycle)
     * We do not write the block now if this is an ANSI label. This
     *  avoids re-writing the ANSI label, which we do not want to do.
     */
-   if (!dev_cap(dev, CAP_STREAM)) {
+   if (!dev->has_cap(CAP_STREAM)) {
       if (!dev->rewind(dcr)) {
          Jmsg2(jcr, M_FATAL, 0, _("Rewind error on device %s: ERR=%s\n"),
                dev->print_name(), dev->print_errmsg());
@@ -458,7 +471,7 @@ bool rewrite_volume_label(DCR *dcr, bool recycle)
       }
 
       /* Attempt write to check write permission */
-      Dmsg1(200, "Attempt to write to device fd=%d.\n", dev->fd);
+      Dmsg1(200, "Attempt to write to device fd=%d.\n", dev->fd());
       if (!write_block_to_dev(dcr)) {
          Jmsg2(jcr, M_ERROR, 0, _("Unable to write device %s: ERR=%s\n"),
             dev->print_name(), dev->print_errmsg());
@@ -558,7 +571,7 @@ static void create_volume_label_record(DCR *dcr, DEV_RECORD *rec)
    rec->FileIndex = dev->VolHdr.LabelType;
    rec->VolSessionId = jcr->VolSessionId;
    rec->VolSessionTime = jcr->VolSessionTime;
-   rec->Stream = jcr->NumVolumes;
+   rec->Stream = jcr->NumWriteVolumes;
    Dmsg2(150, "Created Vol label rec: FI=%s len=%d\n", FI_to_ascii(buf, rec->FileIndex),
       rec->data_len);
 }