]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/parse_bsr.c
kes Fix logic error in handling error return from mtx-changer
[bacula/bacula] / bacula / src / stored / parse_bsr.c
index f5076ee584c9d769c6fbca360068802a54255648..1bd1fa37ba91c84068acccc326c26e66bfb2ad35 100755 (executable)
@@ -7,7 +7,7 @@
  */
 
 /*
-   Copyright (C) 2002-2005 Kern Sibbald
+   Copyright (C) 2002-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
@@ -29,6 +29,7 @@ typedef BSR * (ITEM_HANDLER)(LEX *lc, BSR *bsr);
 
 static BSR *store_vol(LEX *lc, BSR *bsr);
 static BSR *store_mediatype(LEX *lc, BSR *bsr);
+static BSR *store_device(LEX *lc, BSR *bsr);
 static BSR *store_client(LEX *lc, BSR *bsr);
 static BSR *store_job(LEX *lc, BSR *bsr);
 static BSR *store_jobid(LEX *lc, BSR *bsr);
@@ -71,8 +72,9 @@ struct kw_items items[] = {
    {"exclude", store_exclude},
    {"volfile", store_volfile},
    {"volblock", store_volblock},
-   {"stream",  store_stream},
-   {"slot",    store_slot},
+   {"stream",   store_stream},
+   {"slot",     store_slot},
+   {"device",   store_device},
    {NULL, NULL}
 
 };
@@ -268,6 +270,28 @@ static BSR *store_mediatype(LEX *lc, BSR *bsr)
    return bsr;
 }
 
+/* Shove the Device name in each Volume in the current bsr */
+static BSR *store_device(LEX *lc, BSR *bsr)
+{
+   int token;
+
+   token = lex_get_token(lc, T_STRING);
+   if (token == T_ERROR) {
+      return NULL;
+   }
+   if (!bsr->volume) {
+      Emsg1(M_ERROR,0, _("Device \"%s\" in bsr at inappropriate place.\n"),
+         lc->str);
+      return bsr;
+   }
+   BSR_VOLUME *bv;
+   for (bv=bsr->volume; bv; bv=bv->next) {
+      bstrncpy(bv->device, lc->str, sizeof(bv->device));
+   }
+   return bsr;
+}
+
+
 
 static BSR *store_client(LEX *lc, BSR *bsr)
 {
@@ -603,7 +627,12 @@ static BSR *store_slot(LEX *lc, BSR *bsr)
    if (token == T_ERROR) {
       return NULL;
    }
-   bsr->Slot = lc->pint32_val;
+   if (!bsr->volume) {
+      Emsg1(M_ERROR,0, _("Slot %d in bsr at inappropriate place.\n"),
+         lc->pint32_val);
+      return bsr;
+   }
+   bsr->volume->Slot = lc->pint32_val;
    scan_to_eol(lc);
    return bsr;
 }
@@ -677,6 +706,9 @@ void dump_volume(BSR_VOLUME *volume)
 {
    if (volume) {
       Pmsg1(-1, _("VolumeName  : %s\n"), volume->VolumeName);
+      Pmsg1(-1, _("  MediaType : %s\n"), volume->MediaType);
+      Pmsg1(-1, _("  Device    : %s\n"), volume->device);
+      Pmsg1(-1, _("  Slot      : %d\n"), volume->Slot);
       dump_volume(volume->next);
    }
 }
@@ -730,9 +762,6 @@ void dump_bsr(BSR *bsr, bool recurse)
    dump_jobid(bsr->JobId);
    dump_job(bsr->job);
    dump_findex(bsr->FileIndex);
-   if (bsr->Slot) {
-      Pmsg1(-1, _("Slot        : %u\n"), bsr->Slot);
-   }
    if (bsr->count) {
       Pmsg1(-1, _("count       : %u\n"), bsr->count);
       Pmsg1(-1, _("found       : %u\n"), bsr->found);
@@ -875,6 +904,8 @@ void create_restore_volume_list(JCR *jcr)
             vol = new_restore_volume();
             bstrncpy(vol->VolumeName, bsrvol->VolumeName, sizeof(vol->VolumeName));
             bstrncpy(vol->MediaType,  bsrvol->MediaType,  sizeof(vol->MediaType));
+            bstrncpy(vol->device, bsrvol->device, sizeof(vol->device));
+            vol->Slot = bsrvol->Slot;
             vol->start_file = sfile;
             if (add_restore_volume(jcr, vol)) {
                jcr->NumVolumes++;