-
- while ((n=bread(bfd, &buf, sizeof(buf))) > 0) {
- crypto_digest_update(digest, &buf, 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);