src/stored/bcopy.c
static bool record_cb(DCR *in_dcr, DEV_RECORD *rec)
{
   if (list_records) {
      Pmsg5(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u\n"),
            rec->VolSessionId, rec->VolSessionTime, rec->FileIndex,
            rec->Stream, rec->data_len);
   }
   /*
    * Check for Start or End of Session Record
    *
    */
   if (rec->FileIndex < 0) {
      get_session_record(in_dcr->dev, rec, &sessrec);

      if (verbose > 1) {
         dump_label_record(in_dcr->dev, rec, 1/*verbose*/, false/*check err*/);
      }
      switch (rec->FileIndex) {
      case PRE_LABEL:
         Pmsg0(000, _("Volume is prelabeled. This volume cannot be copied.\n"));
         return false;
      case VOL_LABEL:
         Pmsg0(000, _("Volume label not copied.\n"));
         return true;
      case SOS_LABEL:
         if (bsr && rec->match_stat < 1) {
            /* Skipping record, because does not match BSR filter */
            if (verbose) {
             Pmsg0(-1, _("Copy skipped. Record does not match BSR filter.\n"));
            }
         } else {
            jobs++;
         }
         break;
      case EOS_LABEL:
         if (bsr && rec->match_stat < 1) {
            /* Skipping record, because does not match BSR filter */
           return true;
        }
         while (!write_record_to_block(out_jcr->dcr, rec)) {
            Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec->data_len,
                       rec->remainder);
            if (!out_jcr->dcr->write_block_to_device()) {
               Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
                  out_dev->print_name(), out_dev->bstrerror());
               Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
                     out_dev->bstrerror());
               return false;
            }
         }
         if (!out_jcr->dcr->write_block_to_device()) {
            Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
               out_dev->print_name(), out_dev->bstrerror());
            Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
                  out_dev->bstrerror());
            return false;
         }
         return true;
      case EOM_LABEL:
         Pmsg0(000, _("EOM label not copied.\n"));
         return true;
      case EOT_LABEL:              /* end of all tapes */
         Pmsg0(000, _("EOT label not copied.\n"));
         return true;
      default:
         return true;
      }
   }

   /*  Write record */
   if (bsr && rec->match_stat < 1) {
      /* Skipping record, because does not match BSR filter */
      return true;
   }
   records++;
   while (!write_record_to_block(out_jcr->dcr, rec)) {
      Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec->data_len,
                 rec->remainder);
      if (!out_jcr->dcr->write_block_to_device()) {
         Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
            out_dev->print_name(), out_dev->bstrerror());
         Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
               out_dev->bstrerror());
         return false;
      }
   }
   return true;
}
/*
 * read_records() calls back here for each record it gets
 */
read_records() calls back here for each record it gets
read_records () calls back here for each record it gets
static bool record_cb(DCR *in_dcr, DEV_RECORD *rec)
{
   if (list_records) {
      Pmsg5(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u\n"),
            rec->VolSessionId, rec->VolSessionTime, rec->FileIndex,
            rec->Stream, rec->data_len);
   }
   if (rec->FileIndex < 0) {
      get_session_record(in_dcr->dev, rec, &sessrec);
      if (verbose > 1) {
         dump_label_record(in_dcr->dev, rec, 1, false);
      }
      switch (rec->FileIndex) {
      case PRE_LABEL:
         Pmsg0(000, _("Volume is prelabeled. This volume cannot be copied.\n"));
         return false;
      case VOL_LABEL:
         Pmsg0(000, _("Volume label not copied.\n"));
         return true;
      case SOS_LABEL:
         if (bsr && rec->match_stat < 1) {
            if (verbose) {
             Pmsg0(-1, _("Copy skipped. Record does not match BSR filter.\n"));
            }
         } else {
            jobs++;
         }
         break;
      case EOS_LABEL:
         if (bsr && rec->match_stat < 1) {
           return true;
        }
         while (!write_record_to_block(out_jcr->dcr, rec)) {
            Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec->data_len,
                       rec->remainder);
            if (!out_jcr->dcr->write_block_to_device()) {
               Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
                  out_dev->print_name(), out_dev->bstrerror());
               Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
                     out_dev->bstrerror());
               return false;
            }
         }
         if (!out_jcr->dcr->write_block_to_device()) {
            Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
               out_dev->print_name(), out_dev->bstrerror());
            Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
                  out_dev->bstrerror());
            return false;
         }
         return true;
      case EOM_LABEL:
         Pmsg0(000, _("EOM label not copied.\n"));
         return true;
      case EOT_LABEL:              
         Pmsg0(000, _("EOT label not copied.\n"));
         return true;
      default:
         return true;
      }
   }
   if (bsr && rec->match_stat < 1) {
      return true;
   }
   records++;
   while (!write_record_to_block(out_jcr->dcr, rec)) {
      Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec->data_len,
                 rec->remainder);
      if (!out_jcr->dcr->write_block_to_device()) {
         Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
            out_dev->print_name(), out_dev->bstrerror());
         Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
               out_dev->bstrerror());
         return false;
      }
   }
   return true;
}
static bool record_cb ( DCR * in_dcr , DEV_RECORD * rec ) { if ( list_records ) { Pmsg5 ( 000 , _ ( " \n " ) , rec -> VolSessionId , rec -> VolSessionTime , rec -> FileIndex , rec -> Stream , rec -> data_len ) ; } if ( rec -> FileIndex < 0 ) { get_session_record ( in_dcr -> dev , rec , & sessrec ) ; if ( verbose > 1 ) { dump_label_record ( in_dcr -> dev , rec , 1 , false ) ; } switch ( rec -> FileIndex ) { case PRE_LABEL : Pmsg0 ( 000 , _ ( " \n " ) ) ; return false ; case VOL_LABEL : Pmsg0 ( 000 , _ ( " \n " ) ) ; return true ; case SOS_LABEL : if ( bsr && rec -> match_stat < 1 ) { if ( verbose ) { Pmsg0 ( -1 , _ ( " \n " ) ) ; } } else { jobs ++ ; } break ; case EOS_LABEL : if ( bsr && rec -> match_stat < 1 ) { return true ; } while ( ! write_record_to_block ( out_jcr -> dcr , rec ) ) { Dmsg2 ( 150 , " \n " , rec -> data_len , rec -> remainder ) ; if ( ! out_jcr -> dcr -> write_block_to_device ( ) ) { Dmsg2 ( 90 , " \n " , out_dev -> print_name ( ) , out_dev -> bstrerror ( ) ) ; Jmsg ( out_jcr , M_FATAL , 0 , _ ( " \n " ) , out_dev -> bstrerror ( ) ) ; return false ; } } if ( ! out_jcr -> dcr -> write_block_to_device ( ) ) { Dmsg2 ( 90 , " \n " , out_dev -> print_name ( ) , out_dev -> bstrerror ( ) ) ; Jmsg ( out_jcr , M_FATAL , 0 , _ ( " \n " ) , out_dev -> bstrerror ( ) ) ; return false ; } return true ; case EOM_LABEL : Pmsg0 ( 000 , _ ( " \n " ) ) ; return true ; case EOT_LABEL : Pmsg0 ( 000 , _ ( " \n " ) ) ; return true ; default : return true ; } } if ( bsr && rec -> match_stat < 1 ) { return true ; } records ++ ; while ( ! write_record_to_block ( out_jcr -> dcr , rec ) ) { Dmsg2 ( 150 , " \n " , rec -> data_len , rec -> remainder ) ; if ( ! out_jcr -> dcr -> write_block_to_device ( ) ) { Dmsg2 ( 90 , " \n " , out_dev -> print_name ( ) , out_dev -> bstrerror ( ) ) ; Jmsg ( out_jcr , M_FATAL , 0 , _ ( " \n " ) , out_dev -> bstrerror ( ) ) ; return false ; } } return true ; }
read_records() calls back here for each record it gets
read_records () calls back here for each record it gets
/*
    * Check for Start or End of Session Record
    *
    */ /*verbose*/ /*check err*/ /* Skipping record, because does not match BSR filter */ /* Skipping record, because does not match BSR filter */ /* end of all tapes */ /*  Write record */ /* Skipping record, because does not match BSR filter */