Lines Matching refs:s
32 struct sparse_file *s = calloc(sizeof(struct sparse_file), 1); in sparse_file_new() local
33 if (!s) { in sparse_file_new()
37 s->backed_block_list = backed_block_list_new(block_size); in sparse_file_new()
38 if (!s->backed_block_list) { in sparse_file_new()
39 free(s); in sparse_file_new()
43 s->block_size = block_size; in sparse_file_new()
44 s->len = len; in sparse_file_new()
46 return s; in sparse_file_new()
49 void sparse_file_destroy(struct sparse_file *s) in sparse_file_destroy() argument
51 backed_block_list_destroy(s->backed_block_list); in sparse_file_destroy()
52 free(s); in sparse_file_destroy()
55 int sparse_file_add_data(struct sparse_file *s, in sparse_file_add_data() argument
58 return backed_block_add_data(s->backed_block_list, data, len, block); in sparse_file_add_data()
61 int sparse_file_add_fill(struct sparse_file *s, in sparse_file_add_fill() argument
64 return backed_block_add_fill(s->backed_block_list, fill_val, len, block); in sparse_file_add_fill()
67 int sparse_file_add_file(struct sparse_file *s, in sparse_file_add_file() argument
71 return backed_block_add_file(s->backed_block_list, filename, file_offset, in sparse_file_add_file()
75 int sparse_file_add_fd(struct sparse_file *s, in sparse_file_add_fd() argument
78 return backed_block_add_fd(s->backed_block_list, fd, file_offset, in sparse_file_add_fd()
81 unsigned int sparse_count_chunks(struct sparse_file *s) in sparse_count_chunks() argument
87 for (bb = backed_block_iter_new(s->backed_block_list); bb; in sparse_count_chunks()
95 DIV_ROUND_UP(backed_block_len(bb), s->block_size); in sparse_count_chunks()
97 if (last_block < DIV_ROUND_UP(s->len, s->block_size)) { in sparse_count_chunks()
132 static int write_all_blocks(struct sparse_file *s, struct output_file *out) in write_all_blocks() argument
139 for (bb = backed_block_iter_new(s->backed_block_list); bb; in write_all_blocks()
143 write_skip_chunk(out, (int64_t)blocks * s->block_size); in write_all_blocks()
149 DIV_ROUND_UP(backed_block_len(bb), s->block_size); in write_all_blocks()
152 pad = s->len - (int64_t)last_block * s->block_size; in write_all_blocks()
161 int sparse_file_write(struct sparse_file *s, int fd, bool gz, bool sparse, in sparse_file_write() argument
168 chunks = sparse_count_chunks(s); in sparse_file_write()
169 out = output_file_open_fd(fd, s->block_size, s->len, gz, sparse, chunks, crc); in sparse_file_write()
174 ret = write_all_blocks(s, out); in sparse_file_write()
181 int sparse_file_callback(struct sparse_file *s, bool sparse, bool crc, in sparse_file_callback() argument
188 chunks = sparse_count_chunks(s); in sparse_file_callback()
189 out = output_file_open_callback(write, priv, s->block_size, s->len, false, in sparse_file_callback()
195 ret = write_all_blocks(s, out); in sparse_file_callback()
209 int64_t sparse_file_len(struct sparse_file *s, bool sparse, bool crc) in sparse_file_len() argument
212 int chunks = sparse_count_chunks(s); in sparse_file_len()
217 s->block_size, s->len, false, sparse, chunks, crc); in sparse_file_len()
222 ret = write_all_blocks(s, out); in sparse_file_len()
304 struct sparse_file *s; in sparse_file_resparse() local
314 s = sparse_file_new(in_s->block_size, in_s->len); in sparse_file_resparse()
316 bb = move_chunks_up_to_len(in_s, s, max_len); in sparse_file_resparse()
319 out_s[c] = s; in sparse_file_resparse()
321 backed_block_list_move(s->backed_block_list, tmp->backed_block_list, in sparse_file_resparse()
323 sparse_file_destroy(s); in sparse_file_resparse()
336 void sparse_file_verbose(struct sparse_file *s) in sparse_file_verbose() argument
338 s->verbose = true; in sparse_file_verbose()