src/stored/read.c
bool do_read_data(JCR *jcr)
{
   BSOCK *fd = jcr->file_bsock;
   bool ok = true;
   DCR *dcr = jcr->read_dcr;
   char ec[50];

   Dmsg0(100, "Start read data.\n");

   if (!fd->set_buffer_size(dcr->device->max_network_buffer_size, BNET_SETBUF_WRITE)) {
      return false;
   }

   if (jcr->NumReadVolumes == 0) {
      Jmsg(jcr, M_FATAL, 0, _("No Volume names found for restore.\n"));
      fd->fsend(FD_error);
      return false;
   }

   Dmsg2(200, "Found %d volumes names to restore. First=%s\n", jcr->NumReadVolumes,
      jcr->VolList->VolumeName);

   /* Ready device for reading */
   if (!acquire_device_for_read(dcr)) {
      fd->fsend(FD_error);
      return false;
   }
   dcr->dev->start_of_job(dcr);

   /* Tell File daemon we will send data */
   if (!jcr->is_ok_data_sent) {
      fd->fsend(OK_data);
      jcr->is_ok_data_sent = true;
   }

   jcr->sendJobStatus(JS_Running);
   jcr->run_time = time(NULL);
   jcr->JobFiles = 0;

   if (jcr->is_JobType(JT_MIGRATE) || jcr->is_JobType(JT_COPY)) {
      ok = read_records(dcr, mac_record_cb, mount_next_read_volume);
   } else {
      ok = read_records(dcr, read_record_cb, mount_next_read_volume);
   }

   /*
    * Don't use time_t for job_elapsed as time_t can be 32 or 64 bits,
    *   and the subsequent Jmsg() editing will break
    */
   int32_t job_elapsed = time(NULL) - jcr->run_time;

   if (job_elapsed <= 0) {
      job_elapsed = 1;
   }

   Jmsg(dcr->jcr, M_INFO, 0, _("Elapsed time=%02d:%02d:%02d, Transfer rate=%s Bytes/second\n"),
         job_elapsed / 3600, job_elapsed % 3600 / 60, job_elapsed % 60,
         edit_uint64_with_suffix(jcr->JobBytes / job_elapsed, ec));

   /* Send end of data to FD */
   fd->signal(BNET_EOD);

   if (!release_device(jcr->read_dcr)) {
      ok = false;
   }

   Dmsg0(30, "Done reading.\n");
   return ok;
}
/*
 *  Read Data and send to File Daemon
 *   Returns: false on failure
 *            true  on success
 */
Read Data and send to File Daemon
Returns: false on failure
true  on success
Read Data and send to File Daemon Returns : false on failure true on success
bool do_read_data(JCR *jcr)
{
   BSOCK *fd = jcr->file_bsock;
   bool ok = true;
   DCR *dcr = jcr->read_dcr;
   char ec[50];
   Dmsg0(100, "Start read data.\n");
   if (!fd->set_buffer_size(dcr->device->max_network_buffer_size, BNET_SETBUF_WRITE)) {
      return false;
   }
   if (jcr->NumReadVolumes == 0) {
      Jmsg(jcr, M_FATAL, 0, _("No Volume names found for restore.\n"));
      fd->fsend(FD_error);
      return false;
   }
   Dmsg2(200, "Found %d volumes names to restore. First=%s\n", jcr->NumReadVolumes,
      jcr->VolList->VolumeName);
   if (!acquire_device_for_read(dcr)) {
      fd->fsend(FD_error);
      return false;
   }
   dcr->dev->start_of_job(dcr);
   if (!jcr->is_ok_data_sent) {
      fd->fsend(OK_data);
      jcr->is_ok_data_sent = true;
   }
   jcr->sendJobStatus(JS_Running);
   jcr->run_time = time(NULL);
   jcr->JobFiles = 0;
   if (jcr->is_JobType(JT_MIGRATE) || jcr->is_JobType(JT_COPY)) {
      ok = read_records(dcr, mac_record_cb, mount_next_read_volume);
   } else {
      ok = read_records(dcr, read_record_cb, mount_next_read_volume);
   }
   int32_t job_elapsed = time(NULL) - jcr->run_time;
   if (job_elapsed <= 0) {
      job_elapsed = 1;
   }
   Jmsg(dcr->jcr, M_INFO, 0, _("Elapsed time=%02d:%02d:%02d, Transfer rate=%s Bytes/second\n"),
         job_elapsed / 3600, job_elapsed % 3600 / 60, job_elapsed % 60,
         edit_uint64_with_suffix(jcr->JobBytes / job_elapsed, ec));
   fd->signal(BNET_EOD);
   if (!release_device(jcr->read_dcr)) {
      ok = false;
   }
   Dmsg0(30, "Done reading.\n");
   return ok;
}
bool do_read_data ( JCR * jcr ) { BSOCK * fd = jcr -> file_bsock ; bool ok = true ; DCR * dcr = jcr -> read_dcr ; char ec [ 50 ] ; Dmsg0 ( 100 , " \n " ) ; if ( ! fd -> set_buffer_size ( dcr -> device -> max_network_buffer_size , BNET_SETBUF_WRITE ) ) { return false ; } if ( jcr -> NumReadVolumes == 0 ) { Jmsg ( jcr , M_FATAL , 0 , _ ( " \n " ) ) ; fd -> fsend ( FD_error ) ; return false ; } Dmsg2 ( 200 , " \n " , jcr -> NumReadVolumes , jcr -> VolList -> VolumeName ) ; if ( ! acquire_device_for_read ( dcr ) ) { fd -> fsend ( FD_error ) ; return false ; } dcr -> dev -> start_of_job ( dcr ) ; if ( ! jcr -> is_ok_data_sent ) { fd -> fsend ( OK_data ) ; jcr -> is_ok_data_sent = true ; } jcr -> sendJobStatus ( JS_Running ) ; jcr -> run_time = time ( NULL ) ; jcr -> JobFiles = 0 ; if ( jcr -> is_JobType ( JT_MIGRATE ) || jcr -> is_JobType ( JT_COPY ) ) { ok = read_records ( dcr , mac_record_cb , mount_next_read_volume ) ; } else { ok = read_records ( dcr , read_record_cb , mount_next_read_volume ) ; } int32_t job_elapsed = time ( NULL ) - jcr -> run_time ; if ( job_elapsed <= 0 ) { job_elapsed = 1 ; } Jmsg ( dcr -> jcr , M_INFO , 0 , _ ( " \n " ) , job_elapsed / 3600 , job_elapsed % 3600 / 60 , job_elapsed % 60 , edit_uint64_with_suffix ( jcr -> JobBytes / job_elapsed , ec ) ) ; fd -> signal ( BNET_EOD ) ; if ( ! release_device ( jcr -> read_dcr ) ) { ok = false ; } Dmsg0 ( 30 , " \n " ) ; return ok ; }
Read Data and send to File Daemon
   Returns: false on failure
            true  on success
Read Data and send to File Daemon Returns : false on failure true on success
/* Ready device for reading */ /* Tell File daemon we will send data */ /*
    * Don't use time_t for job_elapsed as time_t can be 32 or 64 bits,
    *   and the subsequent Jmsg() editing will break
    */ /* Send end of data to FD */