Lines Matching refs:s
56 char *s = ""; in verbose_error() local
79 s = " at "; in verbose_error()
84 sparse_print_verbose("EOF while reading file%s%s\n", s, at); in verbose_error()
88 sparse_print_verbose("Invalid sparse file format%s%s\n", s, at); in verbose_error()
91 s, at); in verbose_error()
93 sparse_print_verbose("Unknown error %d%s%s\n", err, s, at); in verbose_error()
101 static int process_raw_chunk(struct sparse_file *s, unsigned int chunk_size, in process_raw_chunk() argument
107 unsigned int len = blocks * s->block_size; in process_raw_chunk()
109 if (chunk_size % s->block_size != 0) { in process_raw_chunk()
113 if (chunk_size / s->block_size != blocks) { in process_raw_chunk()
117 ret = sparse_file_add_fd(s, fd, offset, len, block); in process_raw_chunk()
139 static int process_fill_chunk(struct sparse_file *s, unsigned int chunk_size, in process_fill_chunk() argument
144 int64_t len = (int64_t)blocks * s->block_size; in process_fill_chunk()
158 ret = sparse_file_add_fill(s, fill_val, len, block); in process_fill_chunk()
180 static int process_skip_chunk(struct sparse_file *s, unsigned int chunk_size, in process_skip_chunk() argument
189 int64_t len = (int64_t)blocks * s->block_size; in process_skip_chunk()
223 static int process_chunk(struct sparse_file *s, int fd, off64_t offset, in process_chunk() argument
234 ret = process_raw_chunk(s, chunk_data_size, fd, offset, in process_chunk()
237 verbose_error(s->verbose, ret, "data block at %" PRId64, offset); in process_chunk()
242 ret = process_fill_chunk(s, chunk_data_size, fd, in process_chunk()
245 verbose_error(s->verbose, ret, "fill block at %" PRId64, offset); in process_chunk()
250 ret = process_skip_chunk(s, chunk_data_size, fd, in process_chunk()
254 verbose_error(s->verbose, ret, "skip block at %" PRId64, offset); in process_chunk()
262 verbose_error(s->verbose, -EINVAL, "crc block at %" PRId64, in process_chunk()
268 verbose_error(s->verbose, -EINVAL, "unknown block %04X at %" PRId64, in process_chunk()
275 static int sparse_file_read_sparse(struct sparse_file *s, int fd, bool crc) in sparse_file_read_sparse() argument
341 ret = process_chunk(s, fd, offset, sparse_header.chunk_hdr_sz, &chunk_header, in sparse_file_read_sparse()
357 static int sparse_file_read_normal(struct sparse_file *s, int fd) in sparse_file_read_normal() argument
360 uint32_t *buf = malloc(s->block_size); in sparse_file_read_normal()
362 int64_t remain = s->len; in sparse_file_read_normal()
373 to_read = min(remain, s->block_size); in sparse_file_read_normal()
381 if (to_read == s->block_size) { in sparse_file_read_normal()
383 for (i = 1; i < s->block_size / sizeof(uint32_t); i++) { in sparse_file_read_normal()
395 sparse_file_add_fill(s, buf[0], to_read, block); in sparse_file_read_normal()
397 sparse_file_add_fd(s, fd, offset, to_read, block); in sparse_file_read_normal()
409 int sparse_file_read(struct sparse_file *s, int fd, bool sparse, bool crc) in sparse_file_read() argument
416 return sparse_file_read_sparse(s, fd, crc); in sparse_file_read()
418 return sparse_file_read_normal(s, fd); in sparse_file_read()
427 struct sparse_file *s; in sparse_file_import() local
454 s = sparse_file_new(sparse_header.blk_sz, len); in sparse_file_import()
455 if (!s) { in sparse_file_import()
463 sparse_file_destroy(s); in sparse_file_import()
467 s->verbose = verbose; in sparse_file_import()
469 ret = sparse_file_read(s, fd, true, crc); in sparse_file_import()
471 sparse_file_destroy(s); in sparse_file_import()
475 return s; in sparse_file_import()
480 struct sparse_file *s; in sparse_file_import_auto() local
484 s = sparse_file_import(fd, verbose, crc); in sparse_file_import_auto()
485 if (s) { in sparse_file_import_auto()
486 return s; in sparse_file_import_auto()
496 s = sparse_file_new(4096, len); in sparse_file_import_auto()
497 if (!s) { in sparse_file_import_auto()
501 ret = sparse_file_read_normal(s, fd); in sparse_file_import_auto()
503 sparse_file_destroy(s); in sparse_file_import_auto()
507 return s; in sparse_file_import_auto()