+ }
+ if (digest && ff_pkt->flags & FO_HFSPLUS) {
+ crypto_digest_update(digest, (uint8_t *)ff_pkt->hfsinfo.fndrinfo, 32);
+ }
+#endif
+ return 0;
+}
+
+/*
+ * 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[DEFAULT_NETWORK_BUFFER_SIZE];
+ int64_t n;
+ int64_t bufsiz = (int64_t)sizeof(buf);
+ FF_PKT *ff_pkt = (FF_PKT *)jcr->ff;
+ uint64_t fileAddr = 0; /* file address */
+
+
+ Dmsg0(50, "=== read_digest\n");
+ 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;