src/filed/verify.c
static int read_digest(BFILE *bfd, DIGEST *digest, JCR *jcr)
{
   char  *buf;
   int64_t n;
   int64_t bufsiz = jcr->buf_size;
   FF_PKT *ff_pkt = (FF_PKT *)jcr->ff;
   uint64_t fileAddr = 0;             /* file address */

   buf = (char *)malloc(bufsiz);
   Dmsg0(50, "=== read_digest\n");
   /* With this option, we read shorter blocks, so to not break the
    * sparse block detection, we need to adjust the read size.
    */
   if (ff_pkt->flags & FO_SPARSE) {
      bufsiz -= OFFSET_FADDR_SIZE;
   }
   while ((n=bread(bfd, buf, bufsiz)) > 0) {
      /* Check for sparse blocks */
      if (ff_pkt->flags & FO_SPARSE) {
         bool allZeros = false;
         if ((n == bufsiz &&
              fileAddr+n < (uint64_t)ff_pkt->statp.st_size) ||
             ((ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO) &&
               (uint64_t)ff_pkt->statp.st_size == 0)) {
            allZeros = is_buf_zero(buf, bufsiz);
         }
         fileAddr += n;               /* update file address */
         /* Skip any block of all zeros */
         if (allZeros) {
            continue;                 /* skip block of zeros */
         }
      }

      crypto_digest_update(digest, (uint8_t *)buf, n);

      /* Can be used by BaseJobs or with accurate, update only for Verify
       * jobs
       */
      if (jcr->getJobType() == JT_VERIFY) {
         jcr->JobBytes += n;
      }
      jcr->ReadBytes += n;
   }
   free(buf);
   if (n < 0) {
      berrno be;
      be.set_errno(bfd->berrno);
      Dmsg2(100, "Error reading file %s: ERR=%s\n", jcr->last_fname, be.bstrerror());
      Jmsg(jcr, M_ERROR, 1, _("Error reading file %s: ERR=%s\n"),
            jcr->last_fname, be.bstrerror());
      jcr->JobErrors++;
      return -1;
   }
   return 0;
}
/*
 * Read message digest of bfd, updating digest
 * In case of errors we need the job control record and file name.
 */
Read message digest of bfd, updating digest
In case of errors we need the job control record and file name.
Read message digest of bfd updating digest In case of errors we need the job control record and file name .
static int read_digest(BFILE *bfd, DIGEST *digest, JCR *jcr)
{
   char  *buf;
   int64_t n;
   int64_t bufsiz = jcr->buf_size;
   FF_PKT *ff_pkt = (FF_PKT *)jcr->ff;
   uint64_t fileAddr = 0;             
   buf = (char *)malloc(bufsiz);
   Dmsg0(50, "=== read_digest\n");
   if (ff_pkt->flags & FO_SPARSE) {
      bufsiz -= OFFSET_FADDR_SIZE;
   }
   while ((n=bread(bfd, buf, bufsiz)) > 0) {
      if (ff_pkt->flags & FO_SPARSE) {
         bool allZeros = false;
         if ((n == bufsiz &&
              fileAddr+n < (uint64_t)ff_pkt->statp.st_size) ||
             ((ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO) &&
               (uint64_t)ff_pkt->statp.st_size == 0)) {
            allZeros = is_buf_zero(buf, bufsiz);
         }
         fileAddr += n;               
         if (allZeros) {
            continue;                 
         }
      }
      crypto_digest_update(digest, (uint8_t *)buf, n);
      if (jcr->getJobType() == JT_VERIFY) {
         jcr->JobBytes += n;
      }
      jcr->ReadBytes += n;
   }
   free(buf);
   if (n < 0) {
      berrno be;
      be.set_errno(bfd->berrno);
      Dmsg2(100, "Error reading file %s: ERR=%s\n", jcr->last_fname, be.bstrerror());
      Jmsg(jcr, M_ERROR, 1, _("Error reading file %s: ERR=%s\n"),
            jcr->last_fname, be.bstrerror());
      jcr->JobErrors++;
      return -1;
   }
   return 0;
}
static int read_digest ( BFILE * bfd , DIGEST * digest , JCR * jcr ) { char * buf ; int64_t n ; int64_t bufsiz = jcr -> buf_size ; FF_PKT * ff_pkt = ( FF_PKT * ) jcr -> ff ; uint64_t fileAddr = 0 ; buf = ( char * ) malloc ( bufsiz ) ; Dmsg0 ( 50 , " \n " ) ; if ( ff_pkt -> flags & FO_SPARSE ) { bufsiz -= OFFSET_FADDR_SIZE ; } while ( ( n = bread ( bfd , buf , bufsiz ) ) > 0 ) { if ( ff_pkt -> flags & FO_SPARSE ) { bool allZeros = false ; if ( ( n == bufsiz && fileAddr + n < ( uint64_t ) ff_pkt -> statp . st_size ) || ( ( ff_pkt -> type == FT_RAW || ff_pkt -> type == FT_FIFO ) && ( uint64_t ) ff_pkt -> statp . st_size == 0 ) ) { allZeros = is_buf_zero ( buf , bufsiz ) ; } fileAddr += n ; if ( allZeros ) { continue ; } } crypto_digest_update ( digest , ( uint8_t * ) buf , n ) ; if ( jcr -> getJobType ( ) == JT_VERIFY ) { jcr -> JobBytes += n ; } jcr -> ReadBytes += n ; } free ( buf ) ; if ( n < 0 ) { berrno be ; be . set_errno ( bfd -> berrno ) ; Dmsg2 ( 100 , " \n " , jcr -> last_fname , be . bstrerror ( ) ) ; Jmsg ( jcr , M_ERROR , 1 , _ ( " \n " ) , jcr -> last_fname , be . bstrerror ( ) ) ; jcr -> JobErrors ++ ; return -1 ; } return 0 ; }
Read message digest of bfd, updating digest
 In case of errors we need the job control record and file name.
Read message digest of bfd updating digest In case of errors we need the job control record and file name .
/* file address */ /* With this option, we read shorter blocks, so to not break the
    * sparse block detection, we need to adjust the read size.
    */ /* Check for sparse blocks */ /* update file address */ /* Skip any block of all zeros */ /* skip block of zeros */ /* Can be used by BaseJobs or with accurate, update only for Verify
       * jobs
       */