Lines Matching refs:out

71 	int (*write_data_chunk)(struct output_file *out, unsigned int len,
73 int (*write_fill_chunk)(struct output_file *out, unsigned int len,
75 int (*write_skip_chunk)(struct output_file *out, int64_t len);
76 int (*write_end_chunk)(struct output_file *out);
94 struct output_file out; member
99 container_of((_o), struct output_file_gz, out)
102 struct output_file out; member
107 container_of((_o), struct output_file_normal, out)
110 struct output_file out; member
116 container_of((_o), struct output_file_callback, out)
118 static int file_open(struct output_file *out, int fd) in file_open() argument
120 struct output_file_normal *outn = to_output_file_normal(out); in file_open()
126 static int file_skip(struct output_file *out, int64_t cnt) in file_skip() argument
129 struct output_file_normal *outn = to_output_file_normal(out); in file_skip()
139 static int file_pad(struct output_file *out, int64_t len) in file_pad() argument
142 struct output_file_normal *outn = to_output_file_normal(out); in file_pad()
152 static int file_write(struct output_file *out, void *data, int len) in file_write() argument
155 struct output_file_normal *outn = to_output_file_normal(out); in file_write()
169 static void file_close(struct output_file *out) in file_close() argument
171 struct output_file_normal *outn = to_output_file_normal(out); in file_close()
184 static int gz_file_open(struct output_file *out, int fd) in gz_file_open() argument
186 struct output_file_gz *outgz = to_output_file_gz(out); in gz_file_open()
198 static int gz_file_skip(struct output_file *out, int64_t cnt) in gz_file_skip() argument
201 struct output_file_gz *outgz = to_output_file_gz(out); in gz_file_skip()
211 static int gz_file_pad(struct output_file *out, int64_t len) in gz_file_pad() argument
214 struct output_file_gz *outgz = to_output_file_gz(out); in gz_file_pad()
235 static int gz_file_write(struct output_file *out, void *data, int len) in gz_file_write() argument
238 struct output_file_gz *outgz = to_output_file_gz(out); in gz_file_write()
252 static void gz_file_close(struct output_file *out) in gz_file_close() argument
254 struct output_file_gz *outgz = to_output_file_gz(out); in gz_file_close()
268 static int callback_file_open(struct output_file *out __unused, int fd __unused) in callback_file_open()
273 static int callback_file_skip(struct output_file *out, int64_t off) in callback_file_skip() argument
275 struct output_file_callback *outc = to_output_file_callback(out); in callback_file_skip()
291 static int callback_file_pad(struct output_file *out __unused, int64_t len __unused) in callback_file_pad()
296 static int callback_file_write(struct output_file *out, void *data, int len) in callback_file_write() argument
298 struct output_file_callback *outc = to_output_file_callback(out); in callback_file_write()
303 static void callback_file_close(struct output_file *out) in callback_file_close() argument
305 struct output_file_callback *outc = to_output_file_callback(out); in callback_file_close()
340 static int write_sparse_skip_chunk(struct output_file *out, int64_t skip_len) in write_sparse_skip_chunk() argument
345 if (skip_len % out->block_size) { in write_sparse_skip_chunk()
347 skip_len, out->block_size); in write_sparse_skip_chunk()
354 chunk_header.chunk_sz = skip_len / out->block_size; in write_sparse_skip_chunk()
356 ret = out->ops->write(out, &chunk_header, sizeof(chunk_header)); in write_sparse_skip_chunk()
360 out->cur_out_ptr += skip_len; in write_sparse_skip_chunk()
361 out->chunk_cnt++; in write_sparse_skip_chunk()
366 static int write_sparse_fill_chunk(struct output_file *out, unsigned int len, in write_sparse_fill_chunk() argument
374 rnd_up_len = ALIGN(len, out->block_size); in write_sparse_fill_chunk()
379 chunk_header.chunk_sz = rnd_up_len / out->block_size; in write_sparse_fill_chunk()
381 ret = out->ops->write(out, &chunk_header, sizeof(chunk_header)); in write_sparse_fill_chunk()
385 ret = out->ops->write(out, &fill_val, sizeof(fill_val)); in write_sparse_fill_chunk()
389 if (out->use_crc) { in write_sparse_fill_chunk()
390 count = out->block_size / sizeof(uint32_t); in write_sparse_fill_chunk()
392 out->crc32 = sparse_crc32(out->crc32, &fill_val, sizeof(uint32_t)); in write_sparse_fill_chunk()
395 out->cur_out_ptr += rnd_up_len; in write_sparse_fill_chunk()
396 out->chunk_cnt++; in write_sparse_fill_chunk()
401 static int write_sparse_data_chunk(struct output_file *out, unsigned int len, in write_sparse_data_chunk() argument
409 rnd_up_len = ALIGN(len, out->block_size); in write_sparse_data_chunk()
415 chunk_header.chunk_sz = rnd_up_len / out->block_size; in write_sparse_data_chunk()
417 ret = out->ops->write(out, &chunk_header, sizeof(chunk_header)); in write_sparse_data_chunk()
421 ret = out->ops->write(out, data, len); in write_sparse_data_chunk()
425 ret = out->ops->write(out, out->zero_buf, zero_len); in write_sparse_data_chunk()
430 if (out->use_crc) { in write_sparse_data_chunk()
431 out->crc32 = sparse_crc32(out->crc32, data, len); in write_sparse_data_chunk()
433 out->crc32 = sparse_crc32(out->crc32, out->zero_buf, zero_len); in write_sparse_data_chunk()
436 out->cur_out_ptr += rnd_up_len; in write_sparse_data_chunk()
437 out->chunk_cnt++; in write_sparse_data_chunk()
442 int write_sparse_end_chunk(struct output_file *out) in write_sparse_end_chunk() argument
447 if (out->use_crc) { in write_sparse_end_chunk()
453 ret = out->ops->write(out, &chunk_header, sizeof(chunk_header)); in write_sparse_end_chunk()
457 out->ops->write(out, &out->crc32, 4); in write_sparse_end_chunk()
462 out->chunk_cnt++; in write_sparse_end_chunk()
475 static int write_normal_data_chunk(struct output_file *out, unsigned int len, in write_normal_data_chunk() argument
479 unsigned int rnd_up_len = ALIGN(len, out->block_size); in write_normal_data_chunk()
481 ret = out->ops->write(out, data, len); in write_normal_data_chunk()
487 ret = out->ops->skip(out, rnd_up_len - len); in write_normal_data_chunk()
493 static int write_normal_fill_chunk(struct output_file *out, unsigned int len, in write_normal_fill_chunk() argument
501 for (i = 0; i < out->block_size / sizeof(uint32_t); i++) { in write_normal_fill_chunk()
502 out->fill_buf[i] = fill_val; in write_normal_fill_chunk()
506 write_len = min(len, out->block_size); in write_normal_fill_chunk()
507 ret = out->ops->write(out, out->fill_buf, write_len); in write_normal_fill_chunk()
518 static int write_normal_skip_chunk(struct output_file *out, int64_t len) in write_normal_skip_chunk() argument
520 return out->ops->skip(out, len); in write_normal_skip_chunk()
523 int write_normal_end_chunk(struct output_file *out) in write_normal_end_chunk() argument
525 return out->ops->pad(out, out->len); in write_normal_end_chunk()
535 void output_file_close(struct output_file *out) in output_file_close() argument
537 out->sparse_ops->write_end_chunk(out); in output_file_close()
538 out->ops->close(out); in output_file_close()
541 static int output_file_init(struct output_file *out, int block_size, in output_file_init() argument
546 out->len = len; in output_file_init()
547 out->block_size = block_size; in output_file_init()
548 out->cur_out_ptr = 0ll; in output_file_init()
549 out->chunk_cnt = 0; in output_file_init()
550 out->crc32 = 0; in output_file_init()
551 out->use_crc = crc; in output_file_init()
553 out->zero_buf = calloc(block_size, 1); in output_file_init()
554 if (!out->zero_buf) { in output_file_init()
559 out->fill_buf = calloc(block_size, 1); in output_file_init()
560 if (!out->fill_buf) { in output_file_init()
567 out->sparse_ops = &sparse_file_ops; in output_file_init()
569 out->sparse_ops = &normal_file_ops; in output_file_init()
579 .blk_sz = out->block_size, in output_file_init()
580 .total_blks = out->len / out->block_size, in output_file_init()
585 if (out->use_crc) { in output_file_init()
589 ret = out->ops->write(out, &sparse_header, sizeof(sparse_header)); in output_file_init()
598 free(out->fill_buf); in output_file_init()
600 free(out->zero_buf); in output_file_init()
612 outgz->out.ops = &gz_file_ops; in output_file_new_gz()
614 return &outgz->out; in output_file_new_gz()
625 outn->out.ops = &file_ops; in output_file_new_normal()
627 return &outn->out; in output_file_new_normal()
643 outc->out.ops = &callback_file_ops; in output_file_open_callback()
647 ret = output_file_init(&outc->out, block_size, len, sparse, chunks, crc); in output_file_open_callback()
653 return &outc->out; in output_file_open_callback()
660 struct output_file *out; in output_file_open_fd() local
663 out = output_file_new_gz(); in output_file_open_fd()
665 out = output_file_new_normal(); in output_file_open_fd()
667 if (!out) { in output_file_open_fd()
671 out->ops->open(out, fd); in output_file_open_fd()
673 ret = output_file_init(out, block_size, len, sparse, chunks, crc); in output_file_open_fd()
675 free(out); in output_file_open_fd()
679 return out; in output_file_open_fd()
683 int write_data_chunk(struct output_file *out, unsigned int len, void *data) in write_data_chunk() argument
685 return out->sparse_ops->write_data_chunk(out, len, data); in write_data_chunk()
689 int write_fill_chunk(struct output_file *out, unsigned int len, in write_fill_chunk() argument
692 return out->sparse_ops->write_fill_chunk(out, len, fill_val); in write_fill_chunk()
695 int write_fd_chunk(struct output_file *out, unsigned int len, in write_fd_chunk() argument
734 ret = out->sparse_ops->write_data_chunk(out, len, ptr); in write_fd_chunk()
746 int write_file_chunk(struct output_file *out, unsigned int len, in write_file_chunk() argument
756 ret = write_fd_chunk(out, len, file_fd, offset); in write_file_chunk()
763 int write_skip_chunk(struct output_file *out, int64_t len) in write_skip_chunk() argument
765 return out->sparse_ops->write_skip_chunk(out, len); in write_skip_chunk()