Lines Matching refs:len
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);
87 int64_t len; member
112 int (*write)(void *priv, const void *buf, int len);
139 static int file_pad(struct output_file *out, int64_t len) in file_pad() argument
144 ret = ftruncate64(outn->fd, len); in file_pad()
152 static int file_write(struct output_file *out, void *data, int len) in file_write() argument
157 ret = write(outn->fd, data, len); in file_write()
161 } else if (ret < len) { in file_write()
211 static int gz_file_pad(struct output_file *out, int64_t len) in gz_file_pad() argument
221 if (ret >= len) { in gz_file_pad()
225 ret = gzseek(outgz->gz_fd, len - 1, SEEK_SET); in gz_file_pad()
235 static int gz_file_write(struct output_file *out, void *data, int len) in gz_file_write() argument
240 ret = gzwrite(outgz->gz_fd, data, len); in gz_file_write()
244 } else if (ret < len) { in gz_file_write()
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
300 return outc->write(outc->priv, data, len); in callback_file_write()
318 int read_all(int fd, void *buf, size_t len) in read_all() argument
324 while (total < len) { in read_all()
325 ret = read(fd, ptr, len - total); in read_all()
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()
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()
410 zero_len = rnd_up_len - len; in write_sparse_data_chunk()
421 ret = out->ops->write(out, data, len); in write_sparse_data_chunk()
431 out->crc32 = sparse_crc32(out->crc32, data, len); in write_sparse_data_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()
486 if (rnd_up_len > 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
505 while (len) { in write_normal_fill_chunk()
506 write_len = min(len, out->block_size); in write_normal_fill_chunk()
512 len -= 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()
525 return out->ops->pad(out, out->len); in write_normal_end_chunk()
542 int64_t len, bool sparse, int chunks, bool crc) in output_file_init() argument
546 out->len = len; in output_file_init()
580 .total_blks = out->len / out->block_size, in output_file_init()
631 void *priv, unsigned int block_size, int64_t len, in output_file_open_callback() argument
647 ret = output_file_init(&outc->out, block_size, len, sparse, chunks, crc); in output_file_open_callback()
656 struct output_file *output_file_open_fd(int fd, unsigned int block_size, int64_t len, in output_file_open_fd() argument
673 ret = output_file_init(out, block_size, len, sparse, chunks, crc); 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
706 buffer_size = len + aligned_diff; in write_fd_chunk()
717 char *data = malloc(len); in write_fd_chunk()
726 ret = read_all(fd, data, len); in write_fd_chunk()
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()