Lines Matching refs:s
31 struct sparse_file *s = calloc(sizeof(struct sparse_file), 1); in sparse_file_new() local
32 if (!s) { in sparse_file_new()
36 s->backed_block_list = backed_block_list_new(block_size); in sparse_file_new()
37 if (!s->backed_block_list) { in sparse_file_new()
38 free(s); in sparse_file_new()
42 s->block_size = block_size; in sparse_file_new()
43 s->len = len; in sparse_file_new()
45 return s; in sparse_file_new()
48 void sparse_file_destroy(struct sparse_file *s) in sparse_file_destroy() argument
50 backed_block_list_destroy(s->backed_block_list); in sparse_file_destroy()
51 free(s); in sparse_file_destroy()
54 int sparse_file_add_data(struct sparse_file *s, in sparse_file_add_data() argument
57 return backed_block_add_data(s->backed_block_list, data, len, block); in sparse_file_add_data()
60 int sparse_file_add_fill(struct sparse_file *s, in sparse_file_add_fill() argument
63 return backed_block_add_fill(s->backed_block_list, fill_val, len, block); in sparse_file_add_fill()
66 int sparse_file_add_file(struct sparse_file *s, in sparse_file_add_file() argument
70 return backed_block_add_file(s->backed_block_list, filename, file_offset, in sparse_file_add_file()
74 int sparse_file_add_fd(struct sparse_file *s, in sparse_file_add_fd() argument
77 return backed_block_add_fd(s->backed_block_list, fd, file_offset, in sparse_file_add_fd()
80 unsigned int sparse_count_chunks(struct sparse_file *s) in sparse_count_chunks() argument
86 for (bb = backed_block_iter_new(s->backed_block_list); bb; in sparse_count_chunks()
94 DIV_ROUND_UP(backed_block_len(bb), s->block_size); in sparse_count_chunks()
96 if (last_block < DIV_ROUND_UP(s->len, s->block_size)) { in sparse_count_chunks()
125 static int write_all_blocks(struct sparse_file *s, struct output_file *out) in write_all_blocks() argument
131 for (bb = backed_block_iter_new(s->backed_block_list); bb; in write_all_blocks()
135 write_skip_chunk(out, (int64_t)blocks * s->block_size); in write_all_blocks()
139 DIV_ROUND_UP(backed_block_len(bb), s->block_size); in write_all_blocks()
142 pad = s->len - (int64_t)last_block * s->block_size; in write_all_blocks()
151 int sparse_file_write(struct sparse_file *s, int fd, bool gz, bool sparse, in sparse_file_write() argument
158 chunks = sparse_count_chunks(s); in sparse_file_write()
159 out = output_file_open_fd(fd, s->block_size, s->len, gz, sparse, chunks, crc); in sparse_file_write()
164 ret = write_all_blocks(s, out); in sparse_file_write()
171 int sparse_file_callback(struct sparse_file *s, bool sparse, bool crc, in sparse_file_callback() argument
178 chunks = sparse_count_chunks(s); in sparse_file_callback()
179 out = output_file_open_callback(write, priv, s->block_size, s->len, false, in sparse_file_callback()
185 ret = write_all_blocks(s, out); in sparse_file_callback()
199 int64_t sparse_file_len(struct sparse_file *s, bool sparse, bool crc) in sparse_file_len() argument
202 int chunks = sparse_count_chunks(s); in sparse_file_len()
207 s->block_size, s->len, false, sparse, chunks, crc); in sparse_file_len()
212 ret = write_all_blocks(s, out); in sparse_file_len()
282 struct sparse_file *s; in sparse_file_resparse() local
292 s = sparse_file_new(in_s->block_size, in_s->len); in sparse_file_resparse()
294 bb = move_chunks_up_to_len(in_s, s, max_len); in sparse_file_resparse()
297 out_s[c] = s; in sparse_file_resparse()
299 backed_block_list_move(s->backed_block_list, tmp->backed_block_list, in sparse_file_resparse()
301 sparse_file_destroy(s); in sparse_file_resparse()
314 void sparse_file_verbose(struct sparse_file *s) in sparse_file_verbose() argument
316 s->verbose = true; in sparse_file_verbose()