Lines Matching refs:s

73   virtual int AddToSparseFile(struct sparse_file* s, int64_t len, unsigned int block) = 0;
102 int AddToSparseFile(struct sparse_file* s, int64_t len, unsigned int block) override { in AddToSparseFile() argument
103 return sparse_file_add_fd(s, fd, GetOffset(), len, block); in AddToSparseFile()
167 int AddToSparseFile(struct sparse_file* s, int64_t len, unsigned int block) override { in AddToSparseFile() argument
172 return sparse_file_add_data(s, buf, len, block); in AddToSparseFile()
212 static int process_raw_chunk(struct sparse_file* s, unsigned int chunk_size, in process_raw_chunk() argument
216 int64_t len = (int64_t)blocks * s->block_size; in process_raw_chunk()
218 if (chunk_size % s->block_size != 0) { in process_raw_chunk()
222 if (chunk_size / s->block_size != blocks) { in process_raw_chunk()
226 ret = source->AddToSparseFile(s, len, block); in process_raw_chunk()
246 static int process_fill_chunk(struct sparse_file* s, unsigned int chunk_size, in process_fill_chunk() argument
251 int64_t len = (int64_t)blocks * s->block_size; in process_fill_chunk()
265 ret = sparse_file_add_fill(s, fill_val, len, block); in process_fill_chunk()
287 static int process_skip_chunk(struct sparse_file* s, unsigned int chunk_size, in process_skip_chunk() argument
295 int64_t len = (int64_t)blocks * s->block_size; in process_skip_chunk()
327 static int process_chunk(struct sparse_file* s, SparseFileSource* source, unsigned int chunk_hdr_sz, in process_chunk() argument
338 process_raw_chunk(s, chunk_data_size, source, chunk_header->chunk_sz, cur_block, crc_ptr); in process_chunk()
340 verbose_error(s->verbose, ret, "data block at %" PRId64, offset); in process_chunk()
345 ret = process_fill_chunk(s, chunk_data_size, source, chunk_header->chunk_sz, cur_block, in process_chunk()
348 verbose_error(s->verbose, ret, "fill block at %" PRId64, offset); in process_chunk()
353 ret = process_skip_chunk(s, chunk_data_size, source, chunk_header->chunk_sz, cur_block, in process_chunk()
357 verbose_error(s->verbose, ret, "skip block at %" PRId64, offset); in process_chunk()
365 verbose_error(s->verbose, -EINVAL, "crc block at %" PRId64, offset); in process_chunk()
370 verbose_error(s->verbose, -EINVAL, "unknown block %04X at %" PRId64, chunk_header->chunk_type, in process_chunk()
377 static int sparse_file_read_sparse(struct sparse_file* s, SparseFileSource* source, bool crc) { in sparse_file_read_sparse() argument
445 ret = process_chunk(s, source, sparse_header.chunk_hdr_sz, &chunk_header, cur_block, crc_ptr); in sparse_file_read_sparse()
460 static int do_sparse_file_read_normal(struct sparse_file* s, int fd, uint32_t* buf, int64_t offset, in do_sparse_file_read_normal() argument
463 unsigned int block = offset / s->block_size; in do_sparse_file_read_normal()
473 to_read = std::min(remain, (int64_t)(s->block_size)); in do_sparse_file_read_normal()
480 if (to_read == s->block_size) { in do_sparse_file_read_normal()
482 for (i = 1; i < s->block_size / sizeof(uint32_t); i++) { in do_sparse_file_read_normal()
494 sparse_file_add_fill(s, buf[0], to_read, block); in do_sparse_file_read_normal()
496 sparse_file_add_fd(s, fd, offset, to_read, block); in do_sparse_file_read_normal()
507 static int sparse_file_read_normal(struct sparse_file* s, int fd) { in sparse_file_read_normal() argument
509 uint32_t* buf = (uint32_t*)malloc(s->block_size); in sparse_file_read_normal()
514 ret = do_sparse_file_read_normal(s, fd, buf, 0, s->len); in sparse_file_read_normal()
520 static int sparse_file_read_hole(struct sparse_file* s, int fd) { in sparse_file_read_hole() argument
522 uint32_t* buf = (uint32_t*)malloc(s->block_size); in sparse_file_read_hole()
540 } else if (start > s->len) { in sparse_file_read_hole()
550 end = std::min(end, s->len); in sparse_file_read_hole()
552 start = ALIGN_DOWN(start, s->block_size); in sparse_file_read_hole()
553 end = ALIGN(end, s->block_size); in sparse_file_read_hole()
559 ret = do_sparse_file_read_normal(s, fd, buf, start, end - start); in sparse_file_read_hole()
564 } while (end < s->len); in sparse_file_read_hole()
570 static int sparse_file_read_hole(struct sparse_file* s __unused, int fd __unused) { in sparse_file_read_hole()
575 int sparse_file_read(struct sparse_file* s, int fd, enum sparse_read_mode mode, bool crc) { in sparse_file_read() argument
583 return sparse_file_read_sparse(s, &source, crc); in sparse_file_read()
586 return sparse_file_read_normal(s, fd); in sparse_file_read()
588 return sparse_file_read_hole(s, fd); in sparse_file_read()
599 struct sparse_file* s; in sparse_file_import_source() local
634 s = sparse_file_new(sparse_header.blk_sz, len); in sparse_file_import_source()
635 if (!s) { in sparse_file_import_source()
643 sparse_file_destroy(s); in sparse_file_import_source()
647 s->verbose = verbose; in sparse_file_import_source()
649 ret = sparse_file_read_sparse(s, source, crc); in sparse_file_import_source()
651 sparse_file_destroy(s); in sparse_file_import_source()
655 return s; in sparse_file_import_source()
669 struct sparse_file* s; in sparse_file_import_auto() local
673 s = sparse_file_import(fd, false, crc); in sparse_file_import_auto()
674 if (s) { in sparse_file_import_auto()
675 return s; in sparse_file_import_auto()
685 s = sparse_file_new(4096, len); in sparse_file_import_auto()
686 if (!s) { in sparse_file_import_auto()
690 sparse_file_verbose(s); in sparse_file_import_auto()
693 ret = sparse_file_read_normal(s, fd); in sparse_file_import_auto()
695 sparse_file_destroy(s); in sparse_file_import_auto()
699 return s; in sparse_file_import_auto()