]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/mac.c
Merge branch 'master' into basejobv3
[bacula/bacula] / bacula / src / stored / mac.c
index de22d4f15b08ceb4a4926b3a655b0de67f308ab6..ce2c3707976f378984b7dd076b3a0e790fd4c430 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2006-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2006-2009 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.
@@ -84,8 +84,6 @@ bool do_mac(JCR *jcr)
    }
    Dmsg2(100, "read_dcr=%p write_dcr=%p\n", jcr->read_dcr, jcr->dcr);
 
-
-   create_restore_volume_list(jcr);
    if (jcr->NumReadVolumes == 0) {
       Jmsg(jcr, M_FATAL, 0, _("No Volume names found for %s.\n"), Type);
       goto bail_out;
@@ -113,6 +111,7 @@ bool do_mac(JCR *jcr)
    jcr->run_time = time(NULL);
    set_start_vol_position(jcr->dcr);
 
+   jcr->JobFiles = 0;
    ok = read_records(jcr->read_dcr, record_cb, mount_next_read_volume);
    goto ok_out;
 
@@ -160,11 +159,8 @@ ok_out:
       }
    }
 
-   free_restore_volume_list(jcr);
-
    dir_send_job_status(jcr);          /* update director */
 
-
    Dmsg0(30, "Done reading.\n");
    jcr->end_time = time(NULL);
    dequeue_messages(jcr);             /* send any queued messages */
@@ -173,7 +169,7 @@ ok_out:
    }
    generate_daemon_event(jcr, "JobEnd");
    dir->fsend(Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles,
-      edit_uint64(jcr->JobBytes, ec1));
+      edit_uint64(jcr->JobBytes, ec1), jcr->JobErrors);
    Dmsg4(100, Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles, ec1); 
        
    dir->signal(BNET_EOD);             /* send EOD to Director daemon */
@@ -192,10 +188,13 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
    DEVICE *dev = jcr->dcr->dev;
    char buf1[100], buf2[100];
    int32_t stream;   
-   uint32_t last_VolSessionId = 0;
-   uint32_t last_VolSessionTime = 0;
-   int32_t  last_FileIndex = 0;
    
+#ifdef xxx
+   Dmsg5(000, "on entry     JobId=%d FI=%s SessId=%d Strm=%s len=%d\n",
+      jcr->JobId,
+      FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
+      stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len);
+#endif
    /* If label and not for us, discard it */
    if (rec->FileIndex < 0 && rec->match_stat <= 0) {
       return true;
@@ -208,7 +207,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
    case EOM_LABEL:
       return true;                    /* don't write vol labels */
    }
-   if (jcr->get_JobType() == JT_BACKUP) {
+//   if (jcr->get_JobType() == JT_BACKUP) {
       /*
        * For normal migration jobs, FileIndex values are sequential because
        *  we are dealing with one job.  However, for Vbackup (consolidation),
@@ -217,29 +216,29 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
        *  We do so by detecting a FileIndex change and incrementing the
        *  JobFiles, which we then use as the output FileIndex.
        */
-      if (rec->VolSessionId != last_VolSessionId || 
-          rec->VolSessionTime != last_VolSessionTime ||
-          (rec->FileIndex > 0 && rec->FileIndex != last_FileIndex)) {
-         jcr->JobFiles++;
-         last_VolSessionId = rec->VolSessionId;
-         last_VolSessionTime = rec->VolSessionTime;
-         last_FileIndex = rec->FileIndex;
-      }
-      if (rec->FileIndex > 0) {
+      if (rec->FileIndex >= 0) { 
+         /* If something changed, increment FileIndex */
+         if (rec->VolSessionId != rec->last_VolSessionId || 
+             rec->VolSessionTime != rec->last_VolSessionTime ||
+             rec->FileIndex != rec->last_FileIndex) {
+            jcr->JobFiles++;
+            rec->last_VolSessionId = rec->VolSessionId;
+            rec->last_VolSessionTime = rec->VolSessionTime;
+            rec->last_FileIndex = rec->FileIndex;
+         }
          rec->FileIndex = jcr->JobFiles;     /* set sequential output FileIndex */
       }
-   }
+//   }
    /*
     * Modify record SessionId and SessionTime to correspond to
     * output.
     */
    rec->VolSessionId = jcr->VolSessionId;
    rec->VolSessionTime = jcr->VolSessionTime;
-   Dmsg5(200, "before write_rec JobId=%d FI=%s SessId=%d Strm=%s len=%d\n",
+   Dmsg5(200, "before write JobId=%d FI=%s SessId=%d Strm=%s len=%d\n",
       jcr->JobId,
       FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
-      stream_to_ascii(buf1, rec->Stream,rec->FileIndex), rec->data_len);
-
+      stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len);
    while (!write_record_to_block(jcr->dcr->block, rec)) {
       Dmsg4(200, "!write_record_to_block blkpos=%u:%u len=%d rem=%d\n", 
             dev->file, dev->block_num, rec->data_len, rec->remainder);
@@ -252,10 +251,13 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
       }
       Dmsg2(200, "===== Wrote block new pos %u:%u\n", dev->file, dev->block_num);
    }
-   jcr->JobBytes += rec->data_len;   /* increment bytes this job */
-   if (rec->FileIndex <= 0) {
+   /* Restore packet */
+   rec->VolSessionId = rec->last_VolSessionId;
+   rec->VolSessionTime = rec->last_VolSessionTime;
+   if (rec->FileIndex < 0) {
       return true;                    /* don't send LABELs to Dir */
    }
+   jcr->JobBytes += rec->data_len;   /* increment bytes this job */
    Dmsg5(500, "wrote_record JobId=%d FI=%s SessId=%d Strm=%s len=%d\n",
       jcr->JobId,
       FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,