]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/parse_bsr.c
- Tweak install chapter of French manual to add new paragraph
[bacula/bacula] / bacula / src / stored / parse_bsr.c
index 73e76e16e9ac92dee5cae91d35472d5ca1381b1a..4ff019b30c51ef272ebfef784fd06f822c736c10 100755 (executable)
@@ -47,9 +47,11 @@ static BSR *store_include(LEX *lc, BSR *bsr);
 static BSR *store_exclude(LEX *lc, BSR *bsr);
 static BSR *store_stream(LEX *lc, BSR *bsr);
 static BSR *store_slot(LEX *lc, BSR *bsr);
+static bool is_fast_rejection_ok(BSR *bsr);
+static bool is_positioning_ok(BSR *bsr);
 
 struct kw_items {
-   char *name;
+   const char *name;
    ITEM_HANDLER *handler;
 };
 
@@ -80,7 +82,7 @@ struct kw_items items[] = {
 /* 
  * Create a BSR record
  */
-static BSR *new_bsr() 
+static BSR *new_bsr()
 {
    BSR *bsr = (BSR *)malloc(sizeof(BSR));
    memset(bsr, 0, sizeof(BSR));
@@ -90,7 +92,7 @@ static BSR *new_bsr()
 /*
  * Format a scanner error message 
  */
-static void s_err(char *file, int line, LEX *lc, char *msg, ...)
+static void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
 {
    JCR *jcr = (JCR *)(lc->caller_ctx);
    va_list arg_ptr;
@@ -117,15 +119,15 @@ static void s_err(char *file, int line, LEX *lc, char *msg, ...)
  *     Parse Bootstrap file
  *
  */
-BSR *parse_bsr(JCR *jcr, char *cf)
+BSR *parse_bsr(JCR *jcr, char *fname)
 {
    LEX *lc = NULL;
    int token, i;
    BSR *root_bsr = new_bsr();
    BSR *bsr = root_bsr;
-
-   Dmsg1(200, "Enter parse_bsf %s\n", cf);
-   lc = lex_open_file(lc, cf, s_err);
+     
+   Dmsg1(200, "Enter parse_bsf %s\n", fname);
+   lc = lex_open_file(lc, fname, s_err);
    lc->caller_ctx = (void *)jcr;
    while ((token=lex_get_token(lc, T_ALL)) != T_EOF) {
       Dmsg1(200, "parse got token=%s\n", lex_tok_to_str(token));
@@ -164,9 +166,48 @@ BSR *parse_bsr(JCR *jcr, char *cf)
       free_bsr(root_bsr);
       root_bsr = NULL;
    }
+   if (root_bsr) {
+      root_bsr->use_fast_rejection = is_fast_rejection_ok(root_bsr);
+      root_bsr->use_positioning = is_positioning_ok(root_bsr);
+   }
+   for (bsr=root_bsr; bsr; bsr=bsr->next) {
+      bsr->root = root_bsr;
+   }
    return root_bsr;
 }
 
+static bool is_fast_rejection_ok(BSR *bsr)
+{
+   /*
+    * Although, this can be optimized, for the moment, require
+    *  all bsrs to have both sesstime and sessid set before
+    *  we do fast rejection.
+    */
+   if (!(bsr->sesstime && bsr->sessid)) {
+      return false;
+   }
+   if (bsr->next) {
+      return is_fast_rejection_ok(bsr->next);
+   }
+   return true;
+}
+
+static bool is_positioning_ok(BSR *bsr)
+{
+   /*
+    * Every bsr should have a volfile entry and a volblock entry
+    *  if we are going to use positioning
+    */
+   if (!bsr->volfile || !bsr->volblock) {
+      return false;
+   }
+   if (bsr->next) {
+      return is_positioning_ok(bsr->next);
+   }
+   return true;
+}
+
+
 static BSR *store_vol(LEX *lc, BSR *bsr)
 {
    int token;
@@ -647,14 +688,17 @@ void dump_sesstime(BSR_SESSTIME *sesstime)
 
 
 
-void dump_bsr(BSR *bsr)
+void dump_bsr(BSR *bsr, bool recurse)
 {
+   int save_debug = debug_level;
+   debug_level = 1;
    if (!bsr) {
       Dmsg0(-1, "BSR is NULL\n");
+      debug_level = save_debug;
       return;
    }
-   Dmsg1(-1,   
-"Next        : 0x%x\n", bsr->next);
+   Dmsg1(-1,    "Next        : 0x%x\n", bsr->next);
+   Dmsg1(-1,    "Root bsr    : 0x%x\n", bsr->root);
    dump_volume(bsr->volume);
    dump_sessid(bsr->sessid);
    dump_sesstime(bsr->sesstime);
@@ -669,11 +713,17 @@ void dump_bsr(BSR *bsr)
    }
    if (bsr->count) {
       Dmsg1(-1, "count       : %u\n", bsr->count);
+      Dmsg1(-1, "found       : %u\n", bsr->found);
    }
-   if (bsr->next) {
+
+   Dmsg1(-1,    "done        : %s\n", bsr->done?"yes":"no");
+   Dmsg1(-1,    "positioning : %d\n", bsr->use_positioning);
+   Dmsg1(-1,    "fast_reject : %d\n", bsr->use_fast_rejection);
+   if (recurse && bsr->next) {
       Dmsg0(-1, "\n");
-      dump_bsr(bsr->next);
+      dump_bsr(bsr->next, true);
    }
+   debug_level = save_debug;
 }
 
 
@@ -815,7 +865,7 @@ void create_vol_list(JCR *jcr)
       }
    } else {
       /* This is the old way -- deprecated */ 
-      for (p = jcr->VolumeName; p && *p; ) {
+      for (p = jcr->dcr->VolumeName; p && *p; ) {
          n = strchr(p, '|');             /* volume name separator */
         if (n) {
            *n++ = 0;                    /* Terminate name */