Lines Matching refs:offset

66 /* checks if `offset' is within a corrupted block */
67 static inline bool is_erasure(fec_handle *f, uint64_t offset,
70 if (unlikely(offset >= f->data_size)) {
78 uint64_t n = offset / FEC_BLOCKSIZE;
84 /* check if `offset' is within a block expected to contain zeros */
85 static inline bool is_zero(fec_handle *f, uint64_t offset)
89 if (!v->hash || unlikely(offset >= f->data_size)) {
93 uint64_t hash_offset = (offset / FEC_BLOCKSIZE) * SHA256_DIGEST_LENGTH;
103 /* reads and decodes a single block starting from `offset', returns the number
105 static int __ecc_read(fec_handle *f, void *rs, uint8_t *dest, uint64_t offset,
108 check(offset % FEC_BLOCKSIZE == 0);
112 offset */
113 uint64_t rsb = offset - (offset / (e->rounds * FEC_BLOCKSIZE)) *
126 if (interleaved == offset) {
230 /* reads `count' bytes from `offset' and corrects possible errors without
233 uint64_t offset, size_t *errors)
237 check(offset < f->data_size);
238 check(offset + count <= f->data_size);
241 debug("[%" PRIu64 ", %" PRIu64 ")", offset, offset + count);
250 uint64_t curr = offset / FEC_BLOCKSIZE;
251 size_t coff = (size_t)(offset - curr * FEC_BLOCKSIZE);
280 /* reads `count' bytes from `offset', corrects possible errors with
284 uint64_t offset, size_t *errors)
288 check(offset < f->data_size);
289 check(offset + count <= f->data_size);
293 debug("[%" PRIu64 ", %" PRIu64 ")", offset, offset + count);
302 uint64_t curr = offset / FEC_BLOCKSIZE;
303 size_t coff = (size_t)(offset - curr * FEC_BLOCKSIZE);
345 offset, offset + count, curr);
349 offset, offset + count, curr);
368 " (offset %" PRIu64 ") cannot be recovered",
369 offset, offset + count, curr, curr_offset);
401 /* sets the internal file position to `offset' relative to `whence' */
402 int fec_seek(struct fec_handle *f, int64_t offset, int whence)
407 if (offset < 0) {
412 f->pos = offset;
414 if (offset < 0 && f->pos < (uint64_t)-offset) {
417 } else if (offset > 0 && (uint64_t)offset > UINT64_MAX - f->pos) {
422 f->pos += offset;
424 if (offset >= 0) {
427 } else if ((uint64_t)-offset > f->size) {
432 f->pos = f->size + offset;
456 from `offset', up to `count' bytes */
457 static inline size_t get_max_count(uint64_t offset, size_t count, uint64_t max)
459 if (offset >= max) {
461 } else if (offset > max - count) {
462 return (size_t)(max - offset);
468 /* reads `count' bytes from `f->fd' starting from `offset', and copies the
470 bool raw_pread(fec_handle *f, void *buf, size_t count, uint64_t offset)
479 ssize_t n = TEMP_FAILURE_RETRY(pread64(f->fd, p, remaining, offset));
487 offset += n;
493 /* writes `count' bytes from `buf' to `f->fd' to a file position `offset' */
494 bool raw_pwrite(fec_handle *f, const void *buf, size_t count, uint64_t offset)
503 ssize_t n = TEMP_FAILURE_RETRY(pwrite64(f->fd, p, remaining, offset));
511 offset += n;
517 /* reads up to `count' bytes starting from `offset' using error correction and
520 uint64_t offset)
525 if (unlikely(offset > UINT64_MAX - count)) {
532 get_max_count(offset, count, f->data_size), offset,
537 count = get_max_count(offset, count, f->data_size);
538 ssize_t rc = process(f, (uint8_t *)buf, count, offset, ecc_read);
547 count = get_max_count(offset, count, f->size);
550 if (raw_pread(f, buf, count, offset)) {