]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/butil.c
Start adding back removed code.
[bacula/bacula] / bacula / src / stored / butil.c
index c4cda7c9d2833f3ba9e006a09da0ac808e7d60ed..43a8088a8f909425cd9c8dacddb39afc687db04c 100644 (file)
  *   Version $Id$
  */
 /*
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   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
 
    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 ammended with additional clauses defined in the
+   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,
    file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
@@ -43,19 +43,19 @@ char *rec_state_to_str(DEV_RECORD *rec)
    static char buf[200];
    buf[0] = 0;
    if (rec->state & REC_NO_HEADER) {
    static char buf[200];
    buf[0] = 0;
    if (rec->state & REC_NO_HEADER) {
-      strcat(buf, "Nohdr,");
+      strcat(buf, _("Nohdr,"));
    }
    if (is_partial_record(rec)) {
    }
    if (is_partial_record(rec)) {
-      strcat(buf, "partial,");
+      strcat(buf, _("partial,"));
    }
    if (rec->state & REC_BLOCK_EMPTY) {
    }
    if (rec->state & REC_BLOCK_EMPTY) {
-      strcat(buf, "empty,");
+      strcat(buf, _("empty,"));
    }
    if (rec->state & REC_NO_MATCH) {
    }
    if (rec->state & REC_NO_MATCH) {
-      strcat(buf, "Nomatch,");
+      strcat(buf, _("Nomatch,"));
    }
    if (rec->state & REC_CONTINUATION) {
    }
    if (rec->state & REC_CONTINUATION) {
-      strcat(buf, "cont,");
+      strcat(buf, _("cont,"));
    }
    if (buf[0]) {
       buf[strlen(buf)-1] = 0;
    }
    if (buf[0]) {
       buf[strlen(buf)-1] = 0;
@@ -92,6 +92,9 @@ JCR *setup_jcr(const char *name, char *dev_name, BSR *bsr,
    jcr->fileset_md5 = get_pool_memory(PM_FNAME);
    pm_strcpy(jcr->fileset_md5, "Dummy.fileset.md5");
 
    jcr->fileset_md5 = get_pool_memory(PM_FNAME);
    pm_strcpy(jcr->fileset_md5, "Dummy.fileset.md5");
 
+   init_autochangers();
+   create_volume_list();
+
    dcr = setup_to_access_device(jcr, dev_name, VolumeName, mode);
    if (!dcr) {
       return NULL;
    dcr = setup_to_access_device(jcr, dev_name, VolumeName, mode);
    if (!dcr) {
       return NULL;
@@ -118,6 +121,8 @@ static DCR *setup_to_access_device(JCR *jcr, char *dev_name,
    DCR *dcr;
    char VolName[MAX_NAME_LENGTH];
 
    DCR *dcr;
    char VolName[MAX_NAME_LENGTH];
 
+   init_reservations_lock();
+
    /*
     * If no volume name already given and no bsr, and it is a file,
     * try getting name from Filename
    /*
     * If no volume name already given and no bsr, and it is a file,
     * try getting name from Filename
@@ -157,6 +162,7 @@ static DCR *setup_to_access_device(JCR *jcr, char *dev_name,
    }
    device->dev = dev;
    dcr = new_dcr(jcr, dev);
    }
    device->dev = dev;
    dcr = new_dcr(jcr, dev);
+   jcr->dcr = dcr;
    if (VolName[0]) {
       bstrncpy(dcr->VolumeName, VolName, sizeof(dcr->VolumeName));
    }
    if (VolName[0]) {
       bstrncpy(dcr->VolumeName, VolName, sizeof(dcr->VolumeName));
    }
@@ -169,11 +175,13 @@ static DCR *setup_to_access_device(JCR *jcr, char *dev_name,
       if (!acquire_device_for_read(dcr)) {
          return NULL;
       }
       if (!acquire_device_for_read(dcr)) {
          return NULL;
       }
+      jcr->read_dcr = dcr;
    } else {
    } else {
-      if (!first_open_device(dev)) {
-         Jmsg1(jcr, M_FATAL, 0, _("Cannot open %s\n"), dcr->dev_name);
+      if (!first_open_device(dcr)) {
+         Jmsg1(jcr, M_FATAL, 0, _("Cannot open %s\n"), dev->print_name());
          return NULL;
       }
          return NULL;
       }
+      jcr->dcr = dcr;        /* write dcr */
    }
    return dcr;
 }
    }
    return dcr;
 }
@@ -224,8 +232,10 @@ static DEVRES *find_device_res(char *device_name, int read_access)
    bool found = false;
    DEVRES *device;
 
    bool found = false;
    DEVRES *device;
 
+   Dmsg0(900, "Enter find_device_res\n");
    LockRes();
    foreach_res(device, R_DEVICE) {
    LockRes();
    foreach_res(device, R_DEVICE) {
+      Dmsg2(900, "Compare %s and %s\n", device->device_name, device_name);
       if (strcmp(device->device_name, device_name) == 0) {
          found = true;
          break;
       if (strcmp(device->device_name, device_name) == 0) {
          found = true;
          break;
@@ -242,6 +252,7 @@ static DEVRES *find_device_res(char *device_name, int read_access)
          }
       }
       foreach_res(device, R_DEVICE) {
          }
       }
       foreach_res(device, R_DEVICE) {
+         Dmsg2(900, "Compare %s and %s\n", device->hdr.name, device_name);
          if (strcmp(device->hdr.name, device_name) == 0) {
             found = true;
             break;
          if (strcmp(device->hdr.name, device_name) == 0) {
             found = true;
             break;
@@ -254,8 +265,12 @@ static DEVRES *find_device_res(char *device_name, int read_access)
             configfile);
       return NULL;
    }
             configfile);
       return NULL;
    }
-   Pmsg2(0, _("Using device: \"%s\" for %s.\n"), device_name,
-             read_access?"reading":"writing");
+   if (read_access) {
+      Pmsg1(0, _("Using device: \"%s\" for reading.\n"), device_name);
+   }
+   else {
+      Pmsg1(0, _("Using device: \"%s\" for writing.\n"), device_name);
+   }
    return device;
 }
 
    return device;
 }