]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/label.c
Add V: to bextract and bscan
[bacula/bacula] / bacula / src / stored / label.c
index a99b9188e1083366b151cfd9222d485cf08feaa8..1912d1571e0d22567df59229032f3b263f882513 100644 (file)
@@ -68,14 +68,13 @@ int read_dev_volume_label(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
    if (dev->state & ST_LABEL) {       /* did we already read label? */
       /* Compare Volume Names allow special wild card */
       if (VolName && *VolName && *VolName != '*' && strcmp(dev->VolHdr.VolName, VolName) != 0) {
-         Mmsg(&jcr->errmsg, _("Volume name mismatch on device %s: Wanted %s got %s\n"),
+         Mmsg(&jcr->errmsg, _("Wrong Volume mounted on device %s: Wanted %s have %s\n"),
            dev_name(dev), VolName, dev->VolHdr.VolName);
         /*
          * Cancel Job if too many label errors
          *  => we are in a loop
          */
-        if (jcr->label_errors > 100) {
-           set_jcr_job_status(jcr, JS_ErrorTerminated);
+        if (jcr->label_errors++ > 100) {
             Jmsg(jcr, M_FATAL, 0, "%s", jcr->errmsg);
         }
         return jcr->label_status = VOL_NAME_ERROR;
@@ -93,10 +92,10 @@ int read_dev_volume_label(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
    }
    strcpy(dev->VolHdr.Id, "**error**");
 
-   /* Read the device label block */
+   /* Read the Volume label block */
    record = new_record();
    Dmsg0(90, "Big if statement in read_volume_label\n");
-   if (!read_block_from_dev(dev, block)) { 
+   if (!read_block_from_dev(jcr, dev, block, NO_BLOCK_NUMBER_CHECK)) { 
       Mmsg(&jcr->errmsg, _("Volume on %s is not a Bacula labeled Volume, \
 because:\n   %s"), dev_name(dev), strerror_dev(dev));
    } else if (!read_record_from_block(block, record)) {
@@ -135,14 +134,13 @@ because:\n   %s"), dev_name(dev), strerror_dev(dev));
    /* Compare Volume Names */
    Dmsg2(30, "Compare Vol names: VolName=%s hdr=%s\n", VolName?VolName:"*", dev->VolHdr.VolName);
    if (VolName && *VolName && *VolName != '*' && strcmp(dev->VolHdr.VolName, VolName) != 0) {
-      Mmsg(&jcr->errmsg, _("Volume name mismatch. Wanted %s got %s\n"),
-        VolName, dev->VolHdr.VolName);
+      Mmsg(&jcr->errmsg, _("Wrong Volume mounted on device %s: Wanted %s have %s\n"),
+          dev_name(dev), VolName, dev->VolHdr.VolName);
       /*
        * Cancel Job if too many label errors
        *  => we are in a loop
        */
-      if (jcr->label_errors > 100) {
-        set_jcr_job_status(jcr, JS_ErrorTerminated);
+      if (jcr->label_errors++ > 100) {
          Jmsg(jcr, M_FATAL, 0, "%s", jcr->errmsg);
       }
       return jcr->label_status = VOL_NAME_ERROR;
@@ -245,6 +243,7 @@ int write_volume_label_to_block(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
    create_volume_label_record(jcr, dev, &rec);
 
    empty_block(block);               /* Volume label always at beginning */
+   block->BlockNumber = 0;
    if (!write_record_to_block(block, &rec)) {
       free_pool_memory(rec.data);
       Jmsg1(jcr, M_FATAL, 0, _("Cannot write Volume label to block for device %s\n"),
@@ -442,7 +441,6 @@ int write_volume_label_to_dev(JCR *jcr, DEVRES *device, char *VolName, char *Poo
 void create_session_label(JCR *jcr, DEV_RECORD *rec, int label)
 {
    ser_declare;
-   struct date_time dt;
 
    rec->sync          = 1;         /* wait for completion */
    rec->VolSessionId   = jcr->VolSessionId;
@@ -456,15 +454,9 @@ void create_session_label(JCR *jcr, DEV_RECORD *rec, int label)
 
    ser_uint32(jcr->JobId);
 
-   if (BaculaTapeVersion >= 11) {
-      ser_btime(get_current_btime());
-      ser_float64(0);
-   } else {
-      /* OLD WAY DEPRECATED */
-      get_current_time(&dt);
-      ser_float64(dt.julian_day_number);
-      ser_float64(dt.julian_day_fraction);
-   }
+   /* Changed in VerNum 11 */
+   ser_btime(get_current_btime());
+   ser_float64(0);
 
    ser_string(jcr->pool_name);
    ser_string(jcr->pool_type);
@@ -476,9 +468,8 @@ void create_session_label(JCR *jcr, DEV_RECORD *rec, int label)
    ser_string(jcr->fileset_name);
    ser_uint32(jcr->JobType);
    ser_uint32(jcr->JobLevel);
-   if (BaculaTapeVersion >= 11) {
-      ser_string(jcr->fileset_md5);
-   }
+   /* Added in VerNum 11 */
+   ser_string(jcr->fileset_md5);
 
    if (label == EOS_LABEL) {
       ser_uint32(jcr->JobFiles);
@@ -508,27 +499,27 @@ int write_session_label(JCR *jcr, DEV_BLOCK *block, int label)
    rec = new_record();
    Dmsg1(90, "session_label record=%x\n", rec);
    switch (label) {
-      case SOS_LABEL:
-        if (dev->state & ST_TAPE) {
-           jcr->StartBlock = dev->block_num;
-           jcr->StartFile  = dev->file;
-        } else {
-           jcr->StartBlock = (uint32_t)dev->file_addr;
-           jcr->StartFile = (uint32_t)(dev->file_addr >> 32);
-        }
-        break;
-      case EOS_LABEL:
-        if (dev->state & ST_TAPE) {
-           jcr->EndBlock = dev->EndBlock;
-           jcr->EndFile  = dev->EndFile;
-        } else {
-           jcr->EndBlock = (uint32_t)dev->file_addr;
-           jcr->EndFile = (uint32_t)(dev->file_addr >> 32);
-        }
-        break;
-      default:
-         Jmsg1(jcr, M_ABORT, 0, _("Bad session label = %d\n"), label);
-        break;
+   case SOS_LABEL:
+      if (dev->state & ST_TAPE) {
+        jcr->StartBlock = dev->block_num;
+        jcr->StartFile  = dev->file;
+      } else {
+        jcr->StartBlock = (uint32_t)dev->file_addr;
+        jcr->StartFile = (uint32_t)(dev->file_addr >> 32);
+      }
+      break;
+   case EOS_LABEL:
+      if (dev->state & ST_TAPE) {
+        jcr->EndBlock = dev->EndBlock;
+        jcr->EndFile  = dev->EndFile;
+      } else {
+        jcr->EndBlock = (uint32_t)dev->file_addr;
+        jcr->EndFile = (uint32_t)(dev->file_addr >> 32);
+      }
+      break;
+   default:
+      Jmsg1(jcr, M_ABORT, 0, _("Bad session label = %d\n"), label);
+      break;
    }
    create_session_label(jcr, rec, label);
    rec->FileIndex = label;