src/filed/verify.c
int digest_file(JCR *jcr, FF_PKT *ff_pkt, DIGEST *digest)
{
   BFILE bfd;

   Dmsg0(50, "=== digest_file\n");
   binit(&bfd);

   if (ff_pkt->statp.st_size > 0 || ff_pkt->type == FT_RAW
         || ff_pkt->type == FT_FIFO) {
      int noatime = ff_pkt->flags & FO_NOATIME ? O_NOATIME : 0;
      if ((bopen(&bfd, ff_pkt->fname, O_RDONLY | O_BINARY | noatime, 0)) < 0) {
         ff_pkt->ff_errno = errno;
         berrno be;
         be.set_errno(bfd.berrno);
         Dmsg2(100, "Cannot open %s: ERR=%s\n", ff_pkt->fname, be.bstrerror());
         Jmsg(jcr, M_ERROR, 1, _("     Cannot open %s: ERR=%s.\n"),
               ff_pkt->fname, be.bstrerror());
         return 1;
      }
      read_digest(&bfd, digest, jcr);
      bclose(&bfd);
   }

#ifdef HAVE_DARWIN_OS
   /* Open resource fork if necessary */
   if (ff_pkt->flags & FO_HFSPLUS && ff_pkt->hfsinfo.rsrclength > 0) {
      if (bopen_rsrc(&bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) {
         ff_pkt->ff_errno = errno;
         berrno be;
         Jmsg(jcr, M_ERROR, -1, _("     Cannot open resource fork for %s: ERR=%s.\n"),
               ff_pkt->fname, be.bstrerror());
         if (is_bopen(&ff_pkt->bfd)) {
            bclose(&ff_pkt->bfd);
         }
         return 1;
      } 
      read_digest(&bfd, digest, jcr);
      bclose(&bfd);
   } 
   if (digest && ff_pkt->flags & FO_HFSPLUS) {
      crypto_digest_update(digest, (uint8_t *)ff_pkt->hfsinfo.fndrinfo, 32);
   } 
#endif
   return 0;
}
/*
 * Compute message digest for the file specified by ff_pkt.
 * In case of errors we need the job control record and file name.
 */
Compute message digest for the file specified by ff_pkt.
In case of errors we need the job control record and file name.
Compute message digest for the file specified by ff_pkt . In case of errors we need the job control record and file name .
int digest_file(JCR *jcr, FF_PKT *ff_pkt, DIGEST *digest)
{
   BFILE bfd;
   Dmsg0(50, "=== digest_file\n");
   binit(&bfd);
   if (ff_pkt->statp.st_size > 0 || ff_pkt->type == FT_RAW
         || ff_pkt->type == FT_FIFO) {
      int noatime = ff_pkt->flags & FO_NOATIME ? O_NOATIME : 0;
      if ((bopen(&bfd, ff_pkt->fname, O_RDONLY | O_BINARY | noatime, 0)) < 0) {
         ff_pkt->ff_errno = errno;
         berrno be;
         be.set_errno(bfd.berrno);
         Dmsg2(100, "Cannot open %s: ERR=%s\n", ff_pkt->fname, be.bstrerror());
         Jmsg(jcr, M_ERROR, 1, _("     Cannot open %s: ERR=%s.\n"),
               ff_pkt->fname, be.bstrerror());
         return 1;
      }
      read_digest(&bfd, digest, jcr);
      bclose(&bfd);
   }
#ifdef HAVE_DARWIN_OS
   if (ff_pkt->flags & FO_HFSPLUS && ff_pkt->hfsinfo.rsrclength > 0) {
      if (bopen_rsrc(&bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) {
         ff_pkt->ff_errno = errno;
         berrno be;
         Jmsg(jcr, M_ERROR, -1, _("     Cannot open resource fork for %s: ERR=%s.\n"),
               ff_pkt->fname, be.bstrerror());
         if (is_bopen(&ff_pkt->bfd)) {
            bclose(&ff_pkt->bfd);
         }
         return 1;
      } 
      read_digest(&bfd, digest, jcr);
      bclose(&bfd);
   } 
   if (digest && ff_pkt->flags & FO_HFSPLUS) {
      crypto_digest_update(digest, (uint8_t *)ff_pkt->hfsinfo.fndrinfo, 32);
   } 
#endif
   return 0;
}
int digest_file ( JCR * jcr , FF_PKT * ff_pkt , DIGEST * digest ) { BFILE bfd ; Dmsg0 ( 50 , " \n " ) ; binit ( & bfd ) ; if ( ff_pkt -> statp . st_size > 0 || ff_pkt -> type == FT_RAW || ff_pkt -> type == FT_FIFO ) { int noatime = ff_pkt -> flags & FO_NOATIME ? O_NOATIME : 0 ; if ( ( bopen ( & bfd , ff_pkt -> fname , O_RDONLY | O_BINARY | noatime , 0 ) ) < 0 ) { ff_pkt -> ff_errno = errno ; berrno be ; be . set_errno ( bfd . berrno ) ; Dmsg2 ( 100 , " \n " , ff_pkt -> fname , be . bstrerror ( ) ) ; Jmsg ( jcr , M_ERROR , 1 , _ ( " \n " ) , ff_pkt -> fname , be . bstrerror ( ) ) ; return 1 ; } read_digest ( & bfd , digest , jcr ) ; bclose ( & bfd ) ; } #ifdef HAVE_DARWIN_OS if ( ff_pkt -> flags & FO_HFSPLUS && ff_pkt -> hfsinfo . rsrclength > 0 ) { if ( bopen_rsrc ( & bfd , ff_pkt -> fname , O_RDONLY | O_BINARY , 0 ) < 0 ) { ff_pkt -> ff_errno = errno ; berrno be ; Jmsg ( jcr , M_ERROR , -1 , _ ( " \n " ) , ff_pkt -> fname , be . bstrerror ( ) ) ; if ( is_bopen ( & ff_pkt -> bfd ) ) { bclose ( & ff_pkt -> bfd ) ; } return 1 ; } read_digest ( & bfd , digest , jcr ) ; bclose ( & bfd ) ; } if ( digest && ff_pkt -> flags & FO_HFSPLUS ) { crypto_digest_update ( digest , ( uint8_t * ) ff_pkt -> hfsinfo . fndrinfo , 32 ) ; } #endif return 0 ; }
Compute message digest for the file specified by ff_pkt.
Compute message digest for the file specified by ff_pkt .
/* Open resource fork if necessary */